Skip to content

Commit

Permalink
Merge branch 'api-working' of github.com:SELab-2/UGent-1 into api-wor…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
ReinhardDP committed Mar 13, 2024
2 parents 3580f9f + 5a2e0a4 commit ff1e0bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
14 changes: 14 additions & 0 deletions backend/pigeonhole/apps/groups/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,18 @@ def get_other_group(self):
del data['final_score']
if 'feedback' in data:
del data['feedback']
return data

def to_representation(self, instance):
data = super().to_representation(instance)
request = self.context.get('request')

# Check if the user is a student and the group is not visible
if request and request.user.is_student and not instance.visible:
# Hide sensitive information for students
if 'final_score' in data:
del data['final_score']
if 'feedback' in data:
del data['feedback']

return data
26 changes: 0 additions & 26 deletions backend/pigeonhole/apps/groups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,3 @@ class GroupViewSet(viewsets.ModelViewSet):
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = [IsAuthenticated and CanAccessGroup]

"""
def list(self, request, *args, **kwargs):
course_id = kwargs.get('course_id')
project_id = kwargs.get('project_id')
# Check whether the course exists
get_object_or_404(Course, course_id=course_id)
# Check whether the project exists
project = get_object_or_404(Project, project=project_id)
# Ensure the project is associated with the course
if project.course_id != int(course_id):
return Response({'detail': 'Project not found in the specified course.'}, status=status.HTTP_404_NOT_FOUND)
queryset = self.queryset.filter(project_id=project_id)
serializer = self.get_serializer(queryset, many=True)
if request.user.is_student:
for group in serializer.data:
if request.user.id not in group["users"]:
del group["final_score"]
del group["feedback"]
return Response(serializer.data, status=status.HTTP_200_OK)
"""

0 comments on commit ff1e0bd

Please sign in to comment.