diff --git a/stude/accounts/migrations/0001_initial.py b/stude/accounts/migrations/0001_initial.py index 1c5b101..8f91475 100644 --- a/stude/accounts/migrations/0001_initial.py +++ b/stude/accounts/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 import accounts.models import django.contrib.auth.models @@ -25,10 +25,10 @@ class Migration(migrations.Migration): ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), - ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('first_name', models.CharField(max_length=100)), ('last_name', models.CharField(max_length=100)), + ('is_active', models.BooleanField(default=False)), ('is_student', models.BooleanField(default=True)), ('is_studying', models.BooleanField(default=False)), ('is_banned', models.BooleanField(default=False)), diff --git a/stude/accounts/migrations/0002_initial.py b/stude/accounts/migrations/0002_initial.py index 8e150eb..e6a7875 100644 --- a/stude/accounts/migrations/0002_initial.py +++ b/stude/accounts/migrations/0002_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.db import migrations, models import django.db.models.deletion @@ -9,18 +9,19 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('auth', '0012_alter_user_first_name_max_length'), - ('year_levels', '0001_initial'), - ('accounts', '0001_initial'), ('courses', '0002_initial'), + ('accounts', '0001_initial'), ('semesters', '0001_initial'), + ('year_levels', '0001_initial'), + ('auth', '0012_alter_user_first_name_max_length'), + ('subjects', '0001_initial'), ] operations = [ migrations.AddField( model_name='customuser', name='course', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='courses.course'), + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='courses.course'), ), migrations.AddField( model_name='customuser', @@ -30,7 +31,12 @@ class Migration(migrations.Migration): migrations.AddField( model_name='customuser', name='semester', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='semesters.semester'), + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='semesters.semester'), + ), + migrations.AddField( + model_name='customuser', + name='subjects', + field=models.ManyToManyField(related_name='SubjectStudent_user', through='subjects.SubjectStudent', to='subjects.subject'), ), migrations.AddField( model_name='customuser', @@ -40,6 +46,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='customuser', name='year_level', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='year_levels.year_level'), + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='year_levels.year_level'), ), ] diff --git a/stude/accounts/migrations/0003_customuser_subjects.py b/stude/accounts/migrations/0003_customuser_subjects.py deleted file mode 100644 index 37f2fd5..0000000 --- a/stude/accounts/migrations/0003_customuser_subjects.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-28 03:09 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('subjects', '0002_subjectstudent_subject_students'), - ('accounts', '0002_initial'), - ] - - operations = [ - migrations.AddField( - model_name='customuser', - name='subjects', - field=models.ManyToManyField(related_name='SubjectStudent_user', through='subjects.SubjectStudent', to='subjects.subject'), - ), - ] diff --git a/stude/accounts/migrations/0004_alter_customuser_course_alter_customuser_semester_and_more.py b/stude/accounts/migrations/0004_alter_customuser_course_alter_customuser_semester_and_more.py deleted file mode 100644 index 0527dd0..0000000 --- a/stude/accounts/migrations/0004_alter_customuser_course_alter_customuser_semester_and_more.py +++ /dev/null @@ -1,32 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-04 10:04 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('semesters', '0001_initial'), - ('courses', '0002_initial'), - ('year_levels', '0001_initial'), - ('accounts', '0003_customuser_subjects'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='course', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='courses.course'), - ), - migrations.AlterField( - model_name='customuser', - name='semester', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='semesters.semester'), - ), - migrations.AlterField( - model_name='customuser', - name='year_level', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='year_levels.year_level'), - ), - ] diff --git a/stude/accounts/migrations/0005_alter_customuser_is_active.py b/stude/accounts/migrations/0005_alter_customuser_is_active.py deleted file mode 100644 index f6ebd78..0000000 --- a/stude/accounts/migrations/0005_alter_customuser_is_active.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-04 11:33 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('accounts', '0004_alter_customuser_course_alter_customuser_semester_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='customuser', - name='is_active', - field=models.BooleanField(default=False), - ), - ] diff --git a/stude/accounts/serializers.py b/stude/accounts/serializers.py index 90f3b54..7665158 100644 --- a/stude/accounts/serializers.py +++ b/stude/accounts/serializers.py @@ -11,6 +11,7 @@ from django.contrib.auth.password_validation import validate_password from courses.models import Course from year_levels.models import Year_Level from semesters.models import Semester +from django.contrib.gis.geos import Point class CustomUserSerializer(BaseUserSerializer): @@ -35,7 +36,8 @@ class CustomUserSerializer(BaseUserSerializer): class UserRegistrationSerializer(serializers.ModelSerializer): email = serializers.EmailField(required=True) student_id_number = serializers.CharField(required=True) - password = serializers.CharField(write_only=True) + password = serializers.CharField( + write_only=True, style={'input_type': 'password', 'placeholder': 'Password'}) class Meta: model = CustomUser # Use your custom user model here @@ -64,8 +66,7 @@ class UserRegistrationSerializer(serializers.ModelSerializer): StudentStatus.objects.create( user=user, active=False, - x=None, - y=None, + 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 2530e9b..970281d 100644 --- a/stude/courses/migrations/0001_initial.py +++ b/stude/courses/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.db import migrations, models import django.db.models.deletion diff --git a/stude/courses/migrations/0002_initial.py b/stude/courses/migrations/0002_initial.py index 5f3e96f..cb6eb76 100644 --- a/stude/courses/migrations/0002_initial.py +++ b/stude/courses/migrations/0002_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.db import migrations, models import django.db.models.deletion @@ -9,8 +9,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('subjects', '0001_initial'), ('courses', '0001_initial'), + ('subjects', '0001_initial'), ] operations = [ diff --git a/stude/semesters/migrations/0001_initial.py b/stude/semesters/migrations/0001_initial.py index e890336..e4928e7 100644 --- a/stude/semesters/migrations/0001_initial.py +++ b/stude/semesters/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 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 cf457c7..80b2aa9 100644 --- a/stude/student_status/migrations/0001_initial.py +++ b/stude/student_status/migrations/0001_initial.py @@ -1,6 +1,7 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.conf import settings +import django.contrib.gis.db.models.fields from django.db import migrations, models import django.db.models.deletion @@ -18,8 +19,7 @@ class Migration(migrations.Migration): name='StudentStatus', fields=[ ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), - ('x', models.FloatField(null=True)), - ('y', models.FloatField(null=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)), ], diff --git a/stude/student_status/migrations/0002_initial.py b/stude/student_status/migrations/0002_initial.py index 801da19..68f3c08 100644 --- a/stude/student_status/migrations/0002_initial.py +++ b/stude/student_status/migrations/0002_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.db import migrations, models import django.db.models.deletion @@ -10,19 +10,19 @@ class Migration(migrations.Migration): dependencies = [ ('student_status', '0001_initial'), - ('subjects', '0001_initial'), ('study_groups', '0001_initial'), + ('subjects', '0001_initial'), ] operations = [ migrations.AddField( model_name='studentstatus', name='study_group', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='study_groups.studygroup'), + field=models.ManyToManyField(blank=True, through='study_groups.StudyGroupMembership', to='study_groups.studygroup'), ), migrations.AddField( model_name='studentstatus', name='subject', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='subjects.subject'), + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='subjects.subject'), ), ] diff --git a/stude/student_status/migrations/0003_remove_studentstatus_study_group_and_more.py b/stude/student_status/migrations/0003_remove_studentstatus_study_group_and_more.py deleted file mode 100644 index 43495cc..0000000 --- a/stude/student_status/migrations/0003_remove_studentstatus_study_group_and_more.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:53 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('study_groups', '0001_initial'), - ('student_status', '0002_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='studentstatus', - name='study_group', - ), - migrations.AddField( - model_name='studentstatus', - name='study_group', - field=models.ManyToManyField(blank=True, null=True, through='study_groups.StudyGroupMembership', to='study_groups.studygroup'), - ), - ] diff --git a/stude/student_status/migrations/0004_alter_studentstatus_study_group.py b/stude/student_status/migrations/0004_alter_studentstatus_study_group.py deleted file mode 100644 index bca9509..0000000 --- a/stude/student_status/migrations/0004_alter_studentstatus_study_group.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-27 17:15 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('study_groups', '0001_initial'), - ('student_status', '0003_remove_studentstatus_study_group_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='studentstatus', - name='study_group', - field=models.ManyToManyField(blank=True, through='study_groups.StudyGroupMembership', to='study_groups.studygroup'), - ), - ] diff --git a/stude/student_status/migrations/0005_alter_studentstatus_subject.py b/stude/student_status/migrations/0005_alter_studentstatus_subject.py deleted file mode 100644 index 845a322..0000000 --- a/stude/student_status/migrations/0005_alter_studentstatus_subject.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 4.2.2 on 2023-07-04 10:01 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('subjects', '0002_subjectstudent_subject_students'), - ('student_status', '0004_alter_studentstatus_study_group'), - ] - - operations = [ - migrations.AlterField( - model_name='studentstatus', - name='subject', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='subjects.subject'), - ), - ] diff --git a/stude/student_status/models.py b/stude/student_status/models.py index 2787206..3a3c4dc 100644 --- a/stude/student_status/models.py +++ b/stude/student_status/models.py @@ -1,15 +1,15 @@ from django.db import models from accounts.models import CustomUser from study_groups.models import StudyGroup - +from django.contrib.gis.db import models as gis_models +from django.contrib.gis.geos import Point # Create your models here. class StudentStatus(models.Model): user = models.OneToOneField( CustomUser, on_delete=models.CASCADE, primary_key=True) - x = models.FloatField(null=True) - y = models.FloatField(null=True) + location = gis_models.PointField(blank=True, null=True) subject = models.ForeignKey( 'subjects.Subject', on_delete=models.SET_NULL, null=True) active = models.BooleanField(default=False) diff --git a/stude/student_status/serializers.py b/stude/student_status/serializers.py index 4531a88..ea3aa81 100644 --- a/stude/student_status/serializers.py +++ b/stude/student_status/serializers.py @@ -1,12 +1,12 @@ from rest_framework import serializers from .models import StudentStatus +from subjects.models import Subject +from django.contrib.gis.geos import Point class StudentStatusSerializer(serializers.ModelSerializer): - year_level = serializers.CharField( - source='user.year_level', read_only=True) - course = serializers.CharField(source='user.course', read_only=True) - semester = serializers.CharField(source='user.semester', read_only=True) + subject = serializers.SlugRelatedField( + queryset=Subject.objects.all(), slug_field='name', required=True) user = serializers.CharField(source='user.full_name', read_only=True) class Meta: @@ -24,8 +24,7 @@ class StudentStatusSerializer(serializers.ModelSerializer): active = validated_data.get('active', None) if active is not None and active is False: - validated_data['x'] = None - validated_data['y'] = None + validated_data['location'] = Point(0, 0) validated_data['subject'] = None return super().update(instance, validated_data) diff --git a/stude/study_groups/migrations/0001_initial.py b/stude/study_groups/migrations/0001_initial.py index 6c2f8df..f3ff07d 100644 --- a/stude/study_groups/migrations/0001_initial.py +++ b/stude/study_groups/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 +import django.contrib.gis.db.models.fields from django.db import migrations, models import django.db.models.deletion @@ -19,8 +20,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=48)), - ('x', models.FloatField(null=True)), - ('y', models.FloatField(null=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)), ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='subjects.subject')), diff --git a/stude/study_groups/models.py b/stude/study_groups/models.py index e6647c9..bdfc236 100644 --- a/stude/study_groups/models.py +++ b/stude/study_groups/models.py @@ -1,5 +1,7 @@ from django.db import models from subjects.models import Subject +from django.contrib.gis.db import models as gis_models +from django.contrib.gis.geos import Point # Create your models here. @@ -7,8 +9,7 @@ class StudyGroup(models.Model): name = models.CharField(max_length=48) users = models.ManyToManyField( 'student_status.StudentStatus', through='StudyGroupMembership') - x = models.FloatField(null=True) - y = models.FloatField(null=True) + location = gis_models.PointField(blank=True, null=True) subject = models.ForeignKey(Subject, on_delete=models.CASCADE) active = models.BooleanField(default=False) timestamp = models.DateField(auto_now_add=True) diff --git a/stude/studygroup_messages/migrations/0001_initial.py b/stude/studygroup_messages/migrations/0001_initial.py index f6cdecc..b793e23 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.2 on 2023-06-27 15:24 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.conf import settings from django.db import migrations, models @@ -20,7 +20,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('message_content', models.TextField(max_length=1024)), - ('timestamp', models.DateField(auto_now_add=True)), + ('timestamp', models.DateTimeField(auto_now_add=True)), ('study_group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='study_groups.studygroup')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], diff --git a/stude/studygroup_messages/migrations/0002_alter_message_timestamp.py b/stude/studygroup_messages/migrations/0002_alter_message_timestamp.py deleted file mode 100644 index 55d8981..0000000 --- a/stude/studygroup_messages/migrations/0002_alter_message_timestamp.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-27 17:15 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('studygroup_messages', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='message', - name='timestamp', - field=models.DateTimeField(auto_now_add=True), - ), - ] diff --git a/stude/subjects/migrations/0001_initial.py b/stude/subjects/migrations/0001_initial.py index ec2350e..1db88fd 100644 --- a/stude/subjects/migrations/0001_initial.py +++ b/stude/subjects/migrations/0001_initial.py @@ -1,5 +1,6 @@ -# Generated by Django 4.2.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 +from django.conf import settings from django.db import migrations, models import django.db.models.deletion @@ -9,9 +10,10 @@ class Migration(migrations.Migration): initial = True dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('semesters', '0001_initial'), - ('year_levels', '0001_initial'), ('courses', '0001_initial'), + ('year_levels', '0001_initial'), ] operations = [ @@ -23,7 +25,24 @@ class Migration(migrations.Migration): ('code', models.CharField(max_length=16)), ('courses', models.ManyToManyField(related_name='SubjectCourse_subject', through='courses.SubjectCourse', to='courses.course')), ('semester', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='semesters.semester')), - ('year_level', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='Year_Level_name', to='year_levels.year_level')), ], ), + migrations.CreateModel( + name='SubjectStudent', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='subjects.subject')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.AddField( + model_name='subject', + name='students', + field=models.ManyToManyField(related_name='SubjectStudent_subject', through='subjects.SubjectStudent', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='subject', + name='year_level', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='Year_Level_name', to='year_levels.year_level'), + ), ] diff --git a/stude/subjects/migrations/0002_subjectstudent_subject_students.py b/stude/subjects/migrations/0002_subjectstudent_subject_students.py deleted file mode 100644 index e83702f..0000000 --- a/stude/subjects/migrations/0002_subjectstudent_subject_students.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 4.2.2 on 2023-06-28 03:09 - -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), - ('subjects', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='SubjectStudent', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='subjects.subject')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.AddField( - model_name='subject', - name='students', - field=models.ManyToManyField(related_name='SubjectStudent_subject', through='subjects.SubjectStudent', to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/stude/year_levels/migrations/0001_initial.py b/stude/year_levels/migrations/0001_initial.py index 8859f76..6e58573 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.2 on 2023-06-27 15:21 +# Generated by Django 4.2.3 on 2023-07-09 10:57 from django.db import migrations, models