Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
3babf539
Commit
3babf539
authored
11 years ago
by
cahrens
Browse files
Options
Downloads
Patches
Plain Diff
Handle the case of script being terminated before the user was deleted.
parent
42f71156
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cms/djangoapps/contentstore/management/commands/populate_creators.py
+12
-2
12 additions, 2 deletions
...pps/contentstore/management/commands/populate_creators.py
with
12 additions
and
2 deletions
cms/djangoapps/contentstore/management/commands/populate_creators.py
+
12
−
2
View file @
3babf539
...
...
@@ -2,13 +2,23 @@ from auth.authz import _grant_instructors_creator_access
from
django.core.management.base
import
BaseCommand
from
django.contrib.auth.models
import
User
from
django.db.utils
import
IntegrityError
class
Command
(
BaseCommand
):
help
=
'
Grants all users with INSTRUCTOR role permission to create courses
'
def
handle
(
self
,
*
args
,
**
options
):
admin
=
User
.
objects
.
create_user
(
'
populate_creators_command
'
,
'
grant+creator+access@edx.org
'
,
'
foo
'
)
admin
.
is_staff
=
True
username
=
'
populate_creators_command
'
email
=
'
grant+creator+access@edx.org
'
try
:
admin
=
User
.
objects
.
create_user
(
username
,
email
,
'
foo
'
)
admin
.
is_staff
=
True
admin
.
save
()
except
IntegrityError
:
# If the script did not complete the last time it was run,
# the admin user will already exist.
admin
=
User
.
objects
.
get
(
username
=
username
,
email
=
email
)
_grant_instructors_creator_access
(
admin
)
admin
.
delete
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment