mirror of
https://github.com/AmanTahiliani/PeerNotes.git
synced 2026-08-07 11:55:12 -04:00
Removed extra code
This commit is contained in:
@@ -312,65 +312,3 @@ class FileFilterView(APIView):
|
|||||||
{"error": f"Something went wrong: {str(e)}"},
|
{"error": f"Something went wrong: {str(e)}"},
|
||||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# class FileFilterView(APIView):
|
|
||||||
# authentication_classes = [TokenAuthentication]
|
|
||||||
# permission_classes = [IsAuthenticated]
|
|
||||||
# def get(self, request, format=None):
|
|
||||||
# try:
|
|
||||||
# # Extract filters from the query parameters
|
|
||||||
# topic_id = request.query_params.get("topic")
|
|
||||||
# professor_id = request.query_params.get("professor")
|
|
||||||
# course_id = request.query_params.get("course")
|
|
||||||
# semester_id = request.query_params.get("semester")
|
|
||||||
|
|
||||||
# # Check if provided filter IDs exist
|
|
||||||
# if topic_id and not Topic.objects.filter(id=topic_id).exists():
|
|
||||||
# return Response(
|
|
||||||
# {"error": f"Topic with id {topic_id} does not exist"},
|
|
||||||
# status=status.HTTP_400_BAD_REQUEST,
|
|
||||||
# )
|
|
||||||
# if professor_id and not Professor.objects.filter(id=professor_id).exists():
|
|
||||||
# return Response(
|
|
||||||
# {"error": f"Professor with id {professor_id} does not exist"},
|
|
||||||
# status=status.HTTP_400_BAD_REQUEST,
|
|
||||||
# )
|
|
||||||
# if course_id and not Course.objects.filter(id=course_id).exists():
|
|
||||||
# return Response(
|
|
||||||
# {"error": f"Course with id {course_id} does not exist"},
|
|
||||||
# status=status.HTTP_400_BAD_REQUEST,
|
|
||||||
# )
|
|
||||||
# if semester_id and not Semester.objects.filter(id=semester_id).exists():
|
|
||||||
# return Response(
|
|
||||||
# {"error": f"Semester with id {semester_id} does not exist"},
|
|
||||||
# status=status.HTTP_400_BAD_REQUEST,
|
|
||||||
# )
|
|
||||||
|
|
||||||
# # Start with the base queryset
|
|
||||||
# queryset = File.objects.all()
|
|
||||||
|
|
||||||
# # Apply filters if they are provided
|
|
||||||
# if topic_id:
|
|
||||||
# queryset = queryset.filter(topic__id=topic_id)
|
|
||||||
# if professor_id:
|
|
||||||
# queryset = queryset.filter(professor__id=professor_id)
|
|
||||||
# if course_id:
|
|
||||||
# queryset = queryset.filter(course__id=course_id)
|
|
||||||
# if semester_id:
|
|
||||||
# queryset = queryset.filter(semester__id=semester_id)
|
|
||||||
|
|
||||||
# # Filter files based on active peers in the past hour
|
|
||||||
# active_peer_ids = PeerUser.objects.filter(
|
|
||||||
# last_poll__gte=timezone.now() - timedelta(hours=1)
|
|
||||||
# ).values_list("id", flat=True)
|
|
||||||
|
|
||||||
# queryset = queryset.filter(peer_users__in=active_peer_ids).distinct()
|
|
||||||
|
|
||||||
# serializer = FileSerializer(queryset, many=True)
|
|
||||||
# return Response(serializer.data)
|
|
||||||
# except Exception as e:
|
|
||||||
# return Response(
|
|
||||||
# {"error": f"Something went wrong: {str(e)}"},
|
|
||||||
# status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
||||||
# )
|
|
||||||
|
|||||||
Reference in New Issue
Block a user