2023-06-27 15:41:34 +08:00
|
|
|
from django.db import models
|
|
|
|
from django.db.models.signals import post_migrate
|
|
|
|
from django.dispatch import receiver
|
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
|
|
|
|
|
|
|
|
class Year_Level(models.Model):
|
|
|
|
name = models.CharField(max_length=64)
|
|
|
|
shortname = models.CharField(max_length=16)
|
|
|
|
|
|
|
|
def __str__(self):
|
2023-06-27 15:48:43 +08:00
|
|
|
return self.name
|
2023-06-27 15:41:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
@receiver(post_migrate)
|
|
|
|
def populate_courses(sender, **kwargs):
|
|
|
|
if sender.name == 'year_levels':
|
|
|
|
Year_Level.objects.get_or_create(
|
2023-06-27 18:15:31 +08:00
|
|
|
name='1st Year', shortname='1stYr')
|
2023-06-27 15:41:34 +08:00
|
|
|
Year_Level.objects.get_or_create(
|
2023-06-27 18:15:31 +08:00
|
|
|
name='2nd Year', shortname='2ndYr')
|
2023-06-27 15:41:34 +08:00
|
|
|
Year_Level.objects.get_or_create(
|
2023-06-27 18:15:31 +08:00
|
|
|
name='3rd Year', shortname='3rdYr')
|
2023-06-27 15:41:34 +08:00
|
|
|
Year_Level.objects.get_or_create(
|
2023-06-27 18:15:31 +08:00
|
|
|
name='4th Year', shortname='4thYr')
|
2023-06-27 15:41:34 +08:00
|
|
|
Year_Level.objects.get_or_create(
|
|
|
|
name='Irregular', shortname='Irreg')
|
|
|
|
# Add more predefined records as needed
|