From 032ed36af6632dc0cc8cfba781b9818edc7e7982 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Thu, 28 Sep 2023 20:09:24 +0800 Subject: [PATCH] Fixed incorrect users field in study group viewset --- stude/schema.yml | 25 ++----------------------- stude/study_groups/views.py | 5 +++-- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/stude/schema.yml b/stude/schema.yml index c8aaa04..c697ef8 100644 --- a/stude/schema.yml +++ b/stude/schema.yml @@ -763,7 +763,7 @@ paths: items: $ref: '#/components/schemas/StudyGroup' description: '' - /api/v1/study_groups/create//: + /api/v1/study_groups/create/: post: operationId: api_v1_study_groups_create_create tags: @@ -789,7 +789,7 @@ paths: schema: $ref: '#/components/schemas/StudyGroupCreate' description: '' - /api/v1/study_groups/create//{id}/: + /api/v1/study_groups/create/{id}/: patch: operationId: api_v1_study_groups_create_partial_update parameters: @@ -1174,13 +1174,6 @@ components: readOnly: true name: type: string - students: - type: array - items: - type: string - description: Required. 150 characters or fewer. Letters, digits and @/./+/-/_ - only. - nullable: true subject: type: string location: @@ -1188,8 +1181,6 @@ components: landmark: type: string nullable: true - active: - type: boolean timestamp: type: string format: date @@ -1322,8 +1313,6 @@ components: radius: type: number format: double - active: - type: boolean timestamp: type: string format: date @@ -1344,13 +1333,6 @@ components: readOnly: true name: type: string - students: - type: array - items: - type: string - description: Required. 150 characters or fewer. Letters, digits and @/./+/-/_ - only. - nullable: true subject: type: string location: @@ -1358,8 +1340,6 @@ components: landmark: type: string nullable: true - active: - type: boolean timestamp: type: string format: date @@ -1368,7 +1348,6 @@ components: - id - location - name - - students - subject - timestamp SubjectInstance: diff --git a/stude/study_groups/views.py b/stude/study_groups/views.py index 2388fec..551f1c6 100644 --- a/stude/study_groups/views.py +++ b/stude/study_groups/views.py @@ -50,10 +50,11 @@ class StudyGroupListView(generics.ListAPIView): for group in studygroups: # Get all StudentStatus locations of the group - group_locations = group.users.values_list('location', flat=True) + group_locations = group.students.values_list('location', flat=True) # Convert string locations to GEOSGeometry objects point_locations = [fromstr(loc, srid=4326) for loc in group_locations] + # Calculate distances between every pair of locations distances = [(loc1.distance( loc2)*100000)for loc1 in point_locations for loc2 in point_locations] @@ -99,7 +100,7 @@ class StudyGroupListNearView(generics.ListAPIView): for group in studygroups: # Get all StudentStatus locations of the group - group_locations = group.users.values_list('location', flat=True) + group_locations = group.students.values_list('location', flat=True) # Convert string locations to GEOSGeometry objects point_locations = [fromstr(loc, srid=4326) for loc in group_locations]