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
d636318b
Commit
d636318b
authored
Sep 25, 2012
by
Ibrahim Awwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lame skeleton notification settings page that does nothing and looks ugly.
parent
e50cc77a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
1 deletions
+108
-1
common/djangoapps/student/views.py
+49
-1
lms/templates/notification_settings.html
+57
-0
lms/urls.py
+2
-0
No files found.
common/djangoapps/student/views.py
View file @
d636318b
...
@@ -38,7 +38,9 @@ from datetime import date
...
@@ -38,7 +38,9 @@ from datetime import date
from
collections
import
namedtuple
from
collections
import
namedtuple
from
courseware.courses
import
get_courses_by_university
from
courseware.courses
import
get_courses_by_university
from
courseware.access
import
has_access
from
courseware.access
import
has_access
import
comment_client
as
cc
from
django
import
forms
from
django.forms.formsets
import
formset_factory
log
=
logging
.
getLogger
(
"mitx.student"
)
log
=
logging
.
getLogger
(
"mitx.student"
)
Article
=
namedtuple
(
'Article'
,
'title url author image deck publication publish_date'
)
Article
=
namedtuple
(
'Article'
,
'title url author image deck publication publish_date'
)
...
@@ -728,3 +730,49 @@ def accept_name_change(request):
...
@@ -728,3 +730,49 @@ def accept_name_change(request):
pnc
.
delete
()
pnc
.
delete
()
return
HttpResponse
(
json
.
dumps
({
'success'
:
True
}))
return
HttpResponse
(
json
.
dumps
({
'success'
:
True
}))
@ensure_csrf_cookie
def
notification_settings
(
request
):
user
=
request
.
user
enrollments
=
CourseEnrollment
.
objects
.
filter
(
user
=
user
)
courses
=
[]
for
enrollment
in
enrollments
:
try
:
courses
.
append
(
course_from_id
(
enrollment
.
course_id
))
except
ItemNotFoundError
:
log
.
error
(
"User {0} enrolled in non-existent course {1}"
.
format
(
user
.
username
,
enrollment
.
course_id
))
message
=
""
if
not
user
.
is_active
:
message
=
render_to_string
(
'registration/activate_account_notice.html'
,
{
'email'
:
user
.
email
})
cc_user
=
cc
.
user
.
User
.
from_django_user
(
user
)
# load existing preferences and render them
show_courseware_links_for
=
frozenset
(
course
.
id
for
course
in
courses
if
has_access
(
request
.
user
,
course
,
'load'
))
context
=
{
'courses'
:
courses
,
'message'
:
message
,
'show_courseware_links_for'
:
show_courseware_links_for
,
}
return
render_to_response
(
'notification_settings.html'
,
context
)
@ensure_csrf_cookie
def
update_notification_settings
(
request
):
user
=
request
.
user
enrollments
=
CourseEnrollment
.
objects
.
filter
(
user
=
user
)
cc_user
=
cc
.
user
.
User
.
from_django_user
(
user
)
# Update preferences on comment service
courses
=
[]
for
enrollment
in
enrollments
:
try
:
courses
.
append
(
course_from_id
(
enrollment
.
course_id
))
except
ItemNotFoundError
:
log
.
error
(
"User {0} enrolled in non-existent course {1}"
.
format
(
user
.
username
,
enrollment
.
course_id
))
return
redirect
(
'notification_settings'
)
lms/templates/notification_settings.html
0 → 100644
View file @
d636318b
<
%!
from
django
.
core
.
urlresolvers
import
reverse
from
courseware
.
courses
import
course_image_url
,
get_course_about_section
from
courseware
.
access
import
has_access
%
>
<
%
inherit
file=
"main.html"
/>
<
%
namespace
name=
'static'
file=
'static_content.html'
/>
<
%
block
name=
"title"
><title>
Notification Settings
</title></
%
block>
<
%
block
name=
"js_extra"
>
</
%
block>
<section
class=
"container dashboard"
>
%if message:
<section
class=
"dashboard-banner"
>
${message}
</section>
%endif
<h4>
Notifications
</h4>
<form
action=
"${reverse('update_notification_settings')}"
method=
"post"
>
<input
type=
"hidden"
name=
"csrfmiddlewaretoken"
value=
"${ csrf_token }"
>
% if len(courses) > 0:
% for course in courses:
<fieldset>
<h3><strong>
${course.number}:
</strong>
${course.title}
</h3>
<h6>
Receive Emails for
</h6>
<ul>
<li>
<label
for=
"all_posts_${course.id}"
>
All posts
</label>
<input
type=
"checkbox"
id=
"all_posts_${course.id}"
>
</li>
<li>
<label
for=
"followed_posts_${course.id}"
>
Posts I am following
</label>
<input
type=
"checkbox"
id=
"followed_posts_${course.id}"
>
</li>
<li>
<label
for=
"email_frequency_${course.id}"
>
Email Frequency
</label>
<select
id=
"email_frequency_${course.id}"
>
<option
value=
"never"
>
Never
</option>
<option
value=
"daily"
>
Daily
</option>
<option
value=
"4hours"
>
Every 4 Hours
</option>
<option
value=
"realtime"
>
Real Time
</option>
</select>
</li>
</ul>
</fieldset>
<hr>
% endfor
<input
type=
"submit"
value=
"Update Notification Preferences"
>
% else:
% endif
</form>
</section>
lms/urls.py
View file @
d636318b
...
@@ -12,6 +12,8 @@ if settings.DEBUG:
...
@@ -12,6 +12,8 @@ if settings.DEBUG:
urlpatterns
=
(
''
,
urlpatterns
=
(
''
,
url
(
r'^$'
,
'branding.views.index'
,
name
=
"root"
),
# Main marketing page, or redirect to courseware
url
(
r'^$'
,
'branding.views.index'
,
name
=
"root"
),
# Main marketing page, or redirect to courseware
url
(
r'^dashboard$'
,
'student.views.dashboard'
,
name
=
"dashboard"
),
url
(
r'^dashboard$'
,
'student.views.dashboard'
,
name
=
"dashboard"
),
url
(
r'^notification_settings$'
,
'student.views.notification_settings'
,
name
=
"notification_settings"
),
url
(
r'^update_notification_settings$'
,
'student.views.update_notification_settings'
,
name
=
"update_notification_settings"
),
url
(
r'^admin_dashboard$'
,
'dashboard.views.dashboard'
),
url
(
r'^admin_dashboard$'
,
'dashboard.views.dashboard'
),
...
...
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