mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2025-06-28 16:25:44 +08:00
Initial fix for duplicate subject queries in student status
This commit is contained in:
parent
451c5ec00b
commit
6fe1042826
20 changed files with 87 additions and 95 deletions
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.2.3 on 2023-08-06 05:55
|
||||
# Generated by Django 4.2.3 on 2023-09-03 09:32
|
||||
|
||||
from django.conf import settings
|
||||
import django.contrib.gis.db.models.fields
|
||||
|
@ -11,8 +11,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0002_initial'),
|
||||
('landmarks', '0001_initial'),
|
||||
('accounts', '0002_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@ -22,7 +22,7 @@ class Migration(migrations.Migration):
|
|||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
|
||||
('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.DateTimeField(auto_now_add=True)),
|
||||
('landmark', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='landmarks.landmark')),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.2.3 on 2023-08-06 05:55
|
||||
# Generated by Django 4.2.3 on 2023-09-03 09:32
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
# Generated by Django 4.2.3 on 2023-08-15 10:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('student_status', '0002_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='studentstatus',
|
||||
name='timestamp',
|
||||
field=models.DateTimeField(auto_now_add=True),
|
||||
),
|
||||
]
|
|
@ -8,7 +8,7 @@ from landmarks.models import Landmark
|
|||
|
||||
class StudentStatusSerializer(serializers.ModelSerializer):
|
||||
subject = serializers.SlugRelatedField(
|
||||
queryset=Subject.objects.all(), slug_field='name', required=True)
|
||||
queryset=Subject.objects.all(), slug_field='name', required=True, many=False)
|
||||
user = serializers.CharField(source='user.full_name', read_only=True)
|
||||
location = PointField(required=True)
|
||||
landmark = serializers.SlugRelatedField(
|
||||
|
@ -32,8 +32,8 @@ class StudentStatusSerializer(serializers.ModelSerializer):
|
|||
def update(self, instance, validated_data):
|
||||
|
||||
active = validated_data.get('active', None)
|
||||
# subject = validated_data.get('subject', None)
|
||||
|
||||
subject = validated_data.get('subject', None)
|
||||
print('=====', subject, '======')
|
||||
# If status is set as false in the request, clear the student status
|
||||
if active is False:
|
||||
validated_data['location'] = Point(0, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue