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
da9c30b2
Commit
da9c30b2
authored
Jan 14, 2015
by
Stephen Sanchez
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6596 from edx/sanchez/course_role_admin_form
Improve Django Admin Panel for Admin Roles.
parents
4052c729
aed89e42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
4 deletions
+51
-4
common/djangoapps/student/admin.py
+21
-1
common/djangoapps/student/models.py
+0
-3
common/djangoapps/student/roles.py
+30
-0
No files found.
common/djangoapps/student/admin.py
View file @
da9c30b2
'''
'''
django admin pages for courseware model
django admin pages for courseware model
'''
'''
from
django
import
forms
from
config_models.admin
import
ConfigurationModelAdmin
from
config_models.admin
import
ConfigurationModelAdmin
from
student.models
import
UserProfile
,
UserTestGroup
,
CourseEnrollmentAllowed
,
DashboardConfiguration
from
student.models
import
UserProfile
,
UserTestGroup
,
CourseEnrollmentAllowed
,
DashboardConfiguration
from
student.models
import
CourseEnrollment
,
Registration
,
PendingNameChange
,
CourseAccessRole
,
CourseAccessRoleAdmin
from
student.models
import
CourseEnrollment
,
Registration
,
PendingNameChange
,
CourseAccessRole
from
ratelimitbackend
import
admin
from
ratelimitbackend
import
admin
from
student.roles
import
REGISTERED_ACCESS_ROLES
class
CourseAccessRoleForm
(
forms
.
ModelForm
):
"""Form for adding new Course Access Roles view the Django Admin Panel."""
class
Meta
:
model
=
CourseAccessRole
COURSE_ACCESS_ROLES
=
[(
role_name
,
role_name
)
for
role_name
in
REGISTERED_ACCESS_ROLES
.
keys
()]
role
=
forms
.
ChoiceField
(
choices
=
COURSE_ACCESS_ROLES
)
class
CourseAccessRoleAdmin
(
admin
.
ModelAdmin
):
"""Admin panel for the Course Access Role. """
form
=
CourseAccessRoleForm
raw_id_fields
=
(
"user"
,)
list_display
=
(
'id'
,
'user'
,
'org'
,
'course_id'
,
'role'
)
admin
.
site
.
register
(
UserProfile
)
admin
.
site
.
register
(
UserProfile
)
...
...
common/djangoapps/student/models.py
View file @
da9c30b2
...
@@ -1267,9 +1267,6 @@ class CourseAccessRole(models.Model):
...
@@ -1267,9 +1267,6 @@ class CourseAccessRole(models.Model):
return
"[CourseAccessRole] user: {} role: {} org: {} course: {}"
.
format
(
self
.
user
.
username
,
self
.
role
,
self
.
org
,
self
.
course_id
)
return
"[CourseAccessRole] user: {} role: {} org: {} course: {}"
.
format
(
self
.
user
.
username
,
self
.
role
,
self
.
org
,
self
.
course_id
)
class
CourseAccessRoleAdmin
(
admin
.
ModelAdmin
):
raw_id_fields
=
(
"user"
,)
#### Helper methods for use from python manage.py shell and other classes.
#### Helper methods for use from python manage.py shell and other classes.
...
...
common/djangoapps/student/roles.py
View file @
da9c30b2
...
@@ -6,11 +6,34 @@ adding users, removing users, and listing members
...
@@ -6,11 +6,34 @@ adding users, removing users, and listing members
from
abc
import
ABCMeta
,
abstractmethod
from
abc
import
ABCMeta
,
abstractmethod
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
import
logging
from
student.models
import
CourseAccessRole
from
student.models
import
CourseAccessRole
from
xmodule_django.models
import
CourseKeyField
from
xmodule_django.models
import
CourseKeyField
log
=
logging
.
getLogger
(
__name__
)
# A list of registered access roles.
REGISTERED_ACCESS_ROLES
=
{}
def
register_access_role
(
cls
):
"""
Decorator that allows access roles to be registered within the roles module and referenced by their
string values.
Assumes that the decorated class has a "ROLE" attribute, defining its type.
"""
try
:
role_name
=
getattr
(
cls
,
'ROLE'
)
REGISTERED_ACCESS_ROLES
[
role_name
]
=
cls
except
AttributeError
:
log
.
exception
(
u"Unable to register Access Role with attribute 'ROLE'."
)
return
cls
class
RoleCache
(
object
):
class
RoleCache
(
object
):
"""
"""
A cache of the CourseAccessRoles held by a particular user
A cache of the CourseAccessRoles held by a particular user
...
@@ -187,6 +210,7 @@ class OrgRole(RoleBase):
...
@@ -187,6 +210,7 @@ class OrgRole(RoleBase):
super
(
OrgRole
,
self
)
.
__init__
(
role
,
org
)
super
(
OrgRole
,
self
)
.
__init__
(
role
,
org
)
@register_access_role
class
CourseStaffRole
(
CourseRole
):
class
CourseStaffRole
(
CourseRole
):
"""A Staff member of a course"""
"""A Staff member of a course"""
ROLE
=
'staff'
ROLE
=
'staff'
...
@@ -195,6 +219,7 @@ class CourseStaffRole(CourseRole):
...
@@ -195,6 +219,7 @@ class CourseStaffRole(CourseRole):
super
(
CourseStaffRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
super
(
CourseStaffRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
@register_access_role
class
CourseInstructorRole
(
CourseRole
):
class
CourseInstructorRole
(
CourseRole
):
"""A course Instructor"""
"""A course Instructor"""
ROLE
=
'instructor'
ROLE
=
'instructor'
...
@@ -203,6 +228,7 @@ class CourseInstructorRole(CourseRole):
...
@@ -203,6 +228,7 @@ class CourseInstructorRole(CourseRole):
super
(
CourseInstructorRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
super
(
CourseInstructorRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
@register_access_role
class
CourseFinanceAdminRole
(
CourseRole
):
class
CourseFinanceAdminRole
(
CourseRole
):
"""A course staff member with privileges to review financial data."""
"""A course staff member with privileges to review financial data."""
ROLE
=
'finance_admin'
ROLE
=
'finance_admin'
...
@@ -211,6 +237,7 @@ class CourseFinanceAdminRole(CourseRole):
...
@@ -211,6 +237,7 @@ class CourseFinanceAdminRole(CourseRole):
super
(
CourseFinanceAdminRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
super
(
CourseFinanceAdminRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
@register_access_role
class
CourseSalesAdminRole
(
CourseRole
):
class
CourseSalesAdminRole
(
CourseRole
):
"""A course staff member with privileges to perform sales operations. """
"""A course staff member with privileges to perform sales operations. """
ROLE
=
'sales_admin'
ROLE
=
'sales_admin'
...
@@ -219,6 +246,7 @@ class CourseSalesAdminRole(CourseRole):
...
@@ -219,6 +246,7 @@ class CourseSalesAdminRole(CourseRole):
super
(
CourseSalesAdminRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
super
(
CourseSalesAdminRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
@register_access_role
class
CourseBetaTesterRole
(
CourseRole
):
class
CourseBetaTesterRole
(
CourseRole
):
"""A course Beta Tester"""
"""A course Beta Tester"""
ROLE
=
'beta_testers'
ROLE
=
'beta_testers'
...
@@ -227,6 +255,7 @@ class CourseBetaTesterRole(CourseRole):
...
@@ -227,6 +255,7 @@ class CourseBetaTesterRole(CourseRole):
super
(
CourseBetaTesterRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
super
(
CourseBetaTesterRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
@register_access_role
class
LibraryUserRole
(
CourseRole
):
class
LibraryUserRole
(
CourseRole
):
"""
"""
A user who can view a library and import content from it, but not edit it.
A user who can view a library and import content from it, but not edit it.
...
@@ -261,6 +290,7 @@ class OrgLibraryUserRole(OrgRole):
...
@@ -261,6 +290,7 @@ class OrgLibraryUserRole(OrgRole):
super
(
OrgLibraryUserRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
super
(
OrgLibraryUserRole
,
self
)
.
__init__
(
self
.
ROLE
,
*
args
,
**
kwargs
)
@register_access_role
class
CourseCreatorRole
(
RoleBase
):
class
CourseCreatorRole
(
RoleBase
):
"""
"""
This is the group of people who have permission to create new courses (we may want to eventually
This is the group of people who have permission to create new courses (we may want to eventually
...
...
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