Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
bb50402b
Commit
bb50402b
authored
Oct 10, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #850 from MITx/feature/jarv/staff-account
Adding django-admin/rake command to set the staff bit
parents
c38aec5b
bd45dbd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
common/djangoapps/student/management/commands/set_staff.py
+37
-0
rakefile
+6
-0
No files found.
common/djangoapps/student/management/commands/set_staff.py
0 → 100644
View file @
bb50402b
from
django.contrib.auth.models
import
User
from
django.core.management.base
import
BaseCommand
,
CommandError
import
re
class
Command
(
BaseCommand
):
args
=
'<user/email user/email ...>'
help
=
"""
This command will set isstaff to true for one or more users.
Lookup by username or email address, assumes usernames
do not look like email addresses.
"""
def
handle
(
self
,
*
args
,
**
kwargs
):
if
len
(
args
)
<
1
:
print
Command
.
help
return
for
user
in
args
:
if
re
.
match
(
'[^@]+@[^@]+
\
.[^@]+'
,
user
):
try
:
v
=
User
.
objects
.
get
(
email
=
user
)
except
:
raise
CommandError
(
"User {0} does not exist"
.
format
(
user
))
else
:
try
:
v
=
User
.
objects
.
get
(
username
=
user
)
except
:
raise
CommandError
(
"User {0} does not exist"
.
format
(
user
))
v
.
is_staff
=
True
v
.
save
()
rakefile
View file @
bb50402b
...
...
@@ -171,6 +171,12 @@ task "django-admin", [:action, :system, :env, :options] => [:predjango] do |t, a
sh
(
django_admin
(
args
.
system
,
args
.
env
,
args
.
action
,
args
.
options
))
end
desc
"Set the staff bit for a user"
task
:set_staff
,
[
:user
,
:system
,
:env
]
do
|
t
,
args
|
args
.
with_defaults
(
:env
=>
'dev'
,
:system
=>
'lms'
,
:options
=>
''
)
sh
(
django_admin
(
args
.
system
,
args
.
env
,
'set_staff'
,
args
.
user
))
end
task
:package
do
FileUtils
.
mkdir_p
(
BUILD_DIR
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment