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
5e8e3353
Commit
5e8e3353
authored
Jul 08, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pylint/pep8 cleanup.
parent
2cceda94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
cms/djangoapps/course_creators/admin.py
+4
-0
cms/djangoapps/course_creators/views.py
+32
-5
No files found.
cms/djangoapps/course_creators/admin.py
View file @
5e8e3353
...
...
@@ -7,6 +7,10 @@ from django.contrib import admin
class
CourseCreatorAdmin
(
admin
.
ModelAdmin
):
"""
Admin for the course creator table.
"""
# Fields to display on the overview page.
list_display
=
(
'username'
,
'email'
,
'state'
,
'state_changed'
)
readonly_fields
=
(
'username'
,
'email'
,
'state_changed'
)
...
...
cms/djangoapps/course_creators/views.py
View file @
5e8e3353
...
...
@@ -2,26 +2,53 @@
Methods for interacting programmatically with the user creator table.
"""
from
course_creators.models
import
CourseCreator
from
django.core.exceptions
import
PermissionDenied
from
auth.authz
import
add_user_to_creator_group
def
add_user_with_status_unrequested
(
user
):
def
add_user_with_status_unrequested
(
caller
,
user
):
"""
Adds a user to the course creator table with status 'unrequested'.
Caller must have staff permissions.
"""
_add_user
(
user
,
'u'
)
_add_user
(
caller
,
user
,
'u'
)
def
add_user_with_status_granted
(
user
):
def
add_user_with_status_granted
(
caller
,
user
):
"""
Adds a user to the course creator table with status 'granted'.
Caller must have staff permissions. This method also adds the user
to the course creator group maintained by authz.py.
"""
_add_user
(
user
,
'g'
)
_add_user
(
caller
,
user
,
'g'
)
add_user_to_creator_group
(
caller
,
user
)
def
_add_user
(
user
,
state
):
def
get_course_creator_status
(
user
):
"""
Returns the status for a particular user.
Possible return values are:
'g' = 'granted'
'u' = 'unrequested'
'p' = 'pending'
'd' = 'denied'
"""
user
=
CourseCreator
.
objects
.
filter
(
username
=
user
.
username
)
assert
user
.
count
()
==
1
,
"The user does not exist in the table."
return
user
[
0
]
.
state
def
_add_user
(
caller
,
user
,
state
):
"""
Adds a user to the course creator table with the specified state.
"""
if
not
caller
.
is_active
or
not
caller
.
is_authenticated
or
not
caller
.
is_staff
:
raise
PermissionDenied
if
CourseCreator
.
objects
.
filter
(
username
=
user
.
username
)
.
count
()
==
0
:
entry
=
CourseCreator
(
username
=
user
.
username
,
email
=
user
.
email
,
state
=
state
)
entry
.
save
()
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