Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
88eab7e
build: This is Lilac
Apr 9, 2021
c802acf
build: Transifex projects for Lilac
Apr 9, 2021
2803f5f
fix: extra ")}" in 500 error page
regisb Apr 13, 2021
eb1ed92
xss security fixes
Ali-D-Akbar Apr 19, 2021
eb2e9ac
fix: AA-646: Fix is_staff_user check to check for course staff
Dillon-Dumesnil Apr 23, 2021
419c971
build: no need for this hackathon testing plugin
Apr 21, 2021
bfef207
Merge pull request #27402 from edx/ddumesnil/enable-dates-tab-aa-741
Dillon-Dumesnil Apr 26, 2021
31e2d3d
Merge pull request #27407 from edx/ddumesnil/fix-staff-access-aa-646-…
Dillon-Dumesnil Apr 26, 2021
7ad8d87
chore: upgrade Django to 2.2.21
nedbat May 4, 2021
8d223e0
chore: upgrade django-debug-toolbar to 3.2.1
nedbat May 4, 2021
3fe6e3d
chore: upgrade Django to 2.2.22
nedbat May 6, 2021
84bb9be
fix: django 2.2.21 caused a problem
nedbat May 7, 2021
2b7aa0b
fix: only show 'View in New Exp.' to global staff if MFE preview enab…
kdmccormick May 10, 2021
cdbea83
fix: Import missing function in server_error template.
morenol Apr 14, 2021
c9ddbd6
chore: upgrade Django to 2.2.23
nedbat May 13, 2021
ddd5ec3
refactor!: Enable Account MFE globally.
ericfab179 May 13, 2021
ad810e0
[SE-4101] fix: address VisibleBlocks caching race condition (#27359)
gabor-boros May 5, 2021
4de22fa
Merge pull request #27623 from eduNEXT/eric/enable_account_mfe_global…
robrap May 18, 2021
e6e4919
chore: upgrade Django to 2.2.24
nedbat Jun 2, 2021
1924851
feat: add Course Membership API
Jun 3, 2021
76b5884
feat: update lti XBlock to 2.9.1 to get Advantage
nedbat Jun 3, 2021
d92ad71
fix: Convert block_structure.data to relative paths (TNL-8335)
Jun 3, 2021
335ab58
fix: Hide enterprise/login button if enterprise integration disabled.…
cmltaWt0 Jun 7, 2021
b3c98d8
chore: updated translations
Jun 8, 2021
16b6d2e
fix: mishandled xss change
Ali-D-Akbar Jun 21, 2021
c79e64a
fix: Produce grade report when subsections have future start dates
May 5, 2021
6aa09de
Revert "perf: avoid invoking codejail for problem response report" (#…
Jul 16, 2021
ed9f6c4
Merge pull request #28066 from edx/feanil/arch-1821-alternative
feanil Jul 1, 2021
60cd1d1
fix: Passwored reset page throwing page not found error (#28204)
farhaanbukhsh Jul 23, 2021
d607785
feat: Add token which disables different origin subframe dialog suppr…
Jul 27, 2021
0b9f9f8
chore: Bump version of django-wiki to 1.0.2.
Jul 30, 2021
5d78650
build: add edx-community-bot workflow
stvstnfrd Jul 28, 2021
1400354
fix(ci): move github workflow to correct location
stvstnfrd Aug 2, 2021
f05b9b0
merge(#28363): cherry-pick edx-community-bot commits
stvstnfrd Aug 2, 2021
762b759
feat: redirect to 'contact' page if zendesk url is not defined
Jun 21, 2021
20447e5
merge(#28300): feat: redirect to 'contact' page if zendesk url is not…
Aug 3, 2021
f1e2d96
Fix discussion XSS issue
awaisdar001 Aug 3, 2021
d1d45b9
merge(#28038): fix: Produce grade report when subsections have future…
Aug 4, 2021
b509663
merge(#28250): FAL-2076 Cherry-picks #28066 into lilac.master
Aug 4, 2021
11e1b80
feat: Implements a feature flag to disable unenrollment for all courses
Oct 8, 2021
f81c870
fix: improvements on disable un-enrollment feature
Oct 11, 2021
661a702
fix: feature improvments
Oct 26, 2021
2f39c79
fix: added feature flag variable to cms
Oct 26, 2021
728eaf1
fix: disable unenrollment regardless of unfulfilled_entitlement or pa…
0x29a Oct 27, 2021
374a313
fix: typos
0x29a Oct 27, 2021
89f5260
style: fix indentation
0x29a Oct 28, 2021
b6b740d
fix: hide gear icon and dropdown if there is no action items
0x29a Oct 28, 2021
1a21824
Merge pull request #429 from open-craft/tinumide/lilac_disable_unenro…
0x29a Oct 31, 2021
d9822e3
feat: add CCX ID to generated filename prefixes (#27028) (#438)
gabor-boros Nov 8, 2021
de4fc0d
[SE-4891] Cherry pick: feat: add `optional-exposed` extra field type …
gabor-boros Nov 15, 2021
362427b
feat: implement a login redirect middleware
Cup0fCoffee Nov 5, 2021
8b46e7f
Merge pull request #439 from open-craft/maxim/bb-5090-login-redirect-…
Cup0fCoffee Nov 15, 2021
c8713a5
feat: update enrollment serializer and add problem submission history…
xirdneh Jul 3, 2019
1c797fa
Add ar-sa locale (#309)
viadanna Feb 2, 2021
f126cee
Use PR branch for xblock-lti-consumer
pkulkark Mar 25, 2021
709e1b4
Remove priority from static main tabs to make tab sorting function wo…
Arti3DPlayer Apr 12, 2021
f5343d6
Merge pull request #358 from open-craft/shimulch/bb-4218-koa
giovannicimolin Jun 4, 2021
c1b158e
fix: don't cache ajax request on course details page in Studio
0x29a Jun 18, 2021
6ca5a45
[SE-4482] Allow delete course content in Studio only for admin users …
Jun 27, 2021
8ece59c
merge(#28147): [SE-4304] feat: add celery beat configuration to Lilac
Oct 13, 2021
a497199
feat: add custom task kwargs
gabor-boros Jun 8, 2021
cdf4463
feat: Add REST endpoints for problem response report generation that …
xitij2000 May 6, 2021
6f67762
fix: koa compatible version 2.4 for lti-consumer-xblock (#383)
Aug 9, 2021
8b54e49
fix: update lti-consumer-xblock to new commit (#384)
pkulkark Aug 9, 2021
3fc71ed
Merge pull request #28442 from edx/saad/backport-TNL-8593-celery-xxe-…
saadyousafarbi Aug 11, 2021
6a905c7
Merge pull request #27197 from open-craft/arjun/bb-3954-enrollment-be…
mikix Aug 19, 2021
bd0e576
Merge pull request #387 from open-craft/mtyaka/FAL-2248-monkey-patch-…
mtyaka Aug 23, 2021
9371572
fix: xblock-poll's celery tasks were not registered (#28019)
bradenmacdonald Jun 30, 2021
9f4cd52
Fix RTL issue with capa problems (#28562)
mtyaka Sep 21, 2021
7460a2b
Merge pull request #396 from open-craft/mtyaka/FAL-2358-update-arabic…
mtyaka Sep 6, 2021
b5f4a68
Merge pull request #28486 from open-craft/shimulch/fix-duplicate-arab…
sarina Aug 25, 2021
e304527
feat: options for excluding courses from search
ha-D Aug 20, 2021
1fd0760
fix: update lti-consumer-xblock to 2.10.1 (#400)
nizarmah Sep 16, 2021
6f814bb
feat: adds CELERY_BROKER_TRANSPORT_OPTIONS
pomegranited Jun 23, 2021
2093b30
feat: Add course-wide custom scripts
ha-D Aug 5, 2021
5d75cd8
fix: display right-to-left for rtl-languages in mobile (#28861)
meysam81 Oct 18, 2021
6eb46c1
Add progress_video event and update tests (#25038)
toxinu Oct 1, 2020
b729010
Merge pull request #25045 from open-craft/gabor/expose-banner-image-url
Nov 17, 2020
8126758
Django app to allow user retirement via API (#25800)
pkulkark Dec 8, 2020
7b950e1
Updates tpa email association waffle switch to support edx-toggles=1.1.1
nizarmah Feb 9, 2021
8ca8b60
Unhide student-generated certificates toggle
samuelallan72 Apr 16, 2020
8f07458
Add missing context platform_name and contact_mailing_address. And pa…
Mar 28, 2021
e3bd31b
fix: change buttons in wiki modal to anchor tags
arjunsinghy96 Jun 28, 2021
be337a6
fix: update rebased code to work on lilac
xitij2000 Nov 11, 2021
3db5513
Fix: Allow delete course content in Studio only for admin users (#440)
joidegn Nov 17, 2021
af2d27b
feat: add site language config
Sep 13, 2017
b773024
Merge pull request #436 from open-craft/alfred/code-drift-lilac.2-rel…
xitij2000 Nov 22, 2021
d8fcf11
feat: Change studio schedule datetime inputs to user timezone
kaustavb12 Dec 21, 2021
406b0ab
Merge pull request #444 from open-craft/kaustav/change_studio_fronten…
Cup0fCoffee Dec 31, 2021
d455319
fix: Apply XSS patch for LMS logout page
pkulkark Jan 12, 2022
cf0a785
fix: Security patch for email search
pkulkark Jan 12, 2022
9082c69
Merge pull request #448 from open-craft/pooja/apply-xss-patch-lilac
pkulkark Jan 12, 2022
c684ff4
[SE-4473] Implement progress bar (#431)
pkulkark Dec 13, 2021
9182430
ADD esme custom css as separate file
pedrovgp Sep 20, 2021
061e131
ADD html snippets from esme
pedrovgp Sep 13, 2021
31a17db
REMOVE default files (snippets)
pedrovgp Sep 14, 2021
a8adccd
feat: add `optional-exposed` extra field type to registration form
gabor-boros Nov 12, 2021
fa11216
[SE-5281] Fixes grade report task parent dir not being used.
keithgg Jan 27, 2022
feeed07
[SE-5135] Updated HTML templates to the v2 counterparts.
keithgg Jan 20, 2022
c405cca
[SE-5135] Fixed optional reading and downloads content
keithgg Jan 24, 2022
f14e484
feat: Make course description editable in Certs
pkulkark Feb 1, 2022
dcae674
fix: Convert compliance warning back to html (#465)
pkulkark Mar 31, 2022
a78b97b
feat: added new setting CUSTOM_RESOURCE_TEMPLATES_DIRECTORY
keithgg Mar 23, 2022
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
67 changes: 67 additions & 0 deletions .github/workflows/pr-automerge-open-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For non-draft changes to Named Release branches:
# - Check if the user belongs to a maintainers team.
# - If so, approve the pull request.
# - Tag community-engineering (for now) and the maintainers team.
# - Merge the PR when the author comments `@edx-community-bot merge`.
# Required organization secrets
# - CC_GITHUB_TOKEN=...
# - CC_TEAM_CHAMPIONS=org/team-name
# - CC_TEAM_CONTRIBUTORS_ORG=org
# - CC_TEAM_CONTRIBUTORS_TEAM=team-name
---
name: automerge BTR open-release PRs
on:
issue_comment:
branches:
- open-release/*
types:
- created
- edited
pull_request_target:
branches:
- open-release/*
types:
- opened
- edited
- ready_for_review
jobs:
automerge:
if: ${{ (github.event.issue.pull_request && !github.event.issue.pull_request.draft) || (github.event.pull_request && !github.event.pull_request.draft) }}
runs-on: ubuntu-latest
steps:
- name: lookup teams
id: teams
uses: tspascoal/get-user-teams-membership@v1
with:
username: "${{ github.actor }}"
organization: ${{ secrets.CC_TEAM_CONTRIBUTORS_ORG }}
team: ${{ secrets.CC_TEAM_CONTRIBUTORS_TEAM }}
GITHUB_TOKEN: "${{ secrets.CC_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}"
- name: approve PR
if: ${{ steps.teams.outputs.isTeamMember == 'true' && (github.event.action == 'opened' || github.event.action == 'ready_for_review') }}
uses: andrewmusgrave/automatic-pull-request-review@0.0.5
with:
repo-token: ${{ secrets.CC_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
event: APPROVE
body: |
:+1:

When you're ready to merge, add a comment that says
> @edx-community-bot merge

and we'll handle the rest!
CC: @${{ secrets.CC_TEAM_CHAMPIONS }} @${{ secrets.CC_TEAM_CONTRIBUTORS_ORG }}/${{ secrets.CC_TEAM_CONTRIBUTORS_TEAM }}
- name: label PR as auto-mergeable
if: ${{ steps.teams.outputs.isTeamMember == 'true' && contains(github.event.comment.body, '@edx-community-bot merge') }}
uses: andymckay/labeler@978f846c4ca6299fd136f465b42c5e87aca28cac
with:
add-labels: 'automerge'
repo-token: ${{ secrets.CC_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
- name: automerge
uses: "pascalgn/automerge-action@v0.13.1"
env:
GITHUB_TOKEN: "${{ secrets.CC_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}"
MERGE_COMMIT_MESSAGE: |
merge(#{pullRequest.number}): {pullRequest.title}

{pullRequest.body}
12 changes: 12 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ file_filter = conf/locale/<lang>/LC_MESSAGES/edx_proctoring_proctortrack.po
source_file = conf/locale/en/LC_MESSAGES/edx_proctoring_proctortrack.po
source_lang = en
type = PO

[open-edx-releases.release-lilac]
file_filter = conf/locale/<lang>/LC_MESSAGES/django.po
source_file = conf/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

[open-edx-releases.release-lilac-js]
file_filter = conf/locale/<lang>/LC_MESSAGES/djangojs.po
source_file = conf/locale/en/LC_MESSAGES/djangojs.po
source_lang = en
type = PO
25 changes: 25 additions & 0 deletions cms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,28 @@
# that shared_task will use this app, and also ensures that the celery
# singleton is always configured for the CMS.
from .celery import APP as CELERY_APP # lint-amnesty, pylint: disable=wrong-import-position

# FAL-2248: Monkey patch django's get_storage_engine to work around long migrations times.
# This fixes a performance issue with database migrations in Ocim. We will need to keep
# this patch in our opencraft-release/* branches until edx-platform upgrades to Django 4.*
# which will include this commit:
# https://github.com/django/django/commit/518ce7a51f994fc0585d31c4553e2072bf816f76
import django.db.backends.mysql.introspection

def get_storage_engine(self, cursor, table_name):
"""
This is a patched version of `get_storage_engine` that fixes a
performance issue with migrations. For more info see FAL-2248 and
https://github.com/django/django/pull/14766
"""
cursor.execute("""
SELECT engine
FROM information_schema.tables
WHERE table_name = %s
AND table_schema = DATABASE()""", [table_name])
result = cursor.fetchone()
if not result:
return self.connection.features._mysql_storage_engine
return result[0]

django.db.backends.mysql.introspection.DatabaseIntrospection.get_storage_engine = get_storage_engine
6 changes: 5 additions & 1 deletion cms/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
Taken from: https://celery.readthedocs.org/en/latest/django/first-steps-with-django.html
"""


import os

# Patch the xml libs before anything else.
from safe_lxml import defuse_xml_libs

defuse_xml_libs()


# Set the default Django settings module for the 'celery' program
# and then instantiate the Celery singleton.
Expand Down
12 changes: 12 additions & 0 deletions cms/djangoapps/contentstore/config/waffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,15 @@ def waffle_flags():
flag_name='library_authoring_mfe',
module_name=__name__,
)

# .. toggle_name: studio.prevent_staff_structure_deletion
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Prevents staff from deleting course structures
# .. toggle_use_cases: opt_in
# .. toggle_creation_date: 2021-06-25
PREVENT_STAFF_STRUCTURE_DELETION = LegacyWaffleFlag(
waffle_flags(),
'prevent_staff_structure_deletion',
module_name=__name__,
)
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
10 changes: 10 additions & 0 deletions cms/djangoapps/contentstore/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Permission definitions for the contentstore djangoapp
"""

from bridgekeeper import perms

from lms.djangoapps.courseware.rules import HasRolesRule

DELETE_COURSE_CONTENT = 'contentstore.delete_course_content'
perms[DELETE_COURSE_CONTENT] = HasRolesRule('instructor')
2 changes: 2 additions & 0 deletions cms/djangoapps/contentstore/views/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def serialize_certificate(certificate):
# Some keys are not required, such as the title override...
if certificate_data.get('course_title'):
certificate_response["course_title"] = certificate_data['course_title']
if certificate_data.get('course_description'):
certificate_response['course_description'] = certificate_data['course_description']

return certificate_response

Expand Down
7 changes: 7 additions & 0 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
from openedx.core.djangoapps.credit.tasks import update_credit_course_requirements
from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.models import UserPreference
from openedx.core.djangolib.js_utils import dump_js_escaped_json
from openedx.core.lib.course_tabs import CourseTabPluginManager
from openedx.core.lib.courses import course_image_url
Expand Down Expand Up @@ -1203,6 +1204,12 @@ def settings_handler(request, course_key_string): # lint-amnesty, pylint: disab
elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
if request.method == 'GET':
course_details = CourseDetails.fetch(course_key)

# Fetch the prefered timezone setup by the user
# and pass it as part of Json response
user_timezone = UserPreference.get_value(request.user, 'time_zone')
course_details.user_timezone = user_timezone

return JsonResponse(
course_details,
# encoder serializes dates, old locations, and instances
Expand Down
7 changes: 6 additions & 1 deletion cms/djangoapps/contentstore/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from xblock.core import XBlock
from xblock.fields import Scope

from cms.djangoapps.contentstore.config.waffle import SHOW_REVIEW_RULES_FLAG
from cms.djangoapps.contentstore.config.waffle import PREVENT_STAFF_STRUCTURE_DELETION, SHOW_REVIEW_RULES_FLAG
from cms.djangoapps.contentstore.permissions import DELETE_COURSE_CONTENT
from cms.djangoapps.models.settings.course_grading import CourseGradingModel
from cms.djangoapps.xblock_config.models import CourseEditLTIFieldsEnabledFlag
from cms.lib.xblock.authoring_mixin import VISIBILITY_VIEW
Expand Down Expand Up @@ -1329,6 +1330,10 @@ def create_xblock_info(xblock, data=None, metadata=None, include_ancestor_info=F
else:
xblock_info['staff_only_message'] = False

xblock_info['show_delete_button'] = True
if PREVENT_STAFF_STRUCTURE_DELETION.is_enabled():
xblock_info['show_delete_button'] = user.has_perm(DELETE_COURSE_CONTENT, xblock) if user is not None else False

xblock_info['has_partition_group_components'] = has_children_visible_to_specific_partition_groups(
xblock
)
Expand Down
149 changes: 149 additions & 0 deletions cms/djangoapps/contentstore/views/tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from django.test.client import RequestFactory
from django.urls import reverse
from edx_proctoring.exceptions import ProctoredExamNotFoundException
from edx_toggles.toggles.testutils import override_waffle_switch, override_waffle_flag
from mock import Mock, PropertyMock, patch
from opaque_keys import InvalidKeyError
from opaque_keys.edx.asides import AsideUsageKeyV2
from opaque_keys.edx.keys import CourseKey, UsageKey
Expand All @@ -28,9 +30,12 @@
from xblock.test.tools import TestRuntime
from xblock.validation import ValidationMessage

from cms.djangoapps.contentstore.config.waffle import PREVENT_STAFF_STRUCTURE_DELETION
from cms.djangoapps.contentstore.tests.utils import CourseTestCase
from cms.djangoapps.contentstore.utils import reverse_course_url, reverse_usage_url
from cms.djangoapps.contentstore.views import item as item_module
from lms.djangoapps.lms_xblock.mixin import NONSENSICAL_ACCESS_RESTRICTION
from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole, CourseCreatorRole
from common.djangoapps.student.tests.factories import UserFactory
from common.djangoapps.xblock_django.models import (
XBlockConfiguration,
Expand Down Expand Up @@ -3390,3 +3395,147 @@ def test_self_paced_item_visibility_state(self, store_type):
# Check that in self paced course content has live state now
xblock_info = self._get_xblock_info(chapter.location)
self._verify_visibility_state(xblock_info, VisibilityState.live)

def test_staff_show_delete_button(self):
"""
Test delete button is *not visible* to user with CourseStaffRole
"""
# Add user as course staff
CourseStaffRole(self.course_key).add_users(self.user)

# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=self.user
)
self.assertTrue(xblock_info['show_delete_button'])

def test_staff_show_delete_button_with_waffle(self):
"""
Test delete button is *not visible* to user with CourseStaffRole and
PREVENT_STAFF_STRUCTURE_DELETION waffle set
"""
# Add user as course staff
CourseStaffRole(self.course_key).add_users(self.user)

with override_waffle_flag(PREVENT_STAFF_STRUCTURE_DELETION, active=True):
# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=self.user
)

self.assertFalse(xblock_info['show_delete_button'])

def test_no_user_show_delete_button(self):
"""
Test delete button is *visible* when user attribute is not set on
xblock. This happens with ajax requests.
"""
# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=None
)
self.assertTrue(xblock_info['show_delete_button'])

def test_no_user_show_delete_button_with_waffle(self):
"""
Test delete button is *visible* when user attribute is not set on
xblock (this happens with ajax requests) and PREVENT_STAFF_STRUCTURE_DELETION waffle set.
"""

with override_waffle_flag(PREVENT_STAFF_STRUCTURE_DELETION, active=True):
# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=None
)

self.assertFalse(xblock_info['show_delete_button'])

def test_instructor_show_delete_button(self):
"""
Test delete button is *visible* to user with CourseInstructorRole only
"""
# Add user as course instructor
CourseInstructorRole(self.course_key).add_users(self.user)

# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=self.user
)
self.assertTrue(xblock_info['show_delete_button'])

def test_instructor_show_delete_button_with_waffle(self):
"""
Test delete button is *visible* to user with CourseInstructorRole only
and PREVENT_STAFF_STRUCTURE_DELETION waffle set
"""
# Add user as course instructor
CourseInstructorRole(self.course_key).add_users(self.user)

with override_waffle_flag(PREVENT_STAFF_STRUCTURE_DELETION, active=True):
# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=self.user
)

self.assertTrue(xblock_info['show_delete_button'])

def test_creator_show_delete_button(self):
"""
Test delete button is *visible* to user with CourseInstructorRole only
"""
# Add user as course creator
CourseCreatorRole(self.course_key).add_users(self.user)

# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=self.user
)
self.assertTrue(xblock_info['show_delete_button'])

def test_creator_show_delete_button_with_waffle(self):
"""
Test delete button is *visible* to user with CourseInstructorRole only
and PREVENT_STAFF_STRUCTURE_DELETION waffle set
"""
# Add user as course creator
CourseCreatorRole(self.course_key).add_users(self.user)

with override_waffle_flag(PREVENT_STAFF_STRUCTURE_DELETION, active=True):
# Get xblock outline
xblock_info = create_xblock_info(
self.course,
include_child_info=True,
course_outline=True,
include_children_predicate=lambda xblock: not xblock.category == 'vertical',
user=self.user
)

self.assertFalse(xblock_info['show_delete_button'])
Loading