Skip to content

Commit

Permalink
new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shiva-menta committed Apr 26, 2024
1 parent a79c980 commit a709f75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions backend/review/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ class CommentList(generics.ListAPIView):
http_method_names = ["get"]
permission_classes = [IsAuthenticated]

def get(self, semester_arg, request, course_code):
semester = request.query_params.get("semester") or "all"
def get(self, request, semester, course_code):
semester_arg = request.query_params.get("semester") or "all"
instructor = request.query_params.get("instructor") or "all"
sort_by = request.query_params.get("sort_by") or "oldest"
page = request.query_params.get("page") or 0
Expand All @@ -871,8 +871,8 @@ def get(self, semester_arg, request, course_code):
queryset = self.get_queryset()

# add filters
if semester != "all":
queryset = queryset.all().filter(semester=semester)
if semester_arg != "all":
queryset = queryset.all().filter(semester=semester_arg)
if instructor != "all":
queryset = queryset.all().filter(instructor=instructor)

Expand Down
5 changes: 4 additions & 1 deletion backend/tests/courses/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,9 @@ def get_comments(self, semester, code, ordering):
base_url = reverse("course-comments", kwargs={"semester": semester, "course_code": code})
query_params = {"ordering":ordering}
encoded_params = urlencode(query_params)
self.client.force_login(self.user1)
response = self.client.get(f"{base_url}?{encoded_params}")
self.client.logout()
return response.data

def create_comment(self, username, instructor, code, semester, parent_id):
Expand All @@ -1380,6 +1382,7 @@ def create_comment(self, username, instructor, code, semester, parent_id):

response = self.client.post(reverse("comment"), data, format="json")
self.client.logout()
print(response.data)
return response.data["id"]

def edit_comment(self, username, text, comment_id):
Expand Down Expand Up @@ -1424,7 +1427,7 @@ def downvote(self, username, comment_id):
self.client.logout()

def test_comment_count(self):
self.assertEqual(len(self.get_comments("all", self._COURSE_CODE, "newest")), 3)
self.assertEqual(len(self.get_comments("all", self._COURSE_CODE, "newest")), 4)

# def test_time_ordering_new(self):
# comments = self.get_comments(self._COURSE_CODE, "all", self._COURSE_CODE, "newest")
Expand Down

0 comments on commit a709f75

Please sign in to comment.