mirror of
https://github.com/lemeow125/InfoTech-Backend.git
synced 2024-11-17 06:29:26 +08:00
Polished full_name for professor and student
This commit is contained in:
parent
f9b585108e
commit
cdd4db9b6a
7 changed files with 91 additions and 8 deletions
19
infotech/professors/migrations/0002_professor_full_name.py
Normal file
19
infotech/professors/migrations/0002_professor_full_name.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 4.2 on 2023-04-22 04:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('professors', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='professor',
|
||||||
|
name='full_name',
|
||||||
|
field=models.CharField(db_column='full_name', default=' ', max_length=80),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 4.2 on 2023-04-22 04:57
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('professors', '0002_professor_full_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='professor',
|
||||||
|
name='full_name',
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Generated by Django 4.2 on 2023-04-22 05:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('professors', '0003_remove_professor_full_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='professor',
|
||||||
|
name='full_name',
|
||||||
|
field=models.CharField(default=' ', max_length=120),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='professor',
|
||||||
|
name='middle_name',
|
||||||
|
field=models.CharField(default=' ', max_length=40),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -10,16 +10,18 @@ class Professor(models.Model):
|
||||||
FEMALE = 'Female',
|
FEMALE = 'Female',
|
||||||
|
|
||||||
first_name = models.CharField(max_length=40)
|
first_name = models.CharField(max_length=40)
|
||||||
|
middle_name = models.CharField(max_length=40)
|
||||||
last_name = models.CharField(max_length=40)
|
last_name = models.CharField(max_length=40)
|
||||||
|
full_name = models.CharField(max_length=120)
|
||||||
age = models.IntegerField()
|
age = models.IntegerField()
|
||||||
date_joined = models.DateTimeField(default=now, editable=False)
|
date_joined = models.DateTimeField(default=now, editable=False)
|
||||||
gender = models.CharField(max_length=20, choices=Genders.choices)
|
gender = models.CharField(max_length=20, choices=Genders.choices)
|
||||||
# subjects = models.ManyToManyField(
|
# subjects = models.ManyToManyField(
|
||||||
# 'subjects.Subject', through='subjects.SubjectProfessor')
|
# 'subjects.Subject', through='subjects.SubjectProfessor')
|
||||||
|
|
||||||
@property
|
def save(self, *args, **kwargs):
|
||||||
def full_name(self):
|
self.full_name = f"{self.first_name} {self.last_name}"
|
||||||
return f"{self.first_name} {self.last_name}"
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.full_name
|
return self.full_name
|
||||||
|
|
19
infotech/students/migrations/0009_student_full_name.py
Normal file
19
infotech/students/migrations/0009_student_full_name.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 4.2 on 2023-04-22 05:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('students', '0008_remove_student_schedules'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='student',
|
||||||
|
name='full_name',
|
||||||
|
field=models.CharField(default=' ', max_length=120),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -21,6 +21,7 @@ class Student(models.Model):
|
||||||
first_name = models.CharField(max_length=40)
|
first_name = models.CharField(max_length=40)
|
||||||
middle_name = models.CharField(max_length=40)
|
middle_name = models.CharField(max_length=40)
|
||||||
last_name = models.CharField(max_length=40)
|
last_name = models.CharField(max_length=40)
|
||||||
|
full_name = models.CharField(max_length=120)
|
||||||
#
|
#
|
||||||
age = models.IntegerField()
|
age = models.IntegerField()
|
||||||
sex = models.CharField(max_length=1, choices=SexChoices.choices)
|
sex = models.CharField(max_length=1, choices=SexChoices.choices)
|
||||||
|
@ -42,9 +43,9 @@ class Student(models.Model):
|
||||||
current_semester = models.CharField(
|
current_semester = models.CharField(
|
||||||
max_length=20, choices=Semesters.choices, default=Semesters.FIRST_SEM)
|
max_length=20, choices=Semesters.choices, default=Semesters.FIRST_SEM)
|
||||||
|
|
||||||
@property
|
def save(self, *args, **kwargs):
|
||||||
def full_name(self):
|
self.full_name = f"{self.first_name} {self.middle_name} {self.last_name}"
|
||||||
return f"{self.first_name} {self.last_name}"
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.full_name
|
return self.full_name
|
||||||
|
|
|
@ -8,11 +8,11 @@ class StudentSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Student
|
model = Student
|
||||||
fields = ['id', 'first_name', 'middle_name', 'last_name',
|
fields = ['id', 'full_name', 'first_name', 'middle_name', 'last_name',
|
||||||
'age', 'sex', 'birthdate',
|
'age', 'sex', 'birthdate',
|
||||||
'address', 'birthplace',
|
'address', 'birthplace',
|
||||||
'mother_name', 'father_name',
|
'mother_name', 'father_name',
|
||||||
'registrar_done', 'clearance_done', 'pta_done',
|
'registrar_done', 'clearance_done', 'pta_done',
|
||||||
'year_level', 'current_semester'
|
'year_level', 'current_semester'
|
||||||
]
|
]
|
||||||
read_only_fields = ['id']
|
read_only_fields = ['id', 'full_name']
|
||||||
|
|
Loading…
Reference in a new issue