diff --git a/back-end/src/ams/migrations/0004_fix_student_deletion.py b/back-end/src/ams/migrations/0004_fix_student_deletion.py deleted file mode 100644 index 193963a4..00000000 --- a/back-end/src/ams/migrations/0004_fix_student_deletion.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 3.2.20 on 2024-09-06 13:00 - -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', '0004_add_personal_documents_info'), - ('ams', '0003_add_personal_documents_info'), - ] - - 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), - ), - ] diff --git a/back-end/src/ams/models/applicants.py b/back-end/src/ams/models/applicants.py index 8e738e26..fe11d777 100644 --- a/back-end/src/ams/models/applicants.py +++ b/back-end/src/ams/models/applicants.py @@ -149,9 +149,7 @@ class Applicant(models.Model): ) contact_info = models.OneToOneField( to=ContactInfo, - on_delete=models.SET_NULL, - null=True, - blank=True, + on_delete=models.RESTRICT, ) photo = models.OneToOneField( to=Photo, @@ -174,9 +172,7 @@ class Applicant(models.Model): ) user = models.OneToOneField( to=get_user_model(), - on_delete=models.SET_NULL, - null=True, - blank=True, + on_delete=models.RESTRICT, ) objects = ApplicantManager() diff --git a/back-end/src/lms/migrations/0009_fix_student_deletion.py b/back-end/src/lms/migrations/0009_fix_student_deletion.py deleted file mode 100644 index ba94d876..00000000 --- a/back-end/src/lms/migrations/0009_fix_student_deletion.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 3.2.20 on 2024-09-06 13:00 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('common', '0004_add_personal_documents_info'), - ('lms', '0008_add_personal_documents_info'), - ] - - 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'), - ), - ] diff --git a/back-end/src/lms/models/students.py b/back-end/src/lms/models/students.py index 71757358..7c7642b6 100644 --- a/back-end/src/lms/models/students.py +++ b/back-end/src/lms/models/students.py @@ -72,9 +72,7 @@ class Post(models.TextChoices): ) contact_info = models.OneToOneField( to=ContactInfo, - on_delete=models.SET_NULL, - null=True, - blank=True, + on_delete=models.RESTRICT, ) # -------------------------------------------------------------------------- @@ -210,6 +208,13 @@ def student_post_callback(sender, instance: Student, *args, **kwargs): @receiver(models.signals.post_delete, sender=Student) def post_delete_fields(sender, instance: Student, **kwargs): + # Если у пользователя есть модель абитуриента, удаляем и её + if instance.user: + try: + applicant = Applicant.objects.get(user=instance.user) + applicant.delete() + except Applicant.DoesNotExist: + pass # pylint: disable=unused-argument attributes_to_delete = [ "user", diff --git a/back-end/src/lms/views/students.py b/back-end/src/lms/views/students.py index 940a0287..e8df9e10 100644 --- a/back-end/src/lms/views/students.py +++ b/back-end/src/lms/views/students.py @@ -160,7 +160,7 @@ def registration(self, request): serializer = self.get_serializer(instance) return Response(serializer.data) - @action(detail=False, methods=["post"], permission_classes=[permissions.AllowAny]) + @action(detail=False, methods=["post"], permission_classes=[permissions.IsAdminUser]) def register_from_applicant(self, request): request.data[ "status" diff --git a/front-end/src/components/ApplicantToStudent/index.vue b/front-end/src/components/ApplicantToStudent/index.vue index 14e53aa3..357f719b 100644 --- a/front-end/src/components/ApplicantToStudent/index.vue +++ b/front-end/src/components/ApplicantToStudent/index.vue @@ -16,7 +16,7 @@

- Регистрация студента + Регистрация студента ВУЦ из абитуриента

@@ -37,10 +37,10 @@ :visible.sync="registrationComplete" >

- Ожидайте подтверждения регистрации. + Абитуриент успешно зарегистрирован в качестве студента Военного учебного центра.

- После подтверждения на Вашу почту будет выслана ссылка для создания пароля. + Информацию о нём можно просмотреть в разделе "Личный состав ВУЦ".

@@ -74,7 +74,7 @@ export default { this.registrationComplete = true; setTimeout(() => { this.$router.replace({ name: "Login" }); - }, 4000); + }, 2000); }, }, };