mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Hotfix for registration crashing due to non-unique StudentStatus instance creation
This commit is contained in:
parent
1eb1f71232
commit
d7f88e1770
16 changed files with 27 additions and 102 deletions
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
import accounts.models
|
import accounts.models
|
||||||
import django.contrib.auth.models
|
import django.contrib.auth.models
|
||||||
|
@ -13,9 +13,9 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
('courses', '0001_initial'),
|
||||||
('semesters', '0001_initial'),
|
('semesters', '0001_initial'),
|
||||||
('auth', '0012_alter_user_first_name_max_length'),
|
('auth', '0012_alter_user_first_name_max_length'),
|
||||||
('courses', '0001_initial'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
@ -9,9 +9,9 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
('accounts', '0001_initial'),
|
||||||
('year_levels', '0001_initial'),
|
('year_levels', '0001_initial'),
|
||||||
('subjects', '0001_initial'),
|
('subjects', '0001_initial'),
|
||||||
('accounts', '0001_initial'),
|
|
||||||
('auth', '0012_alter_user_first_name_max_length'),
|
('auth', '0012_alter_user_first_name_max_length'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-30 15:35
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('accounts', '0002_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterModelOptions(
|
|
||||||
name='customuser',
|
|
||||||
options={},
|
|
||||||
),
|
|
||||||
migrations.AlterUniqueTogether(
|
|
||||||
name='customuser',
|
|
||||||
unique_together={('first_name', 'last_name')},
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,21 +0,0 @@
|
||||||
# Generated by Django 4.2.3 on 2023-10-01 05:25
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('accounts', '0003_alter_customuser_options_and_more'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterModelOptions(
|
|
||||||
name='customuser',
|
|
||||||
options={'verbose_name': 'user', 'verbose_name_plural': 'users'},
|
|
||||||
),
|
|
||||||
migrations.AlterUniqueTogether(
|
|
||||||
name='customuser',
|
|
||||||
unique_together=set(),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -155,10 +155,12 @@ class UserRegistrationSerializer(serializers.ModelSerializer):
|
||||||
user.set_password(validated_data['password'])
|
user.set_password(validated_data['password'])
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
StudentStatus.objects.create(
|
StudentStatus.objects.update_or_create(
|
||||||
user=user,
|
user=user,
|
||||||
active=False,
|
defaults={
|
||||||
location=Point(0, 0),
|
'active': False,
|
||||||
subject=None
|
'location': Point(0, 0),
|
||||||
|
'subject': None
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return user
|
return user
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
import django.contrib.gis.db.models.fields
|
import django.contrib.gis.db.models.fields
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import django.contrib.gis.db.models.fields
|
import django.contrib.gis.db.models.fields
|
||||||
|
@ -11,23 +11,24 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('accounts', '0001_initial'),
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
('study_groups', '0001_initial'),
|
('study_groups', '0001_initial'),
|
||||||
('landmarks', '0001_initial'),
|
|
||||||
('subjects', '0001_initial'),
|
('subjects', '0001_initial'),
|
||||||
|
('landmarks', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='StudentStatus',
|
name='StudentStatus',
|
||||||
fields=[
|
fields=[
|
||||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
|
('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
|
||||||
('active', models.BooleanField(default=False)),
|
('active', models.BooleanField(default=False)),
|
||||||
('timestamp', models.DateTimeField(auto_now_add=True)),
|
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||||
('landmark', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='landmarks.landmark')),
|
('landmark', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='landmarks.landmark')),
|
||||||
('study_group', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='students', to='study_groups.studygroup')),
|
('study_group', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='students', to='study_groups.studygroup')),
|
||||||
('subject', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='subjects.subject', to_field='name')),
|
('subject', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='subjects.subject', to_field='name')),
|
||||||
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.dispatch import receiver
|
||||||
|
|
||||||
class StudentStatus(models.Model):
|
class StudentStatus(models.Model):
|
||||||
user = models.OneToOneField(
|
user = models.OneToOneField(
|
||||||
CustomUser, on_delete=models.CASCADE, primary_key=True)
|
CustomUser, on_delete=models.CASCADE, unique=True)
|
||||||
location = gis_models.PointField(blank=True, null=True, srid=4326)
|
location = gis_models.PointField(blank=True, null=True, srid=4326)
|
||||||
subject = models.ForeignKey(
|
subject = models.ForeignKey(
|
||||||
'subjects.Subject', on_delete=models.SET_NULL, null=True, to_field='name')
|
'subjects.Subject', on_delete=models.SET_NULL, null=True, to_field='name')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
import django.contrib.gis.db.models.fields
|
import django.contrib.gis.db.models.fields
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -19,9 +19,8 @@ class Migration(migrations.Migration):
|
||||||
name='StudyGroup',
|
name='StudyGroup',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(max_length=48)),
|
('name', models.CharField(max_length=48, unique=True)),
|
||||||
('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
|
('location', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)),
|
||||||
('active', models.BooleanField(default=False)),
|
|
||||||
('timestamp', models.DateField(auto_now_add=True)),
|
('timestamp', models.DateField(auto_now_add=True)),
|
||||||
('landmark', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='landmarks.landmark')),
|
('landmark', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='landmarks.landmark')),
|
||||||
('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='subjects.subject')),
|
('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='subjects.subject')),
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
# Generated by Django 4.2.5 on 2023-09-26 12:30
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('study_groups', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='studygroup',
|
|
||||||
name='active',
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 4.2.5 on 2023-09-28 12:25
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('study_groups', '0002_remove_studygroup_active'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='studygroup',
|
|
||||||
name='name',
|
|
||||||
field=models.CharField(max_length=48, unique=True),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -10,8 +10,8 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('study_groups', '0001_initial'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('study_groups', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -10,10 +10,10 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
('courses', '0001_initial'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
('year_levels', '0001_initial'),
|
('year_levels', '0001_initial'),
|
||||||
('semesters', '0001_initial'),
|
('semesters', '0001_initial'),
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
('courses', '0001_initial'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.3 on 2023-09-25 13:07
|
# Generated by Django 4.2.5 on 2023-10-01 16:37
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue