2023-03-21 21:49:26 +08:00
|
|
|
from django.db import models
|
|
|
|
# Create your models here.
|
|
|
|
|
|
|
|
|
|
|
|
class Student(models.Model):
|
|
|
|
|
|
|
|
class YearLevels(models.TextChoices):
|
2023-04-22 13:05:14 +08:00
|
|
|
FIRST_YEAR = '1st Year'
|
|
|
|
SECOND_YEAR = '2nd Year'
|
|
|
|
THIRD_YEAR = '3rd Year'
|
2023-03-21 21:49:26 +08:00
|
|
|
FOURTH_YEAR = 'IU-Y4', '4th Year'
|
|
|
|
|
2023-03-21 21:59:09 +08:00
|
|
|
class Semesters(models.TextChoices):
|
2023-04-22 13:05:14 +08:00
|
|
|
FIRST_SEM = '1st Semester'
|
|
|
|
SECOND_SEM = '2nd Semester'
|
2023-03-21 21:59:09 +08:00
|
|
|
|
2023-03-21 21:49:26 +08:00
|
|
|
class SexChoices(models.TextChoices):
|
|
|
|
MALE = 'M', 'Male'
|
|
|
|
FEMALE = 'F', 'Female'
|
|
|
|
|
|
|
|
first_name = models.CharField(max_length=40)
|
|
|
|
middle_name = models.CharField(max_length=40)
|
|
|
|
last_name = models.CharField(max_length=40)
|
2023-04-22 13:03:43 +08:00
|
|
|
full_name = models.CharField(max_length=120)
|
2023-03-21 21:49:26 +08:00
|
|
|
#
|
|
|
|
age = models.IntegerField()
|
|
|
|
sex = models.CharField(max_length=1, choices=SexChoices.choices)
|
|
|
|
birthdate = models.DateField()
|
|
|
|
#
|
|
|
|
address = models.CharField(max_length=150)
|
|
|
|
birthplace = models.CharField(max_length=150)
|
|
|
|
#
|
|
|
|
mother_name = models.CharField(max_length=80)
|
|
|
|
father_name = models.CharField(max_length=80)
|
|
|
|
#
|
|
|
|
registrar_done = models.BooleanField()
|
|
|
|
clearance_done = models.BooleanField()
|
|
|
|
pta_done = models.BooleanField()
|
|
|
|
#
|
2023-04-22 13:42:09 +08:00
|
|
|
schedules = models.ManyToManyField(
|
|
|
|
'schedules.Schedule', related_name='StudentSchedule_subject', through='schedules.StudentSchedule')
|
|
|
|
#
|
2023-03-21 21:49:26 +08:00
|
|
|
year_level = models.CharField(max_length=20, choices=YearLevels.choices)
|
2023-03-21 21:59:09 +08:00
|
|
|
current_semester = models.CharField(
|
|
|
|
max_length=20, choices=Semesters.choices, default=Semesters.FIRST_SEM)
|
2023-03-21 21:49:26 +08:00
|
|
|
|
2023-04-22 13:03:43 +08:00
|
|
|
def save(self, *args, **kwargs):
|
|
|
|
self.full_name = f"{self.first_name} {self.middle_name} {self.last_name}"
|
|
|
|
super().save(*args, **kwargs)
|
2023-04-22 11:59:16 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.full_name
|