Repository navigation
[BB-3622] Restrict user create course #319
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
Merged
farhaanbukhsh
merged 10 commits into
opencraft-release/juniper.3
from
farhaan/bb-3622-restrict-user-create-course
Feb 22, 2021
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2f8331d
Add course creation condition for organisation
farhaanbukhsh 364a22d
Add tests and change the condition to check user for course creation
farhaanbukhsh 3e1019a
Add restriction to make library
farhaanbukhsh cc140ee
Add tests for library creation restriction
farhaanbukhsh ce56662
Fix quality checks
farhaanbukhsh 98f83eb
Added comments and changed the name
farhaanbukhsh fe38cf0
Added log and corrected typo
farhaanbukhsh f3b7432
Fix typos
farhaanbukhsh 44f2e09
Added refined logs
farhaanbukhsh 60a5144
Implicit concatination of string
farhaanbukhsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,15 @@ def _create_library(request): | |
| library = request.json.get('number', None) | ||
| if library is None: | ||
| library = request.json['library'] | ||
| # Allow user to create libraries only if they belong to the organization | ||
| # This flag doesn't apply to Global Staff and Superusers | ||
| if settings.FEATURES.get('RESTRICT_COURSE_CREATION_TO_ORG_ROLES', False): | ||
| has_org_permission = has_studio_write_access(request.user, None, org) | ||
| if not has_org_permission: | ||
| log.exception("User does not have the permission to create library in this organization") | ||
|
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. @farhaanbukhsh, nit: |
||
| return JsonResponseBadRequest({ | ||
| "ErrMsg": _(u"User does not have the permission to create library in this organization") | ||
|
lgp171188 marked this conversation as resolved.
|
||
| }) | ||
| store = modulestore() | ||
| with store.default_store(ModuleStoreEnum.Type.split): | ||
| new_lib = store.create_library( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.