Skip to content

fix: legacy discussion issues #36433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lms/djangoapps/discussion/django_comment_client/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ def delete_thread(request, course_id, thread_id):
course_key = CourseKey.from_string(course_id)
course = get_course_with_access(request.user, 'load', course_key)
thread = cc.Thread.find(thread_id)
thread.delete()
thread.delete(course_id=course_id)
thread_deleted.send(sender=None, user=request.user, post=thread)

track_thread_deleted_event(request, course, thread)
Expand Down Expand Up @@ -781,7 +781,7 @@ def openclose_thread(request, course_id, thread_id):
thread = cc.Thread.find(thread_id)
close_thread = request.POST.get('closed', 'false').lower() == 'true'
thread.closed = close_thread
thread.save()
thread.save(params={"course_id": course_id})

track_thread_lock_unlock_event(request, course, thread, None, close_thread)
return JsonResponse({
Expand Down Expand Up @@ -976,7 +976,7 @@ def pin_thread(request, course_id, thread_id):
course_key = CourseKey.from_string(course_id)
user = cc.User.from_django_user(request.user)
thread = cc.Thread.find(thread_id)
thread.pin(user, thread_id)
thread.pin(user, thread_id, course_id)

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

Expand All @@ -992,7 +992,7 @@ def un_pin_thread(request, course_id, thread_id):
course_key = CourseKey.from_string(course_id)
user = cc.User.from_django_user(request.user)
thread = cc.Thread.find(thread_id)
thread.un_pin(user, thread_id)
thread.un_pin(user, thread_id, course_id)

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

Expand Down Expand Up @@ -1021,7 +1021,7 @@ def follow_commentable(request, course_id, commentable_id): # lint-amnesty, pyl
"""
user = cc.User.from_django_user(request.user)
commentable = cc.Commentable.find(commentable_id)
user.follow(commentable)
user.follow(commentable, course_id=course_id)
return JsonResponse({})


Expand Down Expand Up @@ -1053,7 +1053,7 @@ def unfollow_commentable(request, course_id, commentable_id): # lint-amnesty, p
"""
user = cc.User.from_django_user(request.user)
commentable = cc.Commentable.find(commentable_id)
user.unfollow(commentable)
user.unfollow(commentable, course_id=course_id)
return JsonResponse({})


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def unFlagAbuse(self, user, voteable, removeAll, course_id=None):
url = _url_for_unflag_abuse_thread(voteable.id)
else:
raise utils.CommentClientRequestError("Can only flag/unflag for threads or comments")
course_key = utils.get_course_key(self.attributes.get("course_id"))
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
if is_forum_v2_enabled(course_key):
response = forum_api.update_thread_flag(
thread_id=voteable.id,
Expand All @@ -246,8 +246,8 @@ def unFlagAbuse(self, user, voteable, removeAll, course_id=None):
)
voteable._update_from_response(response)

def pin(self, user, thread_id):
course_key = utils.get_course_key(self.attributes.get("course_id"))
def pin(self, user, thread_id, course_id=None):
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
if is_forum_v2_enabled(course_key):
response = forum_api.pin_thread(
user_id=user.id,
Expand All @@ -266,8 +266,8 @@ def pin(self, user, thread_id):
)
self._update_from_response(response)

def un_pin(self, user, thread_id):
course_key = utils.get_course_key(self.attributes.get("course_id"))
def un_pin(self, user, thread_id, course_id):
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
if is_forum_v2_enabled(course_key):
response = forum_api.unpin_thread(
user_id=user.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def unvote(self, voteable, course_id=None):
url = _url_for_vote_comment(voteable.id)
else:
raise utils.CommentClientRequestError("Can only vote / unvote for threads or comments")
course_key = utils.get_course_key(self.attributes.get("course_id"))
course_key = utils.get_course_key(self.attributes.get("course_id") or course_id)
if is_forum_v2_enabled(course_key):
if voteable.type == 'thread':
response = forum_api.delete_thread_vote(
Expand Down
Loading