mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Improved code for uupdating course year level and semester for student and for postmigration generation of subjects per course
This commit is contained in:
parent
41b2747495
commit
bf9ed11a9e
2 changed files with 14 additions and 15 deletions
|
@ -50,10 +50,10 @@ class CustomUserSerializer(BaseUserSerializer):
|
||||||
# First, we'll remove all the existing subjects from the user
|
# First, we'll remove all the existing subjects from the user
|
||||||
print(validated_data)
|
print(validated_data)
|
||||||
# If course, year_level, or semester is changed
|
# If course, year_level, or semester is changed
|
||||||
if ('course' in validated_data or 'year_level' in validated_data or 'semester' in validated_data):
|
if any(field in validated_data for field in ['course', 'year_level', 'semester']):
|
||||||
if (instance.course is not validated_data['course'] or
|
if (instance.course != validated_data['course'] or
|
||||||
instance.year_level is not validated_data['year_level'] or
|
instance.year_level != validated_data['year_level'] or
|
||||||
instance.semester is not validated_data['semester']):
|
instance.semester != validated_data['semester']):
|
||||||
|
|
||||||
# Clear all subjects
|
# Clear all subjects
|
||||||
instance.subjects.clear()
|
instance.subjects.clear()
|
||||||
|
|
|
@ -96,19 +96,18 @@ def populate_subjects(sender, **kwargs):
|
||||||
subject_code = row[1]
|
subject_code = row[1]
|
||||||
subject_name = row[2]
|
subject_name = row[2]
|
||||||
|
|
||||||
# Skip ROTC/NSTP Subjects
|
ignored_subject_codes = ['NSTP', 'ROTC', 'CWTS', 'LTS']
|
||||||
if ('NSTP' in subject_code or 'ROTC' in subject_code or 'CWTS' in subject_code or 'LTS' in subject_code):
|
ignored_subject_names = [
|
||||||
print('NSTP/ROTC subject', subject_name, 'omitted...')
|
'PRACTICUM', 'On the Job Training', 'CAPSTONE', 'Capstone']
|
||||||
|
# Skip ignored subjects
|
||||||
|
if any(ignored_code in subject_code for ignored_code in ignored_subject_codes):
|
||||||
|
print('Ignored subject', subject_name,
|
||||||
|
'with code', subject_code)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip Practicum Subjects
|
if any(ignored_name in subject_name for ignored_name in ignored_subject_names):
|
||||||
if ('PRACTICUM' in subject_name or 'On the Job Training' in subject_name):
|
print('Ignored subject', subject_name,
|
||||||
print('OJT subject', subject_name, 'omitted...')
|
'with code', subject_code)
|
||||||
continue
|
|
||||||
|
|
||||||
# Skip Capstone Subjects
|
|
||||||
if ('CAPSTONE' in subject_name or 'Capstone' in subject_name):
|
|
||||||
print('Capstone subject', subject_name, 'omitted...')
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
course = Course.objects.filter(
|
course = Course.objects.filter(
|
||||||
|
|
Loading…
Reference in a new issue