Skip to content

Commit 8a7ca2a

Browse files
Ali-Salman29tonybusa
authored andcommitted
fix: legacy discussion issues (openedx#36433)
Explicitly passed course_id to all views
1 parent ff80bd3 commit 8a7ca2a

File tree

3 files changed

+12
-12
lines changed
  • lms/djangoapps/discussion/django_comment_client/base
  • openedx/core/djangoapps/django_comment_common/comment_client

3 files changed

+12
-12
lines changed

lms/djangoapps/discussion/django_comment_client/base/views.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def delete_thread(request, course_id, thread_id):
715715
course_key = CourseKey.from_string(course_id)
716716
course = get_course_with_access(request.user, 'load', course_key)
717717
thread = cc.Thread.find(thread_id)
718-
thread.delete()
718+
thread.delete(course_id=course_id)
719719
thread_deleted.send(sender=None, user=request.user, post=thread)
720720

721721
track_thread_deleted_event(request, course, thread)
@@ -781,7 +781,7 @@ def openclose_thread(request, course_id, thread_id):
781781
thread = cc.Thread.find(thread_id)
782782
close_thread = request.POST.get('closed', 'false').lower() == 'true'
783783
thread.closed = close_thread
784-
thread.save()
784+
thread.save(params={"course_id": course_id})
785785

786786
track_thread_lock_unlock_event(request, course, thread, None, close_thread)
787787
return JsonResponse({
@@ -976,7 +976,7 @@ def pin_thread(request, course_id, thread_id):
976976
course_key = CourseKey.from_string(course_id)
977977
user = cc.User.from_django_user(request.user)
978978
thread = cc.Thread.find(thread_id)
979-
thread.pin(user, thread_id)
979+
thread.pin(user, thread_id, course_id)
980980

981981
return JsonResponse(prepare_content(thread.to_dict(), course_key))
982982

@@ -992,7 +992,7 @@ def un_pin_thread(request, course_id, thread_id):
992992
course_key = CourseKey.from_string(course_id)
993993
user = cc.User.from_django_user(request.user)
994994
thread = cc.Thread.find(thread_id)
995-
thread.un_pin(user, thread_id)
995+
thread.un_pin(user, thread_id, course_id)
996996

997997
return JsonResponse(prepare_content(thread.to_dict(), course_key))
998998

@@ -1021,7 +1021,7 @@ def follow_commentable(request, course_id, commentable_id): # lint-amnesty, pyl
10211021
"""
10221022
user = cc.User.from_django_user(request.user)
10231023
commentable = cc.Commentable.find(commentable_id)
1024-
user.follow(commentable)
1024+
user.follow(commentable, course_id=course_id)
10251025
return JsonResponse({})
10261026

10271027

@@ -1053,7 +1053,7 @@ def unfollow_commentable(request, course_id, commentable_id): # lint-amnesty, p
10531053
"""
10541054
user = cc.User.from_django_user(request.user)
10551055
commentable = cc.Commentable.find(commentable_id)
1056-
user.unfollow(commentable)
1056+
user.unfollow(commentable, course_id=course_id)
10571057
return JsonResponse({})
10581058

10591059

openedx/core/djangoapps/django_comment_common/comment_client/thread.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def unFlagAbuse(self, user, voteable, removeAll, course_id=None):
222222
url = _url_for_unflag_abuse_thread(voteable.id)
223223
else:
224224
raise utils.CommentClientRequestError("Can only flag/unflag for threads or comments")
225-
course_key = utils.get_course_key(self.attributes.get("course_id"))
225+
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
226226
if is_forum_v2_enabled(course_key):
227227
response = forum_api.update_thread_flag(
228228
thread_id=voteable.id,
@@ -246,8 +246,8 @@ def unFlagAbuse(self, user, voteable, removeAll, course_id=None):
246246
)
247247
voteable._update_from_response(response)
248248

249-
def pin(self, user, thread_id):
250-
course_key = utils.get_course_key(self.attributes.get("course_id"))
249+
def pin(self, user, thread_id, course_id=None):
250+
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
251251
if is_forum_v2_enabled(course_key):
252252
response = forum_api.pin_thread(
253253
user_id=user.id,
@@ -266,8 +266,8 @@ def pin(self, user, thread_id):
266266
)
267267
self._update_from_response(response)
268268

269-
def un_pin(self, user, thread_id):
270-
course_key = utils.get_course_key(self.attributes.get("course_id"))
269+
def un_pin(self, user, thread_id, course_id):
270+
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
271271
if is_forum_v2_enabled(course_key):
272272
response = forum_api.unpin_thread(
273273
user_id=user.id,

openedx/core/djangoapps/django_comment_common/comment_client/user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def unvote(self, voteable, course_id=None):
127127
url = _url_for_vote_comment(voteable.id)
128128
else:
129129
raise utils.CommentClientRequestError("Can only vote / unvote for threads or comments")
130-
course_key = utils.get_course_key(self.attributes.get("course_id"))
130+
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
131131
if is_forum_v2_enabled(course_key):
132132
if voteable.type == 'thread':
133133
response = forum_api.delete_thread_vote(

0 commit comments

Comments
 (0)