Skip to content

Commit d33ec75

Browse files
Abdul-Muqadim-Arbisofttaimoor-ahmed-1Taimoor  AhmedAli-Salman29kdmccormick
authored and
Zubair Shakoor
committed
Fix/forum patches sumac (openedx#36606)
* fix: discussion xblock not compatible with forum v2 (openedx#36315) fix all endpoints that were currently breaking with the discussion xblock. Co-authored-by: Taimoor Ahmed <[email protected]> * fix: legacy discussion issues (openedx#36433) Explicitly passed course_id to all views * fix: legacy forum issues (openedx#36470) Co-authored-by: Taimoor Ahmed <[email protected]> * build: Switch off deprecated C-Hive NPM cache (openedx#36502) JS tests are failing because we are using a discontinued GHA caching service: https://github.blog/changelog/2025-03-20-notification-of-upcoming-breaking-changes-in-github-actions/#decommissioned-cache-service-brownouts This service is used by the unsupported C-Hive caching action which we are relying on: https://github.com/c-hive/gha-npm-cache We are switching to the supported caching mechanims which is provided by setup-node: https://github.com/actions/setup-node?tab=readme-ov-file#caching-global-packages-data * Merge pull request openedx#35713 from openedx/feanil/ubuntu-24.04 feanil/ubuntu 24.04 --------- Co-authored-by: Taimoor Ahmed <[email protected]> Co-authored-by: Taimoor Ahmed <[email protected]> Co-authored-by: Ali Salman <[email protected]> Co-authored-by: Kyle McCormick <[email protected]> Co-authored-by: Feanil Patel <[email protected]>
1 parent d275dd1 commit d33ec75

File tree

25 files changed

+133
-134
lines changed

25 files changed

+133
-134
lines changed

.github/workflows/check-consistent-dependencies.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defaults:
1515
jobs:
1616
check-requirements:
1717
name: Compile requirements
18-
runs-on: ubuntu-22.04
18+
runs-on: ubuntu-24.04
1919

2020
steps:
2121
# Only run remaining steps if there are changes to requirements/**

.github/workflows/ci-static-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
python-version:
1212
- "3.11"
13-
os: ["ubuntu-22.04"]
13+
os: ["ubuntu-24.04"]
1414

1515
steps:
1616
- uses: actions/checkout@v4

.github/workflows/js-tests.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
uses: actions/setup-node@v4
2727
with:
2828
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
2930

3031
- name: Setup npm
3132
run: npm i -g [email protected]
@@ -63,7 +64,9 @@ jobs:
6364
run: |
6465
make base-requirements
6566
66-
- uses: c-hive/gha-npm-cache@v1
67+
- name: Install npm
68+
run: npm ci
69+
6770
- name: Run JS Tests
6871
env:
6972
TEST_SUITE: js-unit

.github/workflows/migrations-check.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
16-
os: [ubuntu-22.04]
16+
os: [ubuntu-24.04]
1717
python-version:
1818
- "3.11"
1919
# 'pinned' is used to install the latest patch version of Django
@@ -126,7 +126,7 @@ jobs:
126126
if: always()
127127
needs:
128128
- check_migrations
129-
runs-on: ubuntu-22.04
129+
runs-on: ubuntu-24.04
130130
steps:
131131
- name: Decide whether the needed jobs succeeded or failed
132132
# uses: re-actors/[email protected]

.github/workflows/pylint-checks.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
run-pylint:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-24.04
1212
strategy:
1313
fail-fast: false
1414
matrix:
@@ -75,7 +75,7 @@ jobs:
7575
if: always()
7676
needs:
7777
- run-pylint
78-
runs-on: ubuntu-22.04
78+
runs-on: ubuntu-24.04
7979
steps:
8080
- name: Decide whether the needed jobs succeeded or failed
8181
# uses: re-actors/[email protected]

.github/workflows/quality-checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414
strategy:
1515
matrix:
16-
os: [ubuntu-22.04]
16+
os: [ubuntu-24.04]
1717
python-version:
1818
- "3.11"
1919
node-version: [20]

.github/workflows/static-assets-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-22.04]
15+
os: [ubuntu-24.04]
1616
python-version:
1717
- "3.11"
1818
node-version: [18, 20]

.github/workflows/unit-tests.yml

+29-33
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
jobs:
1616
run-tests:
1717
name: ${{ matrix.shard_name }}(py=${{ matrix.python-version }},dj=${{ matrix.django-version }},mongo=${{ matrix.mongo-version }})
18-
runs-on: ubuntu-22.04
18+
runs-on: ${{ matrix.os-version }}
1919
strategy:
2020
matrix:
2121
python-version:
@@ -43,22 +43,27 @@ jobs:
4343
- "xmodule-with-cms"
4444
mongo-version:
4545
- "7.0"
46+
os-version:
47+
- ubuntu-24.04
4648

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

6368
steps:
6469
- name: checkout repo
@@ -90,19 +95,10 @@ jobs:
9095
activate = 1
9196
EOF
9297
93-
- name: install mongo version
94-
run: |
95-
if [[ "${{ matrix.mongo-version }}" != "4.4" ]]; then
96-
wget -qO - https://www.mongodb.org/static/pgp/server-${{ matrix.mongo-version }}.asc | sudo apt-key add -
97-
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
98-
sudo apt-get update && sudo apt-get install -y mongodb-org="${{ matrix.mongo-version }}.*"
99-
fi
100-
101-
- name: start mongod server for tests
102-
run: |
103-
sudo mkdir -p /data/db
104-
sudo chmod -R a+rw /data/db
105-
mongod &
98+
- name: Start MongoDB
99+
uses: supercharge/[email protected]
100+
with:
101+
mongodb-version: ${{ matrix.mongo-version }}
106102

107103
- name: Setup Python
108104
uses: actions/setup-python@v5
@@ -164,7 +160,7 @@ jobs:
164160
overwrite: true
165161

166162
collect-and-verify:
167-
runs-on: ubuntu-22.04
163+
runs-on: ubuntu-24.04
168164
steps:
169165
- uses: actions/checkout@v4
170166
- name: Setup Python
@@ -229,7 +225,7 @@ jobs:
229225
# https://github.com/orgs/community/discussions/33579
230226
success:
231227
name: Unit tests successful
232-
runs-on: ubuntu-22.04
228+
runs-on: ubuntu-24.04
233229
if: always()
234230
needs: [run-tests]
235231
steps:
@@ -240,7 +236,7 @@ jobs:
240236
jobs: ${{ toJSON(needs) }}
241237

242238
compile-warnings-report:
243-
runs-on: ubuntu-22.04
239+
runs-on: ubuntu-24.04
244240
needs: [run-tests]
245241
steps:
246242
- uses: actions/checkout@v4
@@ -268,7 +264,7 @@ jobs:
268264
overwrite: true
269265

270266
merge-artifacts:
271-
runs-on: ubuntu-22.04
267+
runs-on: ubuntu-24.04
272268
needs: [compile-warnings-report]
273269
steps:
274270
- name: Merge Pytest Warnings JSON Artifacts
@@ -288,7 +284,7 @@ jobs:
288284
# Combine and upload coverage reports.
289285
coverage:
290286
if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
291-
runs-on: ubuntu-22.04
287+
runs-on: ubuntu-24.04
292288
needs: [run-tests]
293289
strategy:
294290
matrix:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ def test_update_comment_basic(self, mock_is_forum_v2_enabled, mock_request):
812812
headers=ANY,
813813
params=ANY,
814814
timeout=ANY,
815-
data={"body": updated_body}
815+
data={"body": updated_body, "course_id": str(self.course_id)}
816816
)
817817

