diff --git a/stude/accounts/migrations/0001_initial.py b/stude/accounts/migrations/0001_initial.py index 147ff44..e82713f 100644 --- a/stude/accounts/migrations/0001_initial.py +++ b/stude/accounts/migrations/0001_initial.py @@ -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 django.contrib.auth.models @@ -13,9 +13,9 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('courses', '0001_initial'), ('semesters', '0001_initial'), ('auth', '0012_alter_user_first_name_max_length'), - ('courses', '0001_initial'), ] operations = [ diff --git a/stude/accounts/migrations/0002_initial.py b/stude/accounts/migrations/0002_initial.py index f52bc7c..ca8cf2b 100644 --- a/stude/accounts/migrations/0002_initial.py +++ b/stude/accounts/migrations/0002_initial.py @@ -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 import django.db.models.deletion @@ -9,9 +9,9 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('accounts', '0001_initial'), ('year_levels', '0001_initial'), ('subjects', '0001_initial'), - ('accounts', '0001_initial'), ('auth', '0012_alter_user_first_name_max_length'), ] diff --git a/stude/accounts/migrations/0003_alter_customuser_options_and_more.py b/stude/accounts/migrations/0003_alter_customuser_options_and_more.py deleted file mode 100644 index 0828deb..0000000 --- a/stude/accounts/migrations/0003_alter_customuser_options_and_more.py +++ /dev/null @@ -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')}, - ), - ] diff --git a/stude/accounts/migrations/0004_alter_customuser_options_and_more.py b/stude/accounts/migrations/0004_alter_customuser_options_and_more.py deleted file mode 100644 index b322b02..0000000 --- a/stude/accounts/migrations/0004_alter_customuser_options_and_more.py +++ /dev/null @@ -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(), - ), - ] diff --git a/stude/accounts/serializers.py b/stude/accounts/serializers.py index 40874fa..d1b8dd1 100644 --- a/stude/accounts/serializers.py +++ b/stude/accounts/serializers.py @@ -155,10 +155,12 @@ class UserRegistrationSerializer(serializers.ModelSerializer): user.set_password(validated_data['password']) user.save() - StudentStatus.objects.create( + StudentStatus.objects.update_or_create( user=user, - active=False, - location=Point(0, 0), - subject=None + defaults={ + 'active': False, + 'location': Point(0, 0), + 'subject': None + } ) return user diff --git a/stude/courses/migrations/0001_initial.py b/stude/courses/migrations/0001_initial.py index b714967..8aed08a 100644 --- a/stude/courses/migrations/0001_initial.py +++ b/stude/courses/migrations/0001_initial.py @@ -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 diff --git a/stude/landmarks/migrations/0001_initial.py b/stude/landmarks/migrations/0001_initial.py index 2abfc17..b348a0f 100644 --- a/stude/landmarks/migrations/0001_initial.py +++ b/stude/landmarks/migrations/0001_initial.py @@ -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 from django.db import migrations, models diff --git a/stude/semesters/migrations/0001_initial.py b/stude/semesters/migrations/0001_initial.py index b016507..96e358c 100644 --- a/stude/semesters/migrations/0001_initial.py +++ b/stude/semesters/migrations/0001_initial.py @@ -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 diff --git a/stude/student_status/migrations/0001_initial.py b/stude/student_status/migrations/0001_initial.py index 52c99ad..80476e4 100644 --- a/stude/student_status/migrations/0001_initial.py +++ b/stude/student_status/migrations/0001_initial.py @@ -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 import django.contrib.gis.db.models.fields @@ -11,23 +11,24 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('accounts', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('study_groups', '0001_initial'), - ('landmarks', '0001_initial'), ('subjects', '0001_initial'), + ('landmarks', '0001_initial'), ] operations = [ migrations.CreateModel( name='StudentStatus', 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)), ('active', models.BooleanField(default=False)), ('timestamp', models.DateTimeField(auto_now_add=True)), ('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')), ('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)), ], ), ] diff --git a/stude/student_status/models.py b/stude/student_status/models.py index e0eb6ed..05bb785 100644 --- a/stude/student_status/models.py +++ b/stude/student_status/models.py @@ -8,7 +8,7 @@ from django.dispatch import receiver class StudentStatus(models.Model): 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) subject = models.ForeignKey( 'subjects.Subject', on_delete=models.SET_NULL, null=True, to_field='name') diff --git a/stude/study_groups/migrations/0001_initial.py b/stude/study_groups/migrations/0001_initial.py index 76e2da3..aa1cc88 100644 --- a/stude/study_groups/migrations/0001_initial.py +++ b/stude/study_groups/migrations/0001_initial.py @@ -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 from django.db import migrations, models @@ -19,9 +19,8 @@ class Migration(migrations.Migration): name='StudyGroup', fields=[ ('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)), - ('active', models.BooleanField(default=False)), ('timestamp', models.DateField(auto_now_add=True)), ('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')), diff --git a/stude/study_groups/migrations/0002_remove_studygroup_active.py b/stude/study_groups/migrations/0002_remove_studygroup_active.py deleted file mode 100644 index 90efc49..0000000 --- a/stude/study_groups/migrations/0002_remove_studygroup_active.py +++ /dev/null @@ -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', - ), - ] diff --git a/stude/study_groups/migrations/0003_alter_studygroup_name.py b/stude/study_groups/migrations/0003_alter_studygroup_name.py deleted file mode 100644 index 0f87ae2..0000000 --- a/stude/study_groups/migrations/0003_alter_studygroup_name.py +++ /dev/null @@ -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), - ), - ] diff --git a/stude/studygroup_messages/migrations/0001_initial.py b/stude/studygroup_messages/migrations/0001_initial.py index 93f5c64..ce05dba 100644 --- a/stude/studygroup_messages/migrations/0001_initial.py +++ b/stude/studygroup_messages/migrations/0001_initial.py @@ -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.db import migrations, models @@ -10,8 +10,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('study_groups', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('study_groups', '0001_initial'), ] operations = [ diff --git a/stude/subjects/migrations/0001_initial.py b/stude/subjects/migrations/0001_initial.py index 7413ef4..9943851 100644 --- a/stude/subjects/migrations/0001_initial.py +++ b/stude/subjects/migrations/0001_initial.py @@ -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.db import migrations, models @@ -10,10 +10,10 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('courses', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('year_levels', '0001_initial'), ('semesters', '0001_initial'), - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('courses', '0001_initial'), ] operations = [ diff --git a/stude/year_levels/migrations/0001_initial.py b/stude/year_levels/migrations/0001_initial.py index 633e1ff..4466c14 100644 --- a/stude/year_levels/migrations/0001_initial.py +++ b/stude/year_levels/migrations/0001_initial.py @@ -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