diff --git a/backend/courses/serializers.py b/backend/courses/serializers.py
index f99db603..93c1ac3b 100644
--- a/backend/courses/serializers.py
+++ b/backend/courses/serializers.py
@@ -484,6 +484,7 @@ class CommentSerializer(serializers.ModelSerializer):
section = serializers.CharField(source="section.full_code", read_only=True)
base = serializers.SerializerMethodField()
parent = serializers.SerializerMethodField()
+ semester = serializers.CharField(source="section.course.semester", read_only=True)
def get_votes(self, obj):
return len(obj.upvotes.values_list("id")) - len(obj.downvotes.values_list("id"))
@@ -511,6 +512,7 @@ class Meta:
"base",
"parent",
"path",
+ "semester"
]
@@ -522,6 +524,7 @@ class CommentListSerializer(serializers.ModelSerializer):
parent = serializers.SerializerMethodField()
user_upvoted = serializers.BooleanField()
user_downvoted = serializers.BooleanField()
+ semester = serializers.CharField(source="section.course.semester", read_only=True)
def get_votes(self, obj):
return len(obj.upvotes.values_list("id")) - len(obj.downvotes.values_list("id"))
@@ -551,4 +554,5 @@ class Meta:
"path",
"user_upvoted",
"user_downvoted",
+ "semester",
]
diff --git a/backend/review/views.py b/backend/review/views.py
index 85d2bc8c..a1bd01a6 100644
--- a/backend/review/views.py
+++ b/backend/review/views.py
@@ -872,17 +872,20 @@ class CommentList(generics.ListAPIView):
def get(self, request, semester, course_code):
print("HELLO")
- semester_arg = request.query_params.get("semester") or "all"
+ print(semester)
+ # semester_arg = request.query_params.get("semester") or "all"
+ semester_arg = semester or "all"
instructor = request.query_params.get("instructor") or "all"
- sort_by = request.query_params.get("sort_by") or "oldest"
+ sort_by = request.query_params.get("sort_by") or "newest"
page = request.query_params.get("page") or 0
- page_size = request.query_params.get("page_size") or 10
+ page_size = request.query_params.get("page_size") or 20
queryset = og_queryset = self.get_queryset()
+ print(queryset)
# add filters
if semester_arg != "all":
- queryset = queryset.all().filter(semester=semester_arg)
+ queryset = queryset.all().filter(section__course__semester=semester_arg)
if instructor != "all":
queryset = queryset.all().filter(instructor=instructor)
@@ -923,11 +926,14 @@ def get(self, request, semester, course_code):
def get_queryset(self):
course_code = self.kwargs["course_code"]
semester = self.kwargs["semester"] or "all"
+ print("I MADE IT HERE", semester)
try:
if semester == "all":
course = Course.objects.filter(full_code=course_code).latest("semester")
else:
+ print("HI1")
course = get_course_from_code_semester(course_code, None)
+ print("HI2")
except Http404:
return Response({"message": "Course not found."}, status=status.HTTP_404_NOT_FOUND)
topic = course.topic
diff --git a/frontend/review/src/components/DetailsBox.js b/frontend/review/src/components/DetailsBox.js
index f4ec860b..8d83f3d2 100644
--- a/frontend/review/src/components/DetailsBox.js
+++ b/frontend/review/src/components/DetailsBox.js
@@ -127,9 +127,9 @@ const CommentsTab = forwardRef(
useEffect(() => {
setIsLoading(true);
- apiComments(course, "2022A", null, null)
+ apiComments(course, "all", null, null)
.then(res => {
- console.log("fetching comments", res);
+ console.log("fetching comments now", res);
setComments(res.comments.map(c => ({ ...c, created_at: new Date(c.created_at), modified_at: new Date(c.modified_at) })));
setSemesterList(res.semesters);
})
@@ -231,7 +231,14 @@ const CommentsTab = forwardRef(