Polish current semester choices on both student and subject

This commit is contained in:
keannu125 2023-03-21 21:59:09 +08:00
parent 249e4e920e
commit bb939198e5
6 changed files with 51 additions and 2 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-21 13:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('students', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='student',
name='current_semester',
field=models.CharField(choices=[('Sem-1', '1st Semester'), ('Sem-2', '2nd Semester')], default='Sem-1', max_length=20),
),
]

View file

@ -11,6 +11,10 @@ class Student(models.Model):
THIRD_YEAR = 'IU-Y3', '3rd Year'
FOURTH_YEAR = 'IU-Y4', '4th Year'
class Semesters(models.TextChoices):
FIRST_SEM = 'Sem-1', '1st Semester'
SECOND_SEM = 'Sem-2', '2nd Semester'
class SexChoices(models.TextChoices):
MALE = 'M', 'Male'
FEMALE = 'F', 'Female'
@ -35,6 +39,8 @@ class Student(models.Model):
#
enrolled_subjects = models.CharField(max_length=800)
year_level = models.CharField(max_length=20, choices=YearLevels.choices)
current_semester = models.CharField(
max_length=20, choices=Semesters.choices, default=Semesters.FIRST_SEM)
def __str__(self):
return self.name

View file

@ -12,6 +12,6 @@ class StudentSerializer(serializers.HyperlinkedModelSerializer):
'address', 'birthplace',
'mother_name', 'father_name',
'registrar_done', 'clearance_done', 'pta_done',
'enrolled_subjects', 'year_level'
'enrolled_subjects', 'year_level', 'current_semester'
]
read_only_fields = ['id']

View file

@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-03-21 13:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('subjects', '0002_alter_subject_year_level'),
]
operations = [
migrations.AddField(
model_name='subject',
name='semester',
field=models.CharField(choices=[('Sem-1', '1st Semester'), ('Sem-2', '2nd Semester')], default='Sem-1', max_length=20),
),
]

View file

@ -10,6 +10,10 @@ class Subject(models.Model):
THIRD_YEAR = 'IU-Y3', '3rd Year'
FOURTH_YEAR = 'IU-Y4', '4th Year'
class Semesters(models.TextChoices):
FIRST_SEM = 'Sem-1', '1st Semester'
SECOND_SEM = 'Sem-2', '2nd Semester'
name = models.CharField(max_length=40)
enrolled_count = models.IntegerField(
default=0,
@ -19,6 +23,8 @@ class Subject(models.Model):
])
max_slots = models.IntegerField(default=60)
year_level = models.CharField(max_length=20, choices=YearLevels.choices)
semester = models.CharField(
max_length=20, choices=Semesters.choices, default=Semesters.FIRST_SEM)
def __str__(self):
return self.name

View file

@ -8,5 +8,6 @@ class SubjectSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Subject
fields = ('id', 'name', 'enrolled_count', 'max_slots', 'year_level')
fields = ('id', 'name', 'enrolled_count',
'max_slots', 'year_level', 'semester')
read_only_fields = ('id',)