Removed duplicate codeblock in views and return error if Student Status is active in StudyGroupListNearView

This commit is contained in:
Keannu Bernasol 2023-09-24 21:17:25 +08:00
parent 05d12073d4
commit 3124c3b6be

View file

@ -21,11 +21,6 @@ class StudyGroupListView(generics.ListAPIView):
def get_queryset(self): def get_queryset(self):
user = self.request.user user = self.request.user
if not user.is_student:
raise PermissionDenied(
"You must be a student to view study groups"
)
if not user.is_student: if not user.is_student:
raise PermissionDenied( raise PermissionDenied(
"You must be a student to view study groups" "You must be a student to view study groups"
@ -57,7 +52,7 @@ class StudyGroupListView(generics.ListAPIView):
group_radius = max(group_radius, 15) group_radius = max(group_radius, 15)
# Annotate the group with the radius # Annotate the group with the radius
group.radius = group_radius group.radius = group_radius
print('test', studygroups)
return studygroups return studygroups
@ -72,9 +67,6 @@ class StudyGroupListNearView(generics.ListAPIView):
user_location = fromstr( user_location = fromstr(
user_status.location, srid=4326) user_status.location, srid=4326)
if user_status.active is False:
raise exceptions.ValidationError("Student Status is not active")
if not user.is_student: if not user.is_student:
raise PermissionDenied( raise PermissionDenied(
"You must be a student to view study groups" "You must be a student to view study groups"