mirror of
https://github.com/lemeow125/InfoTech-Backend.git
synced 2024-11-17 06:29:26 +08:00
Polish current semester choices on both student and subject
This commit is contained in:
parent
249e4e920e
commit
bb939198e5
6 changed files with 51 additions and 2 deletions
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -11,6 +11,10 @@ class Student(models.Model):
|
||||||
THIRD_YEAR = 'IU-Y3', '3rd Year'
|
THIRD_YEAR = 'IU-Y3', '3rd Year'
|
||||||
FOURTH_YEAR = 'IU-Y4', '4th 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):
|
class SexChoices(models.TextChoices):
|
||||||
MALE = 'M', 'Male'
|
MALE = 'M', 'Male'
|
||||||
FEMALE = 'F', 'Female'
|
FEMALE = 'F', 'Female'
|
||||||
|
@ -35,6 +39,8 @@ class Student(models.Model):
|
||||||
#
|
#
|
||||||
enrolled_subjects = models.CharField(max_length=800)
|
enrolled_subjects = models.CharField(max_length=800)
|
||||||
year_level = models.CharField(max_length=20, choices=YearLevels.choices)
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -12,6 +12,6 @@ class StudentSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
'address', 'birthplace',
|
'address', 'birthplace',
|
||||||
'mother_name', 'father_name',
|
'mother_name', 'father_name',
|
||||||
'registrar_done', 'clearance_done', 'pta_done',
|
'registrar_done', 'clearance_done', 'pta_done',
|
||||||
'enrolled_subjects', 'year_level'
|
'enrolled_subjects', 'year_level', 'current_semester'
|
||||||
]
|
]
|
||||||
read_only_fields = ['id']
|
read_only_fields = ['id']
|
||||||
|
|
18
infotech/subjects/migrations/0003_subject_semester.py
Normal file
18
infotech/subjects/migrations/0003_subject_semester.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -10,6 +10,10 @@ class Subject(models.Model):
|
||||||
THIRD_YEAR = 'IU-Y3', '3rd Year'
|
THIRD_YEAR = 'IU-Y3', '3rd Year'
|
||||||
FOURTH_YEAR = 'IU-Y4', '4th 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)
|
name = models.CharField(max_length=40)
|
||||||
enrolled_count = models.IntegerField(
|
enrolled_count = models.IntegerField(
|
||||||
default=0,
|
default=0,
|
||||||
|
@ -19,6 +23,8 @@ class Subject(models.Model):
|
||||||
])
|
])
|
||||||
max_slots = models.IntegerField(default=60)
|
max_slots = models.IntegerField(default=60)
|
||||||
year_level = models.CharField(max_length=20, choices=YearLevels.choices)
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -8,5 +8,6 @@ class SubjectSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Subject
|
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',)
|
read_only_fields = ('id',)
|
||||||
|
|
Loading…
Reference in a new issue