818818
def test_flag_thread_open(self, mock_is_forum_v2_enabled, mock_request):

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

+19-19
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def create_thread(request, course_id, commentable_id):
584584

585585
if follow:
586586
cc_user = cc.User.from_django_user(user)
587-
cc_user.follow(thread)
587+
cc_user.follow(thread, course_id)
588588
thread_followed.send(sender=None, user=user, post=thread)
589589

590590
data = thread.to_dict()
@@ -673,7 +673,7 @@ def _create_comment(request, course_key, thread_id=None, parent_id=None):
673673
parent_id=parent_id,
674674
body=sanitize_body(post["body"]),
675675
)
676-
comment.save()
676+
comment.save(params={"course_id": str(course_key)})
677677

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

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

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

@@ -762,7 +762,7 @@ def endorse_comment(request, course_id, comment_id):
762762
endorsed = request.POST.get('endorsed', 'false').lower() == 'true'
763763
comment.endorsed = endorsed
764764
comment.endorsement_user_id = user.id
765-
comment.save()
765+
comment.save(params={"course_id": course_id})
766766
comment_endorsed.send(sender=None, user=user, post=comment)
767767
track_forum_response_mark_event(request, course, comment, endorsed)
768768
return JsonResponse(prepare_content(comment.to_dict(), course_key))
@@ -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({
@@ -814,7 +814,7 @@ def delete_comment(request, course_id, comment_id):
814814
course_key = CourseKey.from_string(course_id)
815815
course = get_course_with_access(request.user, 'load', course_key)
816816
comment = cc.Comment.find(comment_id)
817-
comment.delete()
817+
comment.delete(course_id=course_id)
818818
comment_deleted.send(sender=None, user=request.user, post=comment)
819819
track_comment_deleted_event(request, course, comment)
820820
return JsonResponse(prepare_content(comment.to_dict(), course_key))
@@ -828,12 +828,12 @@ def _vote_or_unvote(request, course_id, obj, value='up', undo_vote=False):
828828
course = get_course_with_access(request.user, 'load', course_key)
829829
user = cc.User.from_django_user(request.user)
830830
if undo_vote:
831-
user.unvote(obj)
831+
user.unvote(obj, course_id)
832832
# TODO(smarnach): Determine the value of the vote that is undone. Currently, you can
833833
# only cast upvotes in the user interface, so it is assumed that the vote value is 'up'.
834834
# (People could theoretically downvote by handcrafting AJAX requests.)
835835
else:
836-
user.vote(obj, value)
836+
user.vote(obj, value, course_id)
837837
thread_voted.send(sender=None, user=request.user, post=obj)
838838
track_voted_event(request, course, obj, value, undo_vote)
839839
return JsonResponse(prepare_content(obj.to_dict(), course_key))
@@ -899,7 +899,7 @@ def flag_abuse_for_thread(request, course_id, thread_id):
899899
user = cc.User.from_django_user(request.user)
900900
course = get_course_by_id(course_key)
901901
thread = cc.Thread.find(thread_id)
902-
thread.flagAbuse(user, thread)
902+
thread.flagAbuse(user, thread, course_id)
903903
track_discussion_reported_event(request, course, thread)
904904
thread_flagged.send(sender='flag_abuse_for_thread', user=request.user, post=thread)
905905
return JsonResponse(prepare_content(thread.to_dict(), course_key))
@@ -921,7 +921,7 @@ def un_flag_abuse_for_thread(request, course_id, thread_id):
921921
has_permission(request.user, 'openclose_thread', course_key) or
922922
has_access(request.user, 'staff', course)
923923
)
924-
thread.unFlagAbuse(user, thread, remove_all)
924+
thread.unFlagAbuse(user, thread, remove_all, course_id)
925925
track_discussion_unreported_event(request, course, thread)
926926
return JsonResponse(prepare_content(thread.to_dict(), course_key))
927927

@@ -938,7 +938,7 @@ def flag_abuse_for_comment(request, course_id, comment_id):
938938
user = cc.User.from_django_user(request.user)
939939
course = get_course_by_id(course_key)
940940
comment = cc.Comment.find(comment_id)
941-
comment.flagAbuse(user, comment)
941+
comment.flagAbuse(user, comment, course_id)
942942
track_discussion_reported_event(request, course, comment)
943943
comment_flagged.send(sender='flag_abuse_for_comment', user=request.user, post=comment)
944944
return JsonResponse(prepare_content(comment.to_dict(), course_key))
@@ -960,7 +960,7 @@ def un_flag_abuse_for_comment(request, course_id, comment_id):
960960
has_access(request.user, 'staff', course)
961961
)
962962
comment = cc.Comment.find(comment_id)
963-
comment.unFlagAbuse(user, comment, remove_all)
963+
comment.unFlagAbuse(user, comment, remove_all, course_id)
964964
track_discussion_unreported_event(request, course, comment)
965965
return JsonResponse(prepare_content(comment.to_dict(), course_key))
966966

@@ -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

@@ -1005,7 +1005,7 @@ def follow_thread(request, course_id, thread_id): # lint-amnesty, pylint: disab
10051005
course_key = CourseKey.from_string(course_id)
10061006
course = get_course_by_id(course_key)
10071007
thread = cc.Thread.find(thread_id)
1008-
user.follow(thread)
1008+
user.follow(thread, course_id=course_id)
10091009
thread_followed.send(sender=None, user=request.user, post=thread)
10101010
track_thread_followed_event(request, course, thread, True)
10111011
return JsonResponse({})
@@ -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

@@ -1037,7 +1037,7 @@ def unfollow_thread(request, course_id, thread_id): # lint-amnesty, pylint: dis
10371037
course = get_course_by_id(course_key)
10381038
user = cc.User.from_django_user(request.user)
10391039
thread = cc.Thread.find(thread_id)
1040-
user.unfollow(thread)
1040+
user.unfollow(thread, course_id=course_id)
10411041
thread_unfollowed.send(sender=None, user=request.user, post=thread)
10421042
track_thread_followed_event(request, course, thread, False)
10431043
return JsonResponse({})
@@ -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

0 commit comments

Comments
 (0)