Skip to content

Fix/forum patches sumac #36606

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
2 changes: 1 addition & 1 deletion .github/workflows/check-consistent-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defaults:
jobs:
check-requirements:
name: Compile requirements
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
# Only run remaining steps if there are changes to requirements/**
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
python-version:
- "3.11"
os: ["ubuntu-22.04"]
os: ["ubuntu-24.04"]

steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Setup npm
run: npm i -g [email protected]
Expand Down Expand Up @@ -63,7 +64,9 @@ jobs:
run: |
make base-requirements

- uses: c-hive/gha-npm-cache@v1
- name: Install npm
run: npm ci

- name: Run JS Tests
env:
TEST_SUITE: js-unit
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/migrations-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
python-version:
- "3.11"
# 'pinned' is used to install the latest patch version of Django
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
if: always()
needs:
- check_migrations
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Decide whether the needed jobs succeeded or failed
# uses: re-actors/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pylint-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
run-pylint:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
if: always()
needs:
- run-pylint
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Decide whether the needed jobs succeeded or failed
# uses: re-actors/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
python-version:
- "3.11"
node-version: [20]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-assets-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
python-version:
- "3.11"
node-version: [18, 20]
Expand Down
62 changes: 29 additions & 33 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
jobs:
run-tests:
name: ${{ matrix.shard_name }}(py=${{ matrix.python-version }},dj=${{ matrix.django-version }},mongo=${{ matrix.mongo-version }})
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os-version }}
strategy:
matrix:
python-version:
Expand Down Expand Up @@ -43,22 +43,27 @@ jobs:
- "xmodule-with-cms"
mongo-version:
- "7.0"
os-version:
- ubuntu-24.04

# We only need to test older versions of Mongo with modules that directly interface with Mongo (that is: xmodule.modulestore)
# This code is left here as an example for future refernce in case we need to reduce the number of shards we're
# testing but still have good confidence with older versions of mongo. We use Mongo 4.4 in the example.
# It's useful to run some subset of the tests on the older version of Ubuntu
# so that we don't spend too many resources on this but can find major issues quickly
# while we're in a situation where we support two versions. This section may be commented
# out when not in use to easily add/drop future support for any given major dependency.
#
# exclude:
# - mongo-version: "4.4"
# include:
# - shard_name: "xmodule-with-cms"
# python-version: "3.11"
# django-version: "pinned"
# mongo-version: "4.4"
# - shard_name: "xmodule-with-lms"
# python-version: "3.11"
# django-version: "pinned"
# mongo-version: "4.4"
# We're testing the older version of Ubuntu and running the xmodule tests since those rely on many
# dependent complex libraries and will hopefully catch most issues quickly.
include:
- shard_name: "xmodule-with-cms"
python-version: "3.11"
django-version: "pinned"
mongo-version: "7.0"
os-version: "ubuntu-22.04"
- shard_name: "xmodule-with-lms"
python-version: "3.11"
django-version: "pinned"
mongo-version: "7.0"
os-version: "ubuntu-22.04"

steps:
- name: checkout repo
Expand Down Expand Up @@ -90,19 +95,10 @@ jobs:
activate = 1
EOF

- name: install mongo version
run: |
if [[ "${{ matrix.mongo-version }}" != "4.4" ]]; then
wget -qO - https://www.mongodb.org/static/pgp/server-${{ matrix.mongo-version }}.asc | sudo apt-key add -
echo "deb https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/${{ matrix.mongo-version }} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-${{ matrix.mongo-version }}.list
sudo apt-get update && sudo apt-get install -y mongodb-org="${{ matrix.mongo-version }}.*"
fi

- name: start mongod server for tests
run: |
sudo mkdir -p /data/db
sudo chmod -R a+rw /data/db
mongod &
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongo-version }}

- name: Setup Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -164,7 +160,7 @@ jobs:
overwrite: true

collect-and-verify:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup Python
Expand Down Expand Up @@ -229,7 +225,7 @@ jobs:
# https://github.com/orgs/community/discussions/33579
success:
name: Unit tests successful
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: always()
needs: [run-tests]
steps:
Expand All @@ -240,7 +236,7 @@ jobs:
jobs: ${{ toJSON(needs) }}

compile-warnings-report:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: [run-tests]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -268,7 +264,7 @@ jobs:
overwrite: true

merge-artifacts:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: [compile-warnings-report]
steps:
- name: Merge Pytest Warnings JSON Artifacts
Expand All @@ -288,7 +284,7 @@ jobs:
# Combine and upload coverage reports.
coverage:
if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: [run-tests]
strategy:
matrix:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ def test_update_comment_basic(self, mock_is_forum_v2_enabled, mock_request):
headers=ANY,
params=ANY,
timeout=ANY,
data={"body": updated_body}
data={"body": updated_body, "course_id": str(self.course_id)}
)

def test_flag_thread_open(self, mock_is_forum_v2_enabled, mock_request):
Expand Down
38 changes: 19 additions & 19 deletions lms/djangoapps/discussion/django_comment_client/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def create_thread(request, course_id, commentable_id):

if follow:
cc_user = cc.User.from_django_user(user)
cc_user.follow(thread)
cc_user.follow(thread, course_id)
thread_followed.send(sender=None, user=user, post=thread)

data = thread.to_dict()
Expand Down Expand Up @@ -673,7 +673,7 @@ def _create_comment(request, course_key, thread_id=None, parent_id=None):
parent_id=parent_id,
body=sanitize_body(post["body"]),
)
comment.save()
comment.save(params={"course_id": str(course_key)})

