-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: remove block-specific handling from runtime role checks [FC-0026] #32356
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -493,32 +493,6 @@ def inner_get_block(block): | |
| will_recheck_access=will_recheck_access, | ||
| ) | ||
|
|
||
| user_is_staff = bool(has_access(user, 'staff', block.location, course_id)) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no block-specific staff users, so passing the course_id is enough. |
||
| user_service = DjangoXBlockUserService( | ||
| user, | ||
| user_is_staff=user_is_staff, | ||
| user_role=get_user_role(user, course_id), | ||
| anonymous_user_id=anonymous_id_for_user(user, course_id), | ||
| # See the docstring of `DjangoXBlockUserService`. | ||
| deprecated_anonymous_user_id=anonymous_id_for_user(user, None), | ||
| request_country_code=user_location, | ||
| ) | ||
|
|
||
| # Rebind module service to deal with noauth modules getting attached to users | ||
| rebind_user_service = RebindUserService( | ||
| user, | ||
| course_id, | ||
| prepare_runtime_for_user, | ||
| track_function=track_function, | ||
| position=position, | ||
| wrap_xblock_display=wrap_xblock_display, | ||
| grade_bucket_type=grade_bucket_type, | ||
| static_asset_path=static_asset_path, | ||
| user_location=user_location, | ||
| request_token=request_token, | ||
| will_recheck_access=will_recheck_access, | ||
| ) | ||
|
|
||
| # Build a list of wrapping functions that will be applied in order | ||
| # to the Fragment content coming out of the xblocks that are about to be rendered. | ||
| block_wrappers = [] | ||
|
|
@@ -555,6 +529,8 @@ def inner_get_block(block): | |
| block_wrappers.append(partial(course_expiration_wrapper, user)) | ||
| block_wrappers.append(partial(offer_banner_wrapper, user)) | ||
|
|
||
| user_is_staff = bool(has_access(user, 'staff', course_id)) | ||
|
|
||
| if settings.FEATURES.get('DISPLAY_DEBUG_INFO_TO_STAFF'): | ||
| if is_masquerading_as_specific_student(user, course_id): | ||
| # When masquerading as a specific student, we want to show the debug button | ||
|
|
@@ -568,7 +544,7 @@ def inner_get_block(block): | |
| del user.real_user.masquerade_settings | ||
| user.real_user.masquerade_settings = masquerade_settings | ||
| else: | ||
| staff_access = has_access(user, 'staff', block, course_id) | ||
| staff_access = user_is_staff | ||
| if staff_access: | ||
| block_wrappers.append(partial(add_staff_markup, user, disable_staff_debug_info)) | ||
|
|
||
|
|
@@ -581,7 +557,17 @@ def inner_get_block(block): | |
| 'fs': FSService(), | ||
| 'field-data': field_data, | ||
| 'mako': mako_service, | ||
| 'user': user_service, | ||
| 'user': DjangoXBlockUserService( | ||
| user, | ||
| user_is_beta_tester=CourseBetaTesterRole(course_id).has_user(user), | ||
| user_is_staff=user_is_staff, | ||
| user_is_global_staff=bool(has_access(user, 'staff', 'global')), | ||
| user_role=get_user_role(user, course_id), | ||
| anonymous_user_id=anonymous_id_for_user(user, course_id), | ||
| # See the docstring of `DjangoXBlockUserService`. | ||
| deprecated_anonymous_user_id=anonymous_id_for_user(user, None), | ||
| request_country_code=user_location, | ||
| ), | ||
| 'verification': XBlockVerificationService(), | ||
| 'proctoring': ProctoringService(), | ||
| 'milestones': milestones_helpers.get_service(), | ||
|
|
@@ -595,10 +581,21 @@ def inner_get_block(block): | |
| 'sandbox': SandboxService(contentstore=contentstore, course_id=course_id), | ||
| 'xqueue': xqueue_service, | ||
| 'replace_urls': replace_url_service, | ||
| 'rebind_user': rebind_user_service, | ||
| 'completion': CompletionService(user=user, context_key=course_id) | ||
| if user and user.is_authenticated | ||
| else None, | ||
| # Rebind module service to deal with noauth modules getting attached to users. | ||
| 'rebind_user': RebindUserService( | ||
| user, | ||
| course_id, | ||
| prepare_runtime_for_user, | ||
| track_function=track_function, | ||
| position=position, | ||
| wrap_xblock_display=wrap_xblock_display, | ||
| grade_bucket_type=grade_bucket_type, | ||
| static_asset_path=static_asset_path, | ||
| user_location=user_location, | ||
| request_token=request_token, | ||
| will_recheck_access=will_recheck_access, | ||
| ), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved the initialization of these services directly to the |
||
| 'completion': CompletionService(user=user, context_key=course_id) if user and user.is_authenticated else None, | ||
| 'i18n': XBlockI18nService, | ||
| 'library_tools': LibraryToolsService(store, user_id=user.id if user else None), | ||
| 'partitions': PartitionService(course_id=course_id, cache=DEFAULT_REQUEST_CACHE.data), | ||
|
|
@@ -629,11 +626,6 @@ def inner_get_block(block): | |
|
|
||
| block.runtime.set('position', position) | ||
|
|
||
| block.runtime.set('user_is_staff', user_is_staff) | ||
| block.runtime.set('user_is_admin', bool(has_access(user, 'staff', 'global'))) | ||
| block.runtime.set('user_is_beta_tester', CourseBetaTesterRole(course_id).has_user(user)) | ||
| block.runtime.set('days_early_for_beta', block.days_early_for_beta) | ||
|
|
||
| return field_data | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.