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

Eri/rebase mango master #780

Open
wants to merge 38 commits into
base: cag/temporary-ceibal
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7686014
fix: Add security fix in LMS logout redirect_url.
attiyaIshaque Jan 4, 2022
d17451c
fix: updated the unit tests workflow to use labeled runners
timmc-edx Mar 29, 2022
d1afd47
build: update mongo server up command in unit tests CI
timmc-edx Mar 29, 2022
9098965
Merge pull request #30147 from openedx/timmc/fix-mongo-ci
timmc-edx Mar 29, 2022
7e37238
feat: Allow REST_FRAMEWORK to be configured by (shallow) merge (#30142)
timmc-edx Mar 29, 2022
e2b863d
feat: Add monitoring for full IP chain's length (#30090, #30106)
timmc-edx Mar 18, 2022
5ebdee4
chore: Disable lint check on a line that the linter is OK with on master
timmc-edx Mar 30, 2022
99bcdb6
Merge pull request #30148 from openedx/timmc/backport-xff-metrics
timmc-edx Mar 30, 2022
cd7b45d
fix: verify redirect in inactive_user_view (#30220)
Apr 8, 2022
b8e31d4
chore: upgrade Django to 3.2.13
nedbat Apr 11, 2022
ab7aba5
fix: Make SAMLConfiguration viewset readonly (#30260)
timmc-edx Apr 15, 2022
c5eec53
test: Ignore Waffle table in query count assertions
timmc-edx Apr 20, 2022
43a0277
feat!: Use more-trusted IP in rate-limiting
timmc-edx Apr 20, 2022
2bbf06e
build: the Django matrix needs to use the pinned version also.
Feb 8, 2022
abe5c63
fixup! feat: options for excluding courses from search
ha-D Aug 26, 2021
df63cbb
fix: import+export management commands
alex2bender Jul 19, 2021
36b0a19
feat: Implement feature flag to disable students un-enrollment (#29326)
0x29a Apr 22, 2022
18a7473
fix: cross-site scripting vulnerability on logout page (#30545)
waheedahmed Jun 6, 2022
b5e8532
fix: Upgrade npm package @edx/studio-frontend to ^1.19.1 to fix missi…
uetuluk Jun 7, 2022
257c54d
refactor: [BB-6077] allow setting celery backend in yml
navinkarkera Apr 13, 2022
3cf7e10
Merge pull request #30246 from open-craft/navin/fix-celery-backend-maple
giovannicimolin Jun 15, 2022
110dfac
Merge pull request #30373 from open-craft/pooja/se-4682-maple-backport
mtyaka Jun 30, 2022
b46cc14
feat: Open edX Filters backport
mariajgrimaldi Feb 17, 2022
1968afa
chore: update openedx-filters to latest release
mariajgrimaldi Jun 14, 2022
4b1d36b
feat: add course unenrollment filter before unenrollment starts
mariajgrimaldi Feb 16, 2022
9bea3db
feat: add first batch of Open edX Filters
mariajgrimaldi Nov 26, 2021
7c51bcd
style: fix pylint errors
Alec4r Jul 8, 2022
68e9abc
Merge pull request #661 from eduNEXT/feat/backport-filters
Alec4r Jul 14, 2022
2476ed8
Merge pull request #659 from eduNEXT/MJG/restriction-filters
mariajgrimaldi Jun 24, 2022
42f55a6
Merge pull request #665 from eduNEXT/JDB/backport_catalog/homepage_fi…
JuanDavidBuitrago Sep 6, 2022
826016a
perf: add lru_cache to improve performance with multiple themes
Alec4r Oct 4, 2022
4c08d69
fix: update xblock-drag-and-drop for a high level security alert
Ian2012 Nov 26, 2022
91fe287
chore: compiled dependencies
Ian2012 Nov 30, 2022
eec8871
Merge pull request #705 from eduNEXT/cag/security-patch-drag-and-drop…
Dec 5, 2022
5c65a71
feat: Add GA 4 support to edX platform (#762)
MaferMazu Jul 18, 2023
6711d7b
feat: add custom field on register form
Henrrypg Nov 7, 2022
35053e7
fix: fix course requirements issue with proxy class
mariajgrimaldi Jan 14, 2021
a928a8d
fix: adding TypeError to compare scores function
DeimerM May 23, 2023
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
22 changes: 17 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ on:

jobs:
run-tests:
runs-on: [ self-hosted ]
runs-on: [ edx-platform-runner ]
strategy:
matrix:
python-version: ['3.8']
django-version: ["3.2"]
django-version:
- "pinned"
#- "4.0"
shard_name: [
"lms-1",
"lms-2",
Expand All @@ -35,9 +37,11 @@ jobs:
- name: sync directory owner
run: sudo chown runner:runner -R .*
- uses: actions/checkout@v2
- name: start mongodb service
- name: start mongod server for tests
run: |
sudo /etc/init.d/mongodb start
sudo mkdir -p /data/db
sudo chmod -R a+rw /data/db
mongod &

- name: set top-level module name
run: |
Expand All @@ -55,7 +59,15 @@ jobs:
run: |
sudo pip install -r requirements/pip.txt
sudo pip install -r requirements/edx/testing.txt
sudo pip install "django~=${{ matrix.django-version }}.0"
if [[ "${{ matrix.django-version }}" == "pinned" ]]; then
sudo pip install -r requirements/edx/django.txt
else
sudo pip install "django~=${{ matrix.django-version }}.0"
fi

- name: list installed package versions
run: |
sudo pip freeze

- name: get unit tests for shard
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-gha-unit-tests-count.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
collect-and-verify:
runs-on: [ self-hosted ]
runs-on: [ edx-platform-runner ]
steps:
- name: sync directory owner
run: sudo chown runner:runner -R .*
Expand Down
2 changes: 2 additions & 0 deletions cms/djangoapps/contentstore/courseware_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ class CourseAboutSearchIndexer(CoursewareSearchIndexer):
AboutInfo("org", AboutInfo.PROPERTY, AboutInfo.FROM_COURSE_PROPERTY),
AboutInfo("modes", AboutInfo.PROPERTY, AboutInfo.FROM_COURSE_MODE),
AboutInfo("language", AboutInfo.PROPERTY, AboutInfo.FROM_COURSE_PROPERTY),
AboutInfo("invitation_only", AboutInfo.PROPERTY, AboutInfo.FROM_COURSE_PROPERTY),
AboutInfo("catalog_visibility", AboutInfo.PROPERTY, AboutInfo.FROM_COURSE_PROPERTY),
]

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ def handle(self, *args, **options):
filename = prefix + suffix
target = os.path.join(dest_path, filename)
tarball.file.seek(0)
with open(target, 'w') as f:
with open(target, 'wb') as f:
shutil.copyfileobj(tarball.file, f)
print(f'Library "{library.location.library_key}" exported to "{target}"')
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def handle(self, *args, **options):
username = options['owner_username']

data_root = Path(settings.GITHUB_REPO_ROOT)
subdir = base64.urlsafe_b64encode(os.path.basename(archive_path))
subdir = base64.urlsafe_b64encode(os.path.basename(archive_path).encode('utf-8')).decode('utf-8')
course_dir = data_root / subdir

# Extract library archive
tar_file = tarfile.open(archive_path) # lint-amnesty, pylint: disable=consider-using-with
try:
safetar_extractall(tar_file, course_dir.encode('utf-8'))
safetar_extractall(tar_file, course_dir)
except SuspiciousOperation as exc:
raise CommandError(f'\n=== Course import {archive_path}: Unsafe tar file - {exc.args[0]}\n') # lint-amnesty, pylint: disable=raise-missing-from
finally:
Expand Down
12 changes: 12 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,18 @@
# .. toggle_target_removal_date: 2021-10-01
# .. toggle_tickets: 'https://openedx.atlassian.net/browse/MICROBA-1405'
'ENABLE_V2_CERT_DISPLAY_SETTINGS': False,

# .. toggle_name: FEATURES['DISABLE_UNENROLLMENT']
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_description: Set to True to disable self-unenrollments via REST API.
# This also hides the "Unenroll" button on the Learner Dashboard.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2021-10-11
# .. toggle_warnings: For consistency in user experience, keep the value in sync with the setting of the same name
# in the LMS and CMS.
# .. toggle_tickets: 'https://github.com/open-craft/edx-platform/pull/429'
'DISABLE_UNENROLLMENT': False,
}

ENABLE_JASMINE = False
Expand Down
4 changes: 4 additions & 0 deletions cms/envs/devstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,7 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing

# Don't form the return redirect URL with HTTPS on devstack
SOCIAL_AUTH_REDIRECT_IS_HTTPS = False

#################### Network configuration ####################
# Devstack is directly exposed to the caller
CLOSEST_CLIENT_IP_FROM_HEADERS = []
8 changes: 6 additions & 2 deletions cms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def get_env_setting(setting):
'CELERY_QUEUES',
'MKTG_URL_LINK_MAP',
'MKTG_URL_OVERRIDES',
'REST_FRAMEWORK',
]
for key in KEYS_WITH_MERGED_VALUES:
if key in __config_copy__:
Expand All @@ -100,8 +101,8 @@ def get_env_setting(setting):
BROKER_POOL_LIMIT = 0
BROKER_CONNECTION_TIMEOUT = 1

# For the Result Store, use the django cache named 'celery'
CELERY_RESULT_BACKEND = 'django-cache'
# Allow env to configure celery result backend with default set to django-cache
CELERY_RESULT_BACKEND = ENV_TOKENS.get('CELERY_RESULT_BACKEND', 'django-cache')

# When the broker is behind an ELB, use a heartbeat to refresh the
# connection and to detect if it has been dropped.
Expand Down Expand Up @@ -602,3 +603,6 @@ def get_env_setting(setting):
SHOW_ACCOUNT_ACTIVATION_CTA = ENV_TOKENS.get('SHOW_ACCOUNT_ACTIVATION_CTA', SHOW_ACCOUNT_ACTIVATION_CTA)

LANGUAGE_COOKIE_NAME = ENV_TOKENS.get('LANGUAGE_COOKIE', None) or ENV_TOKENS.get('LANGUAGE_COOKIE_NAME')

############## DRF overrides ##############
REST_FRAMEWORK.update(ENV_TOKENS.get('REST_FRAMEWORK', {}))
4 changes: 4 additions & 0 deletions cms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,7 @@

############### Settings for proctoring ###############
PROCTORING_USER_OBFUSCATION_KEY = 'test_key'

#################### Network configuration ####################
# Tests are not behind any proxies
CLOSEST_CLIENT_IP_FROM_HEADERS = []
24 changes: 24 additions & 0 deletions common/djangoapps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
COURSE_ENROLLMENT_CREATED,
COURSE_UNENROLLMENT_COMPLETED,
)
from openedx_filters.learning.filters import CourseEnrollmentStarted, CourseUnenrollmentStarted
import openedx.core.djangoapps.django_comment_common.comment_client as cc
from common.djangoapps.course_modes.models import CourseMode, get_cosmetic_verified_display_price
from common.djangoapps.student.emails import send_proctoring_requirements_email
Expand Down Expand Up @@ -1113,6 +1114,14 @@ class AlreadyEnrolledError(CourseEnrollmentException):
pass


class EnrollmentNotAllowed(CourseEnrollmentException):
pass


class UnenrollmentNotAllowed(CourseEnrollmentException):
pass


class CourseEnrollmentManager(models.Manager):
"""
Custom manager for CourseEnrollment with Table-level filter methods.
Expand Down Expand Up @@ -1623,6 +1632,13 @@ def enroll(cls, user, course_key, mode=None, check_access=False, can_upgrade=Fal

Also emits relevant events for analytics purposes.
"""
try:
user, course_key, mode = CourseEnrollmentStarted.run_filter(
user=user, course_key=course_key, mode=mode,
)
except CourseEnrollmentStarted.PreventEnrollment as exc:
raise EnrollmentNotAllowed(str(exc)) from exc

if mode is None:
mode = _default_course_mode(str(course_key))
# All the server-side checks for whether a user is allowed to enroll.
Expand Down Expand Up @@ -1751,6 +1767,14 @@ def unenroll(cls, user, course_id, skip_refund=False):

try:
record = cls.objects.get(user=user, course_id=course_id)

try:
# .. filter_implemented_name: CourseUnenrollmentStarted
# .. filter_type: org.openedx.learning.course.unenrollment.started.v1
record = CourseUnenrollmentStarted.run_filter(enrollment=record)
except CourseUnenrollmentStarted.PreventUnenrollment as exc:
raise UnenrollmentNotAllowed(str(exc)) from exc

record.update_enrollment(is_active=False, skip_refund=skip_refund)

except cls.DoesNotExist:
Expand Down
16 changes: 16 additions & 0 deletions common/djangoapps/student/tests/test_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,22 @@ def test_with_invalid_course_id(self):
resp = self._change_enrollment('unenroll', course_id="edx/")
assert resp.status_code == 400

@patch.dict(settings.FEATURES, {'DISABLE_UNENROLLMENT': True})
def test_unenroll_when_unenrollment_disabled(self):
"""
Tests that a user cannot unenroll when unenrollment has been disabled.
"""
# Enroll the student in the course
CourseEnrollment.enroll(self.user, self.course.id, mode="honor")

# Attempt to unenroll
resp = self._change_enrollment('unenroll')
assert resp.status_code == 400

# Verify that user is still enrolled
is_enrolled = CourseEnrollment.is_enrolled(self.user, self.course.id)
assert is_enrolled

def test_enrollment_limit(self):
"""
Assert that in a course with max student limit set to 1, we can enroll staff and instructor along with
Expand Down
Loading
Loading