diff --git a/backend/courses/util.py b/backend/courses/util.py
index 2b988982..05b295c8 100644
--- a/backend/courses/util.py
+++ b/backend/courses/util.py
@@ -33,6 +33,7 @@
from review.management.commands.mergeinstructors import resolve_duplicates
+
logger = logging.getLogger(__name__)
@@ -740,12 +741,16 @@ def get_section_from_course_instructor_semester(course_code, professors, semeste
sections = Section.objects.prefetch_related("instructors").filter(
course__topic__most_recent__full_code=course_topic_parent, course__semester=semester
)
+ print(sections.first())
+ print(sections[0].instructors)
+ print("HIGH")
professors_query = Q(instructors__name=professors[0])
for professor in professors[1:]:
professors_query &= Q(instructors__name=professor)
matching_sections = sections.filter(professors_query).distinct()
if matching_sections.count() == 1:
return matching_sections.first()
+ return matching_sections.first()
raise ValueError(
f"""No section exists with course code ({course_code}), professor ({professors[0]}),
semester ({semester})"""
diff --git a/backend/review/views.py b/backend/review/views.py
index 201de837..85d2bc8c 100644
--- a/backend/review/views.py
+++ b/backend/review/views.py
@@ -868,9 +868,10 @@ class CommentList(generics.ListAPIView):
)
serializer_class = CommentSerializer
http_method_names = ["get"]
- permission_classes = [IsAuthenticated]
+ # permission_classes = [IsAuthenticated]
def get(self, request, semester, course_code):
+ print("HELLO")
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"
@@ -894,18 +895,22 @@ def get(self, request, semester, course_code):
queryset = queryset.annotate(
base_votes=Count("base__upvotes") - Count("base__downvotes")
).order_by("-base_votes", "base_id", "path")
+ queryset = queryset.annotate(
+ semester=F("section__course__semester"),
+ )
elif sort_by == "oldest":
queryset = queryset.all().order_by("path")
elif sort_by == "newest":
queryset = queryset.all().order_by("-base_id", "path")
-
+ print(queryset)
# apply pagination (not sure how django handles OOB errors)
- user_upvotes = queryset.filter(upvotes=request.user, id=OuterRef("id"))
- user_downvotes = queryset.filter(downvotes=request.user, id=OuterRef("id"))
- queryset = queryset.annotate(
- user_upvoted=Exists(user_upvotes), user_downvoted=Exists(user_downvotes)
- )
- queryset = queryset.all()[page * page_size: (page + 1) * page_size]
+ if queryset:
+ user_upvotes = queryset.filter(upvotes=request.user, id=OuterRef("id"))
+ user_downvotes = queryset.filter(downvotes=request.user, id=OuterRef("id"))
+ queryset = queryset.annotate(
+ user_upvoted=Exists(user_upvotes), user_downvoted=Exists(user_downvotes)
+ )
+ queryset = queryset.all()[page * page_size: (page + 1) * page_size]
response_body = {"comments": CommentListSerializer(queryset, many=True).data}
if semester_arg == "all":
@@ -922,7 +927,7 @@ def get_queryset(self):
if semester == "all":
course = Course.objects.filter(full_code=course_code).latest("semester")
else:
- course = get_course_from_code_semester(course_code, semester)
+ course = get_course_from_code_semester(course_code, None)
except Http404:
return Response({"message": "Course not found."}, status=status.HTTP_404_NOT_FOUND)
topic = course.topic
@@ -993,7 +998,7 @@ class CommentViewSet(viewsets.ModelViewSet):
serializer_class = CommentSerializer
http_method_names = ["get", "post", "delete", "put"]
- permission_classes = [IsAuthenticated]
+ # permission_classes = [IsAuthenticated]
queryset = Comment.objects.all()
def retrieve(self, request, pk=None):
@@ -1019,16 +1024,20 @@ def create(self, request):
request.data.get("instructor"),
request.data.get("semester"),
)
+ print(section)
except Exception as e:
print(e)
+ print("hi")
return Response({"message": "Section not found."}, status=status.HTTP_404_NOT_FOUND)
# create comment and send response
parent_id = request.data.get("parent")
- parent = get_object_or_404(Comment, pk=parent_id) if parent_id is None else None
+ print(parent_id)
+ parent = get_object_or_404(Comment, pk=parent_id) if parent_id is not None else None
comment = Comment.objects.create(
text=request.data.get("text"), author=request.user, section=section, parent=parent
)
+ print("this is a commnet lol")
base = parent.base if parent else comment
prefix = parent.path + "." if parent else ""
path = prefix + "{:0{}d}".format(comment.id, 10)
diff --git a/frontend/review/package.json b/frontend/review/package.json
index ca348bdd..256cfa27 100644
--- a/frontend/review/package.json
+++ b/frontend/review/package.json
@@ -26,7 +26,7 @@
"workerize-loader": "^1.3.0"
},
"scripts": {
- "dev": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
+ "dev": "react-scripts start",
"start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
"build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
"test": "exit 0",
diff --git a/frontend/review/src/components/Comments/Comment.js b/frontend/review/src/components/Comments/Comment.js
index 99c0311a..2b40ace8 100644
--- a/frontend/review/src/components/Comments/Comment.js
+++ b/frontend/review/src/components/Comments/Comment.js
@@ -7,7 +7,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const Comment = forwardRef(({ comment, isReply, isUserComment }, ref) => {
const [showReplies, setShowReplies] = useState(false);
const [replies, setReplies] = useState([]);
- const [seeMore, setSeeMore] = useState(comment.content.length < 150);
+ const [seeMore, setSeeMore] = useState(comment.text.length < 150);
const [liked, setLiked] = useState(false);
const [disliked, setDisliked] = useState(false);
@@ -27,10 +27,10 @@ export const Comment = forwardRef(({ comment, isReply, isUserComment }, ref) =>
{formatDate(comment.modified_at)}
{seeMore ? (
-
{comment.content}
+ {comment.text}
) : (
<>
- {truncateText(comment.content, 150)}
+ {truncateText(comment.text, 150)}