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
2970f242
Commit
2970f242
authored
Jul 03, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial admin table view.
parent
72999e84
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
10 deletions
+92
-10
cms/djangoapps/auth/authz.py
+4
-0
cms/djangoapps/course_creators/admin.py
+22
-0
cms/djangoapps/course_creators/migrations/0001_initial.py
+7
-7
cms/djangoapps/course_creators/models.py
+29
-1
cms/djangoapps/course_creators/views.py
+21
-0
cms/envs/common.py
+3
-0
cms/urls.py
+6
-2
No files found.
cms/djangoapps/auth/authz.py
View file @
2970f242
...
...
@@ -3,6 +3,7 @@ from django.core.exceptions import PermissionDenied
from
django.conf
import
settings
from
xmodule.modulestore
import
Location
from
course_creators
import
views
'''
This code is somewhat duplicative of access.py in the LMS. We will unify the code as a separate story
...
...
@@ -221,3 +222,6 @@ def _grant_instructors_creator_access(caller):
if
group
.
name
.
startswith
(
INSTRUCTOR_ROLE_NAME
+
"_"
):
for
user
in
group
.
user_set
.
all
():
add_user_to_creator_group
(
caller
,
user
)
views
.
add_user_with_status_granted
(
user
)
elif
group
.
name
.
startswith
(
STAFF_ROLE_NAME
+
"_"
):
views
.
add_user_with_status_unrequested
(
user
)
cms/djangoapps/course_creators/admin.py
0 → 100644
View file @
2970f242
"""
django admin page for the course creators table
"""
from
course_creators.models
import
CourseCreator
from
django.contrib
import
admin
class
CourseCreatorAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'username'
,
'state'
,
'state_changed'
,
'note'
)
def
has_add_permission
(
self
,
request
):
return
False
def
has_delete_permission
(
self
,
request
,
obj
=
None
):
return
False
def
has_change_permission
(
self
,
request
,
obj
=
None
):
return
request
.
user
.
is_staff
admin
.
site
.
register
(
CourseCreator
,
CourseCreatorAdmin
)
cms/djangoapps/course_creators/migrations/0001_initial.py
View file @
2970f242
...
...
@@ -8,24 +8,24 @@ from django.db import models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding model 'CourseCreator
s
'
db
.
create_table
(
'course_creators_coursecreator
s
'
,
(
# Adding model 'CourseCreator'
db
.
create_table
(
'course_creators_coursecreator'
,
(
(
'username'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
unique
=
True
,
max_length
=
64
,
primary_key
=
True
)),
(
'state_changed'
,
self
.
gf
(
'django.db.models.fields.DateTimeField'
)(
auto_now_add
=
True
,
blank
=
True
)),
(
'state'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'u'
,
max_length
=
1
)),
(
'note'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
512
,
blank
=
True
)),
))
db
.
send_create_signal
(
'course_creators'
,
[
'CourseCreator
s
'
])
db
.
send_create_signal
(
'course_creators'
,
[
'CourseCreator'
])
def
backwards
(
self
,
orm
):
# Deleting model 'CourseCreator
s
'
db
.
delete_table
(
'course_creators_coursecreator
s
'
)
# Deleting model 'CourseCreator'
db
.
delete_table
(
'course_creators_coursecreator'
)
models
=
{
'course_creators.coursecreator
s
'
:
{
'Meta'
:
{
'object_name'
:
'CourseCreator
s
'
},
'course_creators.coursecreator'
:
{
'Meta'
:
{
'object_name'
:
'CourseCreator'
},
'note'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'512'
,
'blank'
:
'True'
}),
'state'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'u'"
,
'max_length'
:
'1'
}),
'state_changed'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'auto_now_add'
:
'True'
,
'blank'
:
'True'
}),
...
...
cms/djangoapps/course_creators/models.py
View file @
2970f242
...
...
@@ -2,9 +2,14 @@
Table for storing information about whether or not Studio users have course creation privileges.
"""
from
django.db
import
models
from
django.db.models.signals
import
post_init
,
post_save
from
django.dispatch
import
receiver
from
auth.authz
import
add_user_to_creator_group
,
remove_user_from_creator_group
import
datetime
class
CourseCreators
(
models
.
Model
):
class
CourseCreator
(
models
.
Model
):
"""
Creates the database table model.
"""
...
...
@@ -23,7 +28,30 @@ class CourseCreators(models.Model):
note
=
models
.
CharField
(
max_length
=
512
,
blank
=
True
,
help_text
=
'Optional notes about this user (for example, '
'why course creation access was denied)'
)
def
__unicode__
(
self
):
s
=
"
%
s |
%
s [
%
s] |
%
s"
%
(
self
.
username
,
self
.
state
,
self
.
state_changed
,
self
.
note
)
return
s
@receiver
(
post_init
,
sender
=
CourseCreator
)
def
post_init_callback
(
sender
,
**
kwargs
):
instance
=
kwargs
[
'instance'
]
instance
.
orig_state
=
instance
.
state
@receiver
(
post_save
,
sender
=
CourseCreator
)
def
post_save_callback
(
sender
,
**
kwargs
):
instance
=
kwargs
[
'instance'
]
# We only wish to modify the state_changed time if the state has been modified. We don't wish to
# modify it for changes to the notes field.
if
instance
.
state
!=
instance
.
orig_state
:
instance
.
state_changed
=
datetime
.
datetime
.
now
()
if
instance
.
state
==
'g'
:
# add to course group
instance
.
state
=
'g'
else
:
# remove from course group
instance
.
state
=
instance
.
state
instance
.
orig_state
=
instance
.
state
instance
.
save
()
cms/djangoapps/course_creators/views.py
0 → 100644
View file @
2970f242
from
course_creators.models
import
CourseCreator
def
add_user_with_status_unrequested
(
user
):
"""
Adds a user to the course creator table with status 'unrequested'.
"""
_add_user
(
user
,
'u'
)
def
add_user_with_status_granted
(
user
):
"""
Adds a user to the course creator table with status 'granted'.
"""
_add_user
(
user
,
'g'
)
def
_add_user
(
user
,
state
):
if
CourseCreator
.
objects
.
filter
(
username
=
user
.
username
)
.
count
()
==
0
:
entry
=
CourseCreator
(
username
=
user
.
username
,
state
=
state
)
entry
.
save
()
\ No newline at end of file
cms/envs/common.py
View file @
2970f242
...
...
@@ -346,6 +346,9 @@ INSTALLED_APPS = (
# comment common
'django_comment_common'
,
# for course creator table
'django.contrib.admin'
)
################# EDX MARKETING SITE ##################################
...
...
cms/urls.py
View file @
2970f242
...
...
@@ -6,8 +6,8 @@ from django.conf.urls import patterns, include, url
from
.
import
one_time_startup
# Uncomment the next two lines to enable the admin:
#
from django.contrib import admin
#
admin.autodiscover()
from
django.contrib
import
admin
admin
.
autodiscover
()
urlpatterns
=
(
''
,
# nopep8
url
(
r'^$'
,
'contentstore.views.howitworks'
,
name
=
'homepage'
),
...
...
@@ -146,6 +146,10 @@ if settings.MITX_FEATURES.get('ENABLE_SERVICE_STATUS'):
url
(
r'^status/'
,
include
(
'service_status.urls'
)),
)
urlpatterns
+=
(
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
)
urlpatterns
=
patterns
(
*
urlpatterns
)
# Custom error pages
...
...
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