comment_created.send(sender=None, user=user, post=comment)

Expand Down 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 All @@ -736,7 +736,7 @@ def update_comment(request, course_id, comment_id):
if 'body' not in request.POST or not request.POST['body'].strip():
return JsonError(_("Body can't be empty"))
comment.body = sanitize_body(request.POST["body"])
comment.save()
comment.save(params={"course_id": course_id})

comment_edited.send(sender=None, user=request.user, post=comment)

Expand All @@ -762,7 +762,7 @@ def endorse_comment(request, course_id, comment_id):
endorsed = request.POST.get('endorsed', 'false').lower() == 'true'
comment.endorsed = endorsed
comment.endorsement_user_id = user.id
comment.save()
comment.save(params={"course_id": course_id})
comment_endorsed.send(sender=None, user=user, post=comment)
track_forum_response_mark_event(request, course, comment, endorsed)
return JsonResponse(prepare_content(comment.to_dict(), course_key))
Expand All @@ -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 @@ -814,7 +814,7 @@ def delete_comment(request, course_id, comment_id):
course_key = CourseKey.from_string(course_id)
course = get_course_with_access(request.user, 'load', course_key)
comment = cc.Comment.find(comment_id)
comment.delete()
comment.delete(course_id=course_id)
comment_deleted.send(sender=None, user=request.user, post=comment)
track_comment_deleted_event(request, course, comment)
return JsonResponse(prepare_content(comment.to_dict(), course_key))
Expand All @@ -828,12 +828,12 @@ def _vote_or_unvote(request, course_id, obj, value='up', undo_vote=False):
course = get_course_with_access(request.user, 'load', course_key)
user = cc.User.from_django_user(request.user)
if undo_vote:
user.unvote(obj)
user.unvote(obj, course_id)
# TODO(smarnach): Determine the value of the vote that is undone. Currently, you can
# only cast upvotes in the user interface, so it is assumed that the vote value is 'up'.
# (People could theoretically downvote by handcrafting AJAX requests.)
else:
user.vote(obj, value)
user.vote(obj, value, course_id)
thread_voted.send(sender=None, user=request.user, post=obj)
track_voted_event(request, course, obj, value, undo_vote)
return JsonResponse(prepare_content(obj.to_dict(), course_key))
Expand Down Expand Up @@ -899,7 +899,7 @@ def flag_abuse_for_thread(request, course_id, thread_id):
user = cc.User.from_django_user(request.user)
course = get_course_by_id(course_key)
thread = cc.Thread.find(thread_id)
thread.flagAbuse(user, thread)
thread.flagAbuse(user, thread, course_id)
track_discussion_reported_event(request, course, thread)
thread_flagged.send(sender='flag_abuse_for_thread', user=request.user, post=thread)
return JsonResponse(prepare_content(thread.to_dict(), course_key))
Expand All @@ -921,7 +921,7 @@ def un_flag_abuse_for_thread(request, course_id, thread_id):
has_permission(request.user, 'openclose_thread', course_key) or
has_access(request.user, 'staff', course)
)
thread.unFlagAbuse(user, thread, remove_all)
thread.unFlagAbuse(user, thread, remove_all, course_id)
track_discussion_unreported_event(request, course, thread)
return JsonResponse(prepare_content(thread.to_dict(), course_key))

Expand All @@ -938,7 +938,7 @@ def flag_abuse_for_comment(request, course_id, comment_id):
user = cc.User.from_django_user(request.user)
course = get_course_by_id(course_key)
comment = cc.Comment.find(comment_id)
comment.flagAbuse(user, comment)
comment.flagAbuse(user, comment, course_id)
track_discussion_reported_event(request, course, comment)
comment_flagged.send(sender='flag_abuse_for_comment', user=request.user, post=comment)
return JsonResponse(prepare_content(comment.to_dict(), course_key))
Expand All @@ -960,7 +960,7 @@ def un_flag_abuse_for_comment(request, course_id, comment_id):
has_access(request.user, 'staff', course)
)
comment = cc.Comment.find(comment_id)
comment.unFlagAbuse(user, comment, remove_all)
comment.unFlagAbuse(user, comment, remove_all, course_id)
track_discussion_unreported_event(request, course, comment)
return JsonResponse(prepare_content(comment.to_dict(), course_key))

Expand All @@ -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 All @@ -1005,7 +1005,7 @@ def follow_thread(request, course_id, thread_id): # lint-amnesty, pylint: disab
course_key = CourseKey.from_string(course_id)
course = get_course_by_id(course_key)
thread = cc.Thread.find(thread_id)
user.follow(thread)
user.follow(thread, course_id=course_id)
thread_followed.send(sender=None, user=request.user, post=thread)
track_thread_followed_event(request, course, thread, True)
return JsonResponse({})
Expand All @@ -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 All @@ -1037,7 +1037,7 @@ def unfollow_thread(request, course_id, thread_id): # lint-amnesty, pylint: dis
course = get_course_by_id(course_key)
user = cc.User.from_django_user(request.user)
thread = cc.Thread.find(thread_id)
user.unfollow(thread)
user.unfollow(thread, course_id=course_id)
thread_unfollowed.send(sender=None, user=request.user, post=thread)
track_thread_followed_event(request, course, thread, False)
return JsonResponse({})
Expand All @@ -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
Loading