Skip to content
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

feat: add a method for calling python APIs #580

Closed
wants to merge 151 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
085a2f5
refactor: deprecated course update notification waffle flag (#35190)
eemaanamir Jul 30, 2024
39dd3c0
feat: converting existing api to drf base api. (#35039)
awais786 Jul 30, 2024
459b0a4
feat: Upgrade Python dependency edx-enterprise
hamzawaleed01 Jul 30, 2024
657a138
Merge pull request #35204 from openedx/hamzawaleed01/upgrade-edx-ente…
hamzawaleed01 Jul 30, 2024
46c972e
feat: Upgrade Python dependency edx-enterprise (#35205)
github-actions[bot] Jul 30, 2024
0359d52
fix: Prevent error page recursion (#35209)
timmc-edx Jul 31, 2024
73c3211
chore: geoip2: update maxmind geolite country database
feanil Aug 1, 2024
2ba6fd5
Merge pull request #35212 from openedx/feanil/geoip2-bot-update-count…
Aug 1, 2024
20f7dbd
fix: content search last_published date [FC-0059] (#35195)
pomegranited Aug 1, 2024
a7f6cf1
feat: removing the from the retirement pipeline (#35215)
deborahgu Aug 1, 2024
2788f2b
feat: New fields in library v2 details API view (#35091)
ChrisChV Aug 1, 2024
c135fdd
fix: removed extra space and colon from ORA notification content (#35…
eemaanamir Aug 2, 2024
5aa6958
feat: added truncate and alert in notification (#35214)
muhammadadeeltajamul Aug 5, 2024
8fb033a
feat: add PA role
hamzawaleed01 Aug 5, 2024
28ce713
feat: added custom setting attribute for gradebook freeze timedelta (…
Anas12091101 Aug 5, 2024
5005168
chore: update ora2 version in requirements (#35222)
eemaanamir Aug 5, 2024
05bf82c
chore: bumping enteprise version to 4.22.4
pmakwana93 Aug 5, 2024
e35f183
Merge pull request #35227 from pmakwana93/pmakwana93/bumping-enterpri…
marlonkeating Aug 5, 2024
8aac664
fix: error when saving changes to a v2 library block (#35217)
bradenmacdonald Aug 5, 2024
48c5856
fix(deps): update dependency requirejs to v2.3.7 [security]
renovate[bot] Aug 6, 2024
0a067ff
feat: upgrading simple api to drf compatible (4th api ) (#35135)
awais786 Aug 6, 2024
3c64b74
feat: Upgrade Python dependency edx-django-utils (#35235)
github-actions[bot] Aug 6, 2024
94f4c48
build: Pin social-auth-app-django as a requirement. (#35237)
dianakhuang Aug 6, 2024
834dc31
chore: Upgrade Python requirements (#35241)
edx-requirements-bot Aug 6, 2024
9bd6924
fix: make course update email pref false (#35224)
AhtishamShahid Aug 7, 2024
99760f8
feat: Upgrading api list_course_role_members ( 2nd api ) (#35105)
awais786 Aug 7, 2024
35651da
build: Downgrade xblock due to behavior regression. (#35244)
dianakhuang Aug 7, 2024
2228129
chore: version bump
katrinan029 Aug 7, 2024
36200f4
fix: Fix matching of /c4x/ in course asset view urlpatterns (#35247)
timmc-edx Aug 7, 2024
747d515
Merge branch 'master' into knguyen2/version-bump-9302
katrinan029 Aug 7, 2024
d1bf43d
Merge pull request #35246 from openedx/knguyen2/version-bump-9302
katrinan029 Aug 7, 2024
63f327b
feat: added events to bulk email tool (#35147)
AhtishamShahid Aug 8, 2024
e7dbc48
fix: resolved content issue in renamed notification (#35252)
AhtishamShahid Aug 8, 2024
aa952c9
feat: allow copying library v2 XBlocks via existing copy REST API (#3…
rpenido Aug 8, 2024
eb5bef0
fix: Remove Program details Subscriptions portal CTA (#35249)
julianajlk Aug 8, 2024
aaa733e
chore: bump edx-enterprise to 4.23.3
marlonkeating Aug 8, 2024
10a427c
Merge pull request #35258 from openedx/mkeating/enterprise-version-bu…
marlonkeating Aug 8, 2024
25d5d08
feat: fetched notifications based on time not date (#35250)
muhammadadeeltajamul Aug 12, 2024
152b678
feat: save author pronoun separately for notification to prevent info…
eemaanamir Aug 12, 2024
5c09424
fix: update course discussion config before course load (#35219)
AhtishamShahid Aug 12, 2024
78831cd
chore(deps): update dependency jest-enzyme to v6.1.2
renovate[bot] Aug 12, 2024
456f261
chore(deps): update dependency karma-junit-reporter to v1.2.0
renovate[bot] Aug 12, 2024
84644e1
chore(deps): update dependency karma-sourcemap-loader to v0.4.0
renovate[bot] Aug 12, 2024
212f3ea
chore(deps): update dependency react-test-renderer to v16.14.0
renovate[bot] Aug 12, 2024
892ca4d
fix(deps): update babel monorepo
renovate[bot] Aug 12, 2024
5bd8559
fix(deps): update dependency backbone to v1.6.0
renovate[bot] Aug 12, 2024
2ea6c25
feat: add PA role
hamzawaleed01 Aug 5, 2024
a5c4b08
Merge branch 'master' of github.com:openedx/edx-platform into ENT-920…
hamzawaleed01 Aug 12, 2024
534b938
Merge branch 'ENT-9201-add-PA-role' of github.com:openedx/edx-platfor…
hamzawaleed01 Aug 12, 2024
74af0e7
chore(deps): update jest monorepo to v26.6.3
renovate[bot] Aug 12, 2024
04e5076
feat: Upgrade Python dependency edx-enterprise
MueezKhan246 Aug 12, 2024
e226ed9
Merge branch 'master' of github.com:openedx/edx-platform into ENT-920…
hamzawaleed01 Aug 12, 2024
200ee1a
chore(deps): update dependency selenium-webdriver to v3.6.0
renovate[bot] Aug 12, 2024
059f833
Merge pull request #35297 from openedx/MueezKhan246/upgrade-edx-enter…
MueezKhan246 Aug 12, 2024
31f6ebf
Merge branch 'master' of github.com:openedx/edx-platform into ENT-920…
hamzawaleed01 Aug 13, 2024
30f1c75
feat: Upgrade Python dependency edx-enterprise
hamzawaleed01 Aug 13, 2024
0e5a5bb
Merge pull request #35307 from openedx/hamzawaleed01/upgrade-edx-ente…
hamzawaleed01 Aug 13, 2024
018ba9d
chore: bumping version num to 4.23.8 (#35310)
pmakwana93 Aug 13, 2024
c24c874
feat: Commerce Coordinator step in retirement pipeline
JadeyOlivier Jul 30, 2024
77ca0f7
fix: quality
JadeyOlivier Jul 30, 2024
e8f9db4
fix: generalize internal services
JadeyOlivier Aug 6, 2024
5e636de
fix: tests
JadeyOlivier Aug 12, 2024
64098b6
fix: Add CI update for tests
JadeyOlivier Aug 12, 2024
8a1c30e
fix: dependencies
JadeyOlivier Aug 12, 2024
4cde950
Revert "fix: dependencies"
JadeyOlivier Aug 12, 2024
a5442b2
fix: install dependencies
JadeyOlivier Aug 13, 2024
c9641b3
feat: updated user retirement docs
JadeyOlivier Aug 14, 2024
c06416b
fix: dependencies again
JadeyOlivier Aug 14, 2024
b65550c
fix: change settings config to empty list not dict
JadeyOlivier Aug 14, 2024
395bcd6
Merge branch 'master' of github.com:openedx/edx-platform into ENT-920…
hamzawaleed01 Aug 15, 2024
d8ca283
Merge pull request #35223 from openedx/ENT-9201-add-PA-role
hamzawaleed01 Aug 15, 2024
3d7cc1c
Merge pull request #35203 from openedx/jolivier/SONIC-561/coordinator…
JadeyOlivier Aug 15, 2024
e485553
Revert: revert generic retirement update (#35317)
justinhynes Aug 15, 2024
11de2a4
feat: REST API to allow pasting clipboard (staged) content into a lib…
yusuf-musleh Aug 15, 2024
ca46c20
fix: update content reported notification (#35315)
eemaanamir Aug 16, 2024
0077269
feat: added unsubscribe url in digest header (#35319)
muhammadadeeltajamul Aug 19, 2024
6bcbb1d
feat: Upgrading api to use drf 5th api. register_and_enroll_students …
awais786 Aug 19, 2024
6525811
fix: delete discarded drafts from meilisearch index
navinkarkera Aug 6, 2024
2efff26
refactor: parallelize content block update on discard
navinkarkera Aug 7, 2024
140b9bb
refactor: delete all documents on discard
navinkarkera Aug 7, 2024
e149539
refactor: delete documents that were never published on discard
navinkarkera Aug 7, 2024
fed8a80
test: delete documents that were never published on discard
navinkarkera Aug 7, 2024
c3480b8
chore: add comment
navinkarkera Aug 14, 2024
860ca3c
chore: Upgrade Python requirements
edx-requirements-bot Aug 20, 2024
af9ae77
feat: upgrading simple api to drf compatible. (#35260)
awais786 Aug 20, 2024
688242a
refactor: remove unused builtinblock webpack entry points (#35299)
kdmccormick Aug 20, 2024
375b9d9
feat: Expose xmodule xblocks Sass variables as vanilla CSS variables …
farhan Aug 20, 2024
a8ee9a6
chore: Pin algoliasearch to v3
iamsobanjaved Aug 21, 2024
30bfbd5
feat: Upgrade Python dependency algoliasearch
iamsobanjaved Aug 21, 2024
57ec4ff
Merge pull request #35336 from openedx/iamsobanjaved/upgrade-algolias…
iamsobanjaved Aug 21, 2024
9374717
Merge pull request #35327 from openedx/repo-tools/upgrade-python-requ…
iamsobanjaved Aug 21, 2024
0c2a919
chore: bumping version to 4.23.9 (#35335)
pmakwana93 Aug 21, 2024
f93d16f
feat: upgrading simple api to drf compatible ( 3rd api ) list_email_c…
awais786 Aug 22, 2024
44112aa
fix: Respect the authsource kwarg for MongoDB connections (#35239)
blarghmatey Aug 22, 2024
72d060c
feat: update XBlock to 5.1.0 (#35325)
nsprenkle Aug 22, 2024
6071992
feat: lint this file (#35348)
deborahgu Aug 22, 2024
36a3b0b
Revert "fix: update course discussion config before course load (#352…
KristinAoki Aug 22, 2024
5fbcc79
feat: add collections app from openedx-learning (#35312)
rpenido Aug 23, 2024
71f410e
feat: added snowflake events for email digest unsubscribe (#35329)
muhammadadeeltajamul Aug 26, 2024
66f3a08
feat: added email content in misc notifications (#35341)
AhtishamShahid Aug 26, 2024
353dc34
chore: provide logo url from backend for batch enrollment email (#35138)
mudassir-hafeez Aug 26, 2024
0f177e4
feat: linting only (#35370)
deborahgu Aug 26, 2024
b30318a
feat: add VerificationAttempt model to verify_student application
MichaelRoytman Aug 12, 2024
e615540
Merge pull request #35304 from openedx/michaelroytman/COSMO-421-Verif…
MichaelRoytman Aug 26, 2024
a9d6d4b
feat: Upgrade Python dependency edx-enterprise
MueezKhan246 Aug 26, 2024
b1ecd8f
Merge pull request #35379 from openedx/MueezKhan246/upgrade-edx-enter…
MueezKhan246 Aug 27, 2024
275d4d9
feat: show_student_extensions upgrading api to drf compatible ( 9th )…
awais786 Aug 27, 2024
f0d8d52
fix: add aria-current attributes to video captions (#35371)
KristinAoki Aug 27, 2024
2e77e65
feat: Problem types added as filterable attribute [FC-0059] (#35242)
ChrisChV Aug 27, 2024
9124e7b
feat: allow update xblock fields without passing data (#35320)
rpenido Aug 27, 2024
c65478e
feat: index library collections in studio meilisearch index (#35324)
navinkarkera Aug 27, 2024
60e4449
chore: Convert word cloud block sass variables to css variables
farhan Aug 28, 2024
ea596d6
fix: convert totalRegistrationTime to snake case (#35333)
ahtesham-quraish Aug 28, 2024
1c2b804
feat: DEPR USE-JWT-COOKIE header (#35393)
robrap Aug 29, 2024
481a507
feat: updated content in course_update notification (#35373)
muhammadadeeltajamul Aug 29, 2024
b323e65
feat: added content block in email notification template (#35391)
muhammadadeeltajamul Aug 29, 2024
7530927
Merge pull request #35386 from openedx/farhan/convert-wordcloud-sass-…
farhan Aug 29, 2024
1a431b6
feat: get_students_who_may_enroll update api to DRF ( 8th ) (#35174)
awais786 Aug 29, 2024
5323c55
fix: renamed DatabaseNotReadyError (#35390)
Anas12091101 Aug 29, 2024
989a513
feat: Upgrade Python dependency edx-enterprise
sameeramin Aug 29, 2024
01c718d
Revert "feat: DEPR USE-JWT-COOKIE header (#35393)" (#35397)
robrap Aug 29, 2024
4c3a0b5
Merge branch 'master' into sameeramin/upgrade-edx-enterprise-5323c55
sameeramin Aug 30, 2024
bcab8df
Merge pull request #35398 from openedx/sameeramin/upgrade-edx-enterpr…
sameeramin Aug 30, 2024
ede9102
feat: upgrading get_anon_ids api to drf compatible (12) (#35345)
awais786 Aug 30, 2024
ecd31b3
fix(deps): update dependency webpack to v5.94.0 [security]
renovate[bot] Aug 30, 2024
638bc5d
chore: Update LMS openapi spec yml file (#35400)
julianajlk Aug 30, 2024
311da82
feat: DEPR USE-JWT-COOKIE header - Part 1 (#35401)
robrap Aug 30, 2024
92cc3bf
style: constrain exam iframe to avoid scroll problems (#35396)
zacharis278 Aug 30, 2024
bfee53b
feat: Update CORS allowed headers for compat. w/ axios-cache-intercep…
bradenmacdonald Aug 30, 2024
ec34753
fix: update library v2 search index synchronously (#35367)
navinkarkera Aug 30, 2024
c96949e
feat: Upgrade Python dependency edx-enterprise
MueezKhan246 Aug 30, 2024
4736e9c
Merge pull request #35405 from openedx/MueezKhan246/upgrade-edx-enter…
MueezKhan246 Sep 2, 2024
e668790
chore: Convert annotatable block sass variables to css variables
farhan Sep 2, 2024
14d2c4e
feat: skip `migrations_are_in_sync` test
sameeramin Sep 2, 2024
a4168a7
Merge pull request #35413 from openedx/sameeramin/ENT-8971
sameeramin Sep 2, 2024
ff2afe1
feat: Upgrade Python dependency edx-enterprise
sameeramin Sep 3, 2024
fd92be6
Merge pull request #35418 from openedx/sameeramin/upgrade-edx-enterpr…
sameeramin Sep 3, 2024
4a12de7
refactor: remove unused JS requirement in CMS (#34545)
bradenmacdonald Sep 3, 2024
dd3a7aa
fix: update bulk email created event data (#35412)
muhammadadeeltajamul Sep 4, 2024
ba883fa
Merge pull request #35409 from openedx/farhan/convert-annotatable-sas…
farhan Sep 4, 2024
1ad9fd2
feat: Upgrade Python dependency edx-enterprise
sameeramin Sep 4, 2024
060473a
Merge pull request #35427 from openedx/sameeramin/upgrade-edx-enterpr…
sameeramin Sep 4, 2024
96a6176
feat: Upgrade Python dependency edx-enterprise
katrinan029 Sep 4, 2024
ef4e037
Merge pull request #35429 from openedx/katrinan029/upgrade-edx-enterp…
katrinan029 Sep 4, 2024
51d538c
fix: Remove B2C Subscriptions (#35303)
julianajlk Sep 4, 2024
4d9066d
feat: Upgrade Python dependency openedx-events
pwnage101 Sep 5, 2024
2c705c9
Merge pull request #35432 from openedx/pwnage101/upgrade-openedx-even…
pwnage101 Sep 5, 2024
6a78769
Add Forum v2 request logging (#571)
taimoor-ahmed-1 Aug 2, 2024
c0e0ac2
fix: update settings to use forum v2 APIs
Ali-Salman29 Aug 9, 2024
74a5a95
feat: call python methods from forum v2
Sep 13, 2024
2ea9621
chore: code refactoring
Sep 16, 2024
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
13 changes: 0 additions & 13 deletions cms/djangoapps/contentstore/config/waffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,3 @@
# .. toggle_warning: Flag course_experience.relative_dates should also be active for relative dates functionalities to work.
# .. toggle_tickets: https://openedx.atlassian.net/browse/AA-844
CUSTOM_RELATIVE_DATES = CourseWaffleFlag(f'{WAFFLE_NAMESPACE}.custom_relative_dates', __name__)


# .. toggle_name: studio.enable_course_update_notifications
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: Waffle flag to enable course update notifications.
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 14-Feb-2024
# .. toggle_target_removal_date: 14-Mar-2024
ENABLE_COURSE_UPDATE_NOTIFICATIONS = CourseWaffleFlag(
f'{WAFFLE_NAMESPACE}.enable_course_update_notifications',
__name__
)
8 changes: 3 additions & 5 deletions cms/djangoapps/contentstore/course_info_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from django.http import HttpResponseBadRequest
from django.utils.translation import gettext as _

from cms.djangoapps.contentstore.config.waffle import ENABLE_COURSE_UPDATE_NOTIFICATIONS
from cms.djangoapps.contentstore.utils import track_course_update_event, send_course_update_notification
from openedx.core.lib.xblock_utils import get_course_update_items
from xmodule.html_block import CourseInfoBlock # lint-amnesty, pylint: disable=wrong-import-order
Expand Down Expand Up @@ -93,10 +92,9 @@ def update_course_updates(location, update, passed_id=None, user=None, request_m
track_course_update_event(location.course_key, user, course_update_dict)

# send course update notification
if ENABLE_COURSE_UPDATE_NOTIFICATIONS.is_enabled(location.course_key):
send_course_update_notification(
location.course_key, course_update_dict["content"], user,
)
send_course_update_notification(
location.course_key, course_update_dict["content"], user,
)

# remove status key
if "status" in course_update_dict:
Expand Down
34 changes: 34 additions & 0 deletions cms/djangoapps/contentstore/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from edx_toggles.toggles.testutils import override_waffle_flag
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import CourseLocator, LibraryLocator
from path import Path as path
Expand All @@ -19,7 +20,11 @@
from cms.djangoapps.contentstore import utils
from cms.djangoapps.contentstore.tasks import ALL_ALLOWED_XBLOCKS, validate_course_olx
from cms.djangoapps.contentstore.tests.utils import TEST_DATA_DIR, CourseTestCase
from cms.djangoapps.contentstore.utils import send_course_update_notification
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import GlobalStaffFactory, InstructorFactory, UserFactory
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
from openedx.core.djangoapps.notifications.models import CourseNotificationPreference, Notification
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
Expand Down Expand Up @@ -927,3 +932,32 @@ def test_update_course_details_instructor_paced(self, mock_update):

utils.update_course_details(mock_request, self.course.id, payload, None)
mock_update.assert_called_once_with(self.course.id, payload, mock_request.user)


@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True)
class CourseUpdateNotificationTests(ModuleStoreTestCase):
"""
Unit tests for the course_update notification.
"""

def setUp(self):
"""
Setup the test environment.
"""
super().setUp()
self.user = UserFactory()
self.course = CourseFactory.create(org='testorg', number='testcourse', run='testrun')
CourseNotificationPreference.objects.create(user_id=self.user.id, course_id=self.course.id)

def test_course_update_notification_sent(self):
"""
Test that the course_update notification is sent.
"""
user = UserFactory()
CourseEnrollment.enroll(user=user, course_key=self.course.id)
assert Notification.objects.all().count() == 0
content = "<p>content</p><img src='' />"
send_course_update_notification(self.course.id, content, self.user)
assert Notification.objects.all().count() == 1
notification = Notification.objects.first()
assert notification.content == "<p><strong><p>content</p></strong></p>"
32 changes: 29 additions & 3 deletions cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
from urllib.parse import quote_plus
from uuid import uuid4

from bs4 import BeautifulSoup
from django.conf import settings
from django.core.exceptions import ValidationError
from django.urls import reverse
from django.utils import translation
from django.utils.text import Truncator
from django.utils.translation import gettext as _
from eventtracking import tracker
from help_tokens.core import HelpUrlExpert
from lti_consumer.models import CourseAllowPIISharingInLTIFlag
from opaque_keys.edx.keys import CourseKey, UsageKey
from opaque_keys.edx.locator import LibraryLocator

from openedx.core.lib.teams_config import CONTENT_GROUPS_FOR_TEAMS, TEAM_SCHEME
from openedx_events.content_authoring.data import DuplicatedXBlockData
from openedx_events.content_authoring.signals import XBLOCK_DUPLICATED
Expand Down Expand Up @@ -2239,11 +2242,34 @@ def track_course_update_event(course_key, user, course_update_content=None):
tracker.emit(event_name, event_data)


def clean_html_body(html_body):
"""
Get html body, remove tags and limit to 500 characters
"""
html_body = BeautifulSoup(Truncator(html_body).chars(500, html=True), 'html.parser')

tags_to_remove = [
"a", "link", # Link Tags
"img", "picture", "source", # Image Tags
"video", "track", # Video Tags
"audio", # Audio Tags
"embed", "object", "iframe", # Embedded Content
"script"
]

# Remove the specified tags while keeping their content
for tag in tags_to_remove:
for match in html_body.find_all(tag):
match.unwrap()

return str(html_body)


def send_course_update_notification(course_key, content, user):
"""
Send course update notification
"""
text_content = re.sub(r"(\s|&nbsp;|//)+", " ", html_to_text(content))
text_content = re.sub(r"(\s|&nbsp;|//)+", " ", clean_html_body(content))
course = modulestore().get_course(course_key)
extra_context = {
'author_id': user.id,
Expand All @@ -2252,10 +2278,10 @@ def send_course_update_notification(course_key, content, user):
notification_data = CourseNotificationData(
course_key=course_key,
content_context={
"course_update_content": text_content if len(text_content.strip()) < 10 else "Click here to view",
"course_update_content": text_content,
**extra_context,
},
notification_type="course_update",
notification_type="course_updates",
content_url=f"{settings.LMS_ROOT_URL}/courses/{str(course_key)}/course/updates",
app_name="updates",
audience_filters={},
Expand Down
7 changes: 4 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,9 +1449,8 @@
'edx-ui-toolkit/js/utils/string-utils.js',
'edx-ui-toolkit/js/utils/html-utils.js',

# Load Bootstrap and supporting libraries
'common/js/vendor/popper.js',
'common/js/vendor/bootstrap.js',
# Here we were loading Bootstrap and supporting libraries, but it no longer seems to be needed for any Studio UI.
# 'common/js/vendor/bootstrap.bundle.js',

# Finally load RequireJS
'common/js/vendor/require.js'
Expand Down Expand Up @@ -1880,6 +1879,7 @@
'openedx_events',

# Learning Core Apps, used by v2 content libraries (content_libraries app)
"openedx_learning.apps.authoring.collections",
"openedx_learning.apps.authoring.components",
"openedx_learning.apps.authoring.contents",
"openedx_learning.apps.authoring.publishing",
Expand Down Expand Up @@ -2521,6 +2521,7 @@
ANALYTICS_DASHBOARD_NAME = 'Your Platform Name Here Insights'

COMMENTS_SERVICE_URL = 'http://localhost:18080'
COMMENTS_SERVICE_V2_URL = 'http://localhost:8000'
COMMENTS_SERVICE_KEY = 'password'

EXAMS_SERVICE_URL = 'http://localhost:18740/api/v1'
Expand Down
2 changes: 2 additions & 0 deletions cms/static/sass/studio-main-v1.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

// +Libs and Resets - *do not edit*
// ====================

@import '_builtin-block-variables';
@import 'bourbon/bourbon'; // lib - bourbon
@import 'vendor/bi-app/bi-app-ltr'; // set the layout for left to right languages
@import 'build-v1'; // shared app style assets/rendering
10 changes: 0 additions & 10 deletions common/djangoapps/entitlements/rest_api/v1/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""


from django.conf import settings
from rest_framework.permissions import SAFE_METHODS, BasePermission

from lms.djangoapps.courseware.access import has_access
Expand All @@ -22,12 +21,3 @@ def has_permission(self, request, view):
return request.user.is_authenticated
else:
return request.user.is_staff or has_access(request.user, "support", "global")


class IsSubscriptionWorkerUser(BasePermission):
"""
Method that will require the request to be coming from the subscriptions service worker user.
"""

def has_permission(self, request, view):
return request.user.username == settings.SUBSCRIPTIONS_SERVICE_WORKER_USERNAME
158 changes: 0 additions & 158 deletions common/djangoapps/entitlements/rest_api/v1/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import uuid
from datetime import datetime, timedelta
from unittest.mock import patch
from uuid import uuid4

from django.conf import settings
from django.urls import reverse
Expand Down Expand Up @@ -1236,160 +1235,3 @@ def test_user_is_not_unenrolled_on_failed_refund(
assert CourseEnrollment.is_enrolled(self.user, self.course.id)
assert course_entitlement.enrollment_course_run is not None
assert course_entitlement.expired_at is None


@skip_unless_lms
class RevokeSubscriptionsVerifiedAccessViewTest(ModuleStoreTestCase):
"""
Tests for the RevokeVerifiedAccessView
"""
REVOKE_VERIFIED_ACCESS_PATH = 'entitlements_api:v1:revoke_subscriptions_verified_access'

def setUp(self):
super().setUp()
self.user = UserFactory(username="subscriptions_worker", is_staff=True)
self.client.login(username=self.user.username, password=TEST_PASSWORD)
self.course = CourseFactory()
self.course_mode1 = CourseModeFactory(
course_id=self.course.id, # pylint: disable=no-member
mode_slug=CourseMode.VERIFIED,
expiration_datetime=now() + timedelta(days=1)
)
self.course_mode2 = CourseModeFactory(
course_id=self.course.id, # pylint: disable=no-member
mode_slug=CourseMode.AUDIT,
expiration_datetime=now() + timedelta(days=1)
)

@patch('common.djangoapps.entitlements.rest_api.v1.views.get_courses_completion_status')
def test_revoke_access_success(self, mock_get_courses_completion_status):
mock_get_courses_completion_status.return_value = ([], False)
enrollment = CourseEnrollmentFactory.create(
user=self.user,
course_id=self.course.id, # pylint: disable=no-member
is_active=True,
mode=CourseMode.VERIFIED
)
course_entitlement = CourseEntitlementFactory.create(user=self.user, enrollment_course_run=enrollment)
url = reverse(self.REVOKE_VERIFIED_ACCESS_PATH)

assert course_entitlement.enrollment_course_run is not None

response = self.client.post(
url,
data={
"entitlement_uuids": [str(course_entitlement.uuid)],
"lms_user_id": self.user.id
},
content_type='application/json',
)
assert response.status_code == 204

course_entitlement.refresh_from_db()
enrollment.refresh_from_db()
assert course_entitlement.expired_at is not None
assert course_entitlement.enrollment_course_run is None
assert enrollment.mode == CourseMode.AUDIT

@patch('common.djangoapps.entitlements.rest_api.v1.views.get_courses_completion_status')
def test_already_completed_course(self, mock_get_courses_completion_status):
enrollment = CourseEnrollmentFactory.create(
user=self.user,
course_id=self.course.id, # pylint: disable=no-member
is_active=True,
mode=CourseMode.VERIFIED
)
mock_get_courses_completion_status.return_value = ([str(enrollment.course_id)], False)
course_entitlement = CourseEntitlementFactory.create(user=self.user, enrollment_course_run=enrollment)
url = reverse(self.REVOKE_VERIFIED_ACCESS_PATH)

assert course_entitlement.enrollment_course_run is not None

response = self.client.post(
url,
data={
"entitlement_uuids": [str(course_entitlement.uuid)],
"lms_user_id": self.user.id
},
content_type='application/json',
)
assert response.status_code == 204

course_entitlement.refresh_from_db()
assert course_entitlement.expired_at is None
assert course_entitlement.enrollment_course_run.mode == CourseMode.VERIFIED

@patch('common.djangoapps.entitlements.rest_api.v1.views.log.info')
def test_revoke_access_invalid_uuid(self, mock_log):
url = reverse(self.REVOKE_VERIFIED_ACCESS_PATH)
entitlement_uuids = [str(uuid4())]
response = self.client.post(
url,
data={
"entitlement_uuids": entitlement_uuids,
"lms_user_id": self.user.id
},
content_type='application/json',
)

mock_log.assert_called_once_with("B2C_SUBSCRIPTIONS: Entitlements not found for the provided"
" entitlements data: %s and user: %s",
entitlement_uuids,
self.user.id)
assert response.status_code == 204

def test_revoke_access_unauthorized_user(self):
user = UserFactory(is_staff=True, username='not_subscriptions_worker')
self.client.login(username=user.username, password=TEST_PASSWORD)

enrollment = CourseEnrollmentFactory.create(
user=self.user,
course_id=self.course.id, # pylint: disable=no-member
is_active=True,
mode=CourseMode.VERIFIED
)
course_entitlement = CourseEntitlementFactory.create(user=self.user, enrollment_course_run=enrollment)
url = reverse(self.REVOKE_VERIFIED_ACCESS_PATH)

assert course_entitlement.enrollment_course_run is not None

response = self.client.post(
url,
data={
"entitlement_uuids": [],
"lms_user_id": self.user.id
},
content_type='application/json',
)
assert response.status_code == 403

course_entitlement.refresh_from_db()
assert course_entitlement.expired_at is None
assert course_entitlement.enrollment_course_run.mode == CourseMode.VERIFIED

@patch('common.djangoapps.entitlements.tasks.retry_revoke_subscriptions_verified_access.apply_async')
@patch('common.djangoapps.entitlements.rest_api.v1.views.get_courses_completion_status')
def test_course_completion_exception_triggers_task(self, mock_get_courses_completion_status, mock_task):
mock_get_courses_completion_status.return_value = ([], True)
enrollment = CourseEnrollmentFactory.create(
user=self.user,
course_id=self.course.id, # pylint: disable=no-member
is_active=True,
mode=CourseMode.VERIFIED
)
course_entitlement = CourseEntitlementFactory.create(user=self.user, enrollment_course_run=enrollment)

url = reverse(self.REVOKE_VERIFIED_ACCESS_PATH)

response = self.client.post(
url,
data={
"entitlement_uuids": [str(course_entitlement.uuid)],
"lms_user_id": self.user.id
},
content_type='application/json',
)
assert response.status_code == 204
mock_task.assert_called_once_with(args=([str(course_entitlement.uuid)],
[str(enrollment.course_id)],
self.user.username))
Loading
Loading