Skip to content

Commit 8ee931b

Browse files
committed
New
1 parent e678b75 commit 8ee931b

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

backend/courses/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.core.cache import cache
99
from django.core.exceptions import ObjectDoesNotExist, ValidationError
1010
from django.db import connection
11+
from django.db.models import Q
1112
from django.db.models.aggregates import Count
1213
from django.db.models.expressions import Subquery, Value
1314
from django.db.models.functions.comparison import Coalesce
@@ -723,9 +724,9 @@ def get_section_from_course_instructor_semester(course_code, professors, semeste
723724
course__semester=semester
724725
)
725726

726-
professors_query = Q(instructors__username=professors[0])
727+
professors_query = Q(instructors__name=professors[0])
727728
for professor in professors[1:]:
728-
professors_query &= Q(instructors__username=professor)
729+
professors_query &= Q(instructors__name=professor)
729730
matching_sections = sections.filter(professors_query).distinct()
730731

731732
if matching_sections.count() == 1:

backend/review/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ def get_queryset(self):
900900
course = get_course_from_code_semester(course_code, semester)
901901
except Http404:
902902
return Response(
903-
{"message": "Course not found."}, status=status.HTTP_404_BAD_REQUEST
903+
{"message": "Course not found."}, status=status.HTTP_404_NOT_FOUND
904904
)
905905
topic = course.topic
906906
return Comment.objects.filter(section__course__topic=topic)
@@ -995,7 +995,7 @@ def create(self, request):
995995
if Comment.objects.filter(id=request.data.get("id")).exists():
996996
return self.update(request, request.data.get("id"))
997997

998-
if not all(["text", "course_code", "instructor", "semester"], lambda x: x in request.data):
998+
if not all(map(lambda x: x in request.data, ["text", "course_code", "instructor", "semester"])):
999999
return Response(
10001000
{"message": "Insufficient fields provided."}, status=status.HTTP_400_BAD_REQUEST
10011001
)
@@ -1008,8 +1008,9 @@ def create(self, request):
10081008
request.data.get("semester")
10091009
)
10101010
except Exception as e:
1011+
print(e)
10111012
return Response(
1012-
{"message": "Section not found."}, status=status.HTTP_404_BAD_REQUEST
1013+
{"message": "Section not found."}, status=status.HTTP_404_NOT_FOUND
10131014
)
10141015

10151016
# create comment and send response

backend/tests/courses/test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,12 +1342,12 @@ def setUp(self):
13421342
self.section.instructors.add(Instructor.objects.get_or_create(name="default prof")[0])
13431343

13441344
# Create Base Level Comments
1345-
self.id1 = self.create_comment("user1", "default prof", self._COURSE_CODE, TEST_SEMESTER, None)
1346-
self.id2 = self.create_comment("user2", "default prof", self._COURSE_CODE, "2012A", None)
1345+
self.id1 = self.create_comment("user1", ["default prof"], self._COURSE_CODE, TEST_SEMESTER, None)
1346+
self.id2 = self.create_comment("user2", ["default prof"], self._COURSE_CODE, "2012A", None)
13471347

13481348
# Reply to Comment
1349-
self.id3 = self.create_comment("user3", "default prof", self._COURSE_CODE, TEST_SEMESTER, self.id1)
1350-
self.id4 = self.create_comment("user1", "default prof", self._COURSE_CODE, TEST_SEMESTER, self.id1)
1349+
self.id3 = self.create_comment("user3", ["default prof"], self._COURSE_CODE, TEST_SEMESTER, self.id1)
1350+
self.id4 = self.create_comment("user1", ["default prof"], self._COURSE_CODE, TEST_SEMESTER, self.id1)
13511351

13521352
# Add Vote Counts
13531353
self.upvote("user1", self.id2)
@@ -1377,7 +1377,7 @@ def create_comment(self, username, instructor, code, semester, parent_id):
13771377
if parent_id != None:
13781378
data["parent_id"] = parent_id
13791379

1380-
response = self.client.post(reverse("comment"), data)
1380+
response = self.client.post(reverse("comment"), data, format="json")
13811381
self.client.logout()
13821382
print(response.data)
13831383
return response.data["id"]

0 commit comments

Comments
 (0)