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
55f2cbc9
Commit
55f2cbc9
authored
Aug 06, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split up event notification, make sorting on username work.
parent
4c95078e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
4 deletions
+48
-4
cms/djangoapps/course_creators/admin.py
+48
-4
No files found.
cms/djangoapps/course_creators/admin.py
View file @
55f2cbc9
...
...
@@ -2,13 +2,15 @@
django admin page for the course creators table
"""
from
course_creators.models
import
CourseCreator
,
update_creator_state
from
course_creators.models
import
CourseCreator
,
update_creator_state
,
send_user_notification
,
send_admin_notification
from
course_creators.views
import
update_course_creator_group
from
ratelimitbackend
import
admin
from
django.conf
import
settings
from
django.dispatch
import
receiver
from
mitxmako.shortcuts
import
render_to_string
from
django.core.mail
import
send_mail
from
smtplib
import
SMTPException
import
logging
...
...
@@ -28,12 +30,12 @@ class CourseCreatorAdmin(admin.ModelAdmin):
"""
# Fields to display on the overview page.
list_display
=
[
'user'
,
get_email
,
'state'
,
'state_changed'
,
'note'
]
readonly_fields
=
[
'user'
,
'state_changed'
]
list_display
=
[
'user
name
'
,
get_email
,
'state'
,
'state_changed'
,
'note'
]
readonly_fields
=
[
'user
name
'
,
'state_changed'
]
# Controls the order on the edit form (without this, read-only fields appear at the end).
fieldsets
=
(
(
None
,
{
'fields'
:
[
'user'
,
'state'
,
'state_changed'
,
'note'
]
'fields'
:
[
'user
name
'
,
'state'
,
'state_changed'
,
'note'
]
}),
)
# Fields that filtering support
...
...
@@ -43,6 +45,16 @@ class CourseCreatorAdmin(admin.ModelAdmin):
# Turn off the action bar (we have no bulk actions)
actions
=
None
def
username
(
self
,
inst
):
"""
Returns the username for a given user.
Implemented to make sorting by username instead of by user object.
"""
return
inst
.
user
.
username
username
.
admin_order_field
=
'user__username'
def
has_add_permission
(
self
,
request
):
return
False
...
...
@@ -70,6 +82,12 @@ def update_creator_group_callback(sender, **kwargs):
updated_state
=
kwargs
[
'state'
]
update_course_creator_group
(
kwargs
[
'caller'
],
user
,
updated_state
==
CourseCreator
.
GRANTED
)
@receiver
(
send_user_notification
,
sender
=
CourseCreator
)
def
send_user_notification_callback
(
sender
,
**
kwargs
):
user
=
kwargs
[
'user'
]
updated_state
=
kwargs
[
'state'
]
studio_request_email
=
settings
.
MITX_FEATURES
.
get
(
'STUDIO_REQUEST_EMAIL'
,
''
)
context
=
{
'studio_request_email'
:
studio_request_email
}
...
...
@@ -88,3 +106,29 @@ def update_creator_group_callback(sender, **kwargs):
user
.
email_user
(
subject
,
message
,
studio_request_email
)
except
:
log
.
warning
(
"Unable to send course creator status e-mail to
%
s"
,
user
.
email
)
@receiver
(
send_admin_notification
,
sender
=
CourseCreator
)
def
send_admin_notification_callback
(
sender
,
**
kwargs
):
"""
Callback for notifying admin of a user in the 'pending' state.
"""
user
=
kwargs
[
'user'
]
studio_request_email
=
settings
.
MITX_FEATURES
.
get
(
'STUDIO_REQUEST_EMAIL'
,
''
)
context
=
{
'user_name'
:
user
.
username
,
'user_email'
:
user
.
email
}
subject
=
render_to_string
(
'emails/course_creator_admin_subject.txt'
,
context
)
subject
=
''
.
join
(
subject
.
splitlines
())
message
=
render_to_string
(
'emails/course_creator_admin_user_pending.txt'
,
context
)
try
:
send_mail
(
subject
,
message
,
studio_request_email
,
[
studio_request_email
],
fail_silently
=
False
)
except
SMTPException
:
log
.
warning
(
"Failure sending 'pending state' e-mail for
%
s to
%
s"
,
user
.
email
,
studio_request_email
)
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