Skip to content

Commit

Permalink
Fix issue with student deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
startsev2000 committed Sep 6, 2024
1 parent 174f25d commit 9b46247
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
27 changes: 27 additions & 0 deletions back-end/src/ams/migrations/0003_fix_delete_student_again.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.20 on 2024-09-06 09:38

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('common', '0003_program_available_to_choose_for_applicants'),
('ams', '0002_applicationprocess_mtc_admission_year'),
]

operations = [
migrations.AlterField(
model_name='applicant',
name='contact_info',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='common.contactinfo'),
),
migrations.AlterField(
model_name='applicant',
name='user',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
8 changes: 6 additions & 2 deletions back-end/src/ams/models/applicants.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class Applicant(models.Model):
)
contact_info = models.OneToOneField(
to=ContactInfo,
on_delete=models.RESTRICT,
on_delete=models.SET_NULL,
null=True,
blank=True,
)
photo = models.OneToOneField(
to=Photo,
Expand All @@ -172,7 +174,9 @@ class Applicant(models.Model):
)
user = models.OneToOneField(
to=get_user_model(),
on_delete=models.RESTRICT,
on_delete=models.SET_NULL,
null=True,
blank=True,
)

objects = ApplicantManager()
Expand Down
20 changes: 20 additions & 0 deletions back-end/src/lms/migrations/0008_fix_delete_student.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.20 on 2024-09-06 09:30

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('common', '0003_program_available_to_choose_for_applicants'),
('lms', '0007_alter_mark_changed_by'),
]

operations = [
migrations.AlterField(
model_name='student',
name='contact_info',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='common.contactinfo'),
),
]
4 changes: 3 additions & 1 deletion back-end/src/lms/models/students.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class Post(models.TextChoices):
)
contact_info = models.OneToOneField(
to=ContactInfo,
on_delete=models.RESTRICT,
on_delete=models.SET_NULL,
null=True,
blank=True,
)

# --------------------------------------------------------------------------
Expand Down

0 comments on commit 9b46247

Please sign in to comment.