Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kevin/email notifications panel #520

Merged
merged 98 commits into from
Jul 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
15de412
blankslate edited, header bar now with home button
marcotuts Apr 12, 2013
7ddb7a6
Merge branch 'master' into feature/marco/discussionhome
marcotuts Jun 3, 2013
57c513b
basic shell for discussion home page with both profile information an…
marcotuts Jun 3, 2013
0936e61
addition of font-awesome to LMS sass vendor assets, in additio nto li…
marcotuts Jun 4, 2013
714a3f1
added in vendor font references to lms for font-awesome
marcotuts Jun 4, 2013
f213113
cleaned up font-awesome integration to work with new mako file .scss …
marcotuts Jun 4, 2013
786d8a9
cleaned up variables styling to sync up closer to studio, incorporate…
marcotuts Jun 5, 2013
c63fb7c
basic shell for home page exists, along with start of color cleanup f…
marcotuts Jun 12, 2013
03d5145
removed border to the right of discussion list
marcotuts Jun 12, 2013
73e1227
cleaned up margin and padding to use baseline variable
marcotuts Jun 12, 2013
48f4769
sass build cleanup for baseline fixes
marcotuts Jun 12, 2013
e515857
icon color changes and profile link style to match profile page
marcotuts Jun 12, 2013
1af4d90
removed icon stack from email area of helpgrid
marcotuts Jun 12, 2013
b946a10
cleaned up topic header to allow for multiple line titles still being…
marcotuts Jun 13, 2013
b6c4cc4
new post button using font-awesome
marcotuts Jun 14, 2013
b9d97e4
removed new post icon and added font-awesome replacement
marcotuts Jun 14, 2013
d5105b7
updated flag icons to be font-awesome based
marcotuts Jun 14, 2013
163610d
updated pinning icons and removed images
marcotuts Jun 14, 2013
3df08dc
blankslate edited, header bar now with home button
marcotuts Apr 12, 2013
46998bd
basic shell for discussion home page with both profile information an…
marcotuts Jun 3, 2013
8ef258d
addition of font-awesome to LMS sass vendor assets, in additio nto li…
marcotuts Jun 4, 2013
38d8863
added in vendor font references to lms for font-awesome
marcotuts Jun 4, 2013
23f1942
cleaned up font-awesome integration to work with new mako file .scss …
marcotuts Jun 4, 2013
5240342
cleaned up variables styling to sync up closer to studio, incorporate…
marcotuts Jun 5, 2013
b870679
basic shell for home page exists, along with start of color cleanup f…
marcotuts Jun 12, 2013
d648b18
removed border to the right of discussion list
marcotuts Jun 12, 2013
74ea364
cleaned up margin and padding to use baseline variable
marcotuts Jun 12, 2013
9fe6264
sass build cleanup for baseline fixes
marcotuts Jun 12, 2013
07e87a5
icon color changes and profile link style to match profile page
marcotuts Jun 12, 2013
b83d5aa
removed icon stack from email area of helpgrid
marcotuts Jun 12, 2013
98cd032
cleaned up topic header to allow for multiple line titles still being…
marcotuts Jun 13, 2013
0f84a52
new post button using font-awesome
marcotuts Jun 14, 2013
770bfdc
removed new post icon and added font-awesome replacement
marcotuts Jun 14, 2013
05a7d66
updated flag icons to be font-awesome based
marcotuts Jun 14, 2013
a24c3a9
updated pinning icons and removed images
marcotuts Jun 14, 2013
84d505e
modified html for discussion home to use tables instead of lists, cle…
marcotuts Jun 26, 2013
f94ec6c
merge conflicts resolved
marcotuts Jun 26, 2013
fbd0f1b
wire up static HTML to allow panel functionality
kevinchugh Jul 16, 2013
6e2de9d
tweak css and fix merge conflicts
kevinchugh Jul 16, 2013
63b2b47
update to render home page
kevinchugh Jul 19, 2013
17f4579
blankslate edited, header bar now with home button
marcotuts Apr 12, 2013
8886b59
basic shell for discussion home page with both profile information an…
marcotuts Jun 3, 2013
8216bb6
addition of font-awesome to LMS sass vendor assets, in additio nto li…
marcotuts Jun 4, 2013
0812867
added in vendor font references to lms for font-awesome
marcotuts Jun 4, 2013
1fe54ba
cleaned up font-awesome integration to work with new mako file .scss …
marcotuts Jun 4, 2013
6657ac1
cleaned up variables styling to sync up closer to studio, incorporate…
marcotuts Jun 5, 2013
f674e61
basic shell for home page exists, along with start of color cleanup f…
marcotuts Jun 12, 2013
b55b34f
removed border to the right of discussion list
marcotuts Jun 12, 2013
a0f54aa
cleaned up margin and padding to use baseline variable
marcotuts Jun 12, 2013
ff9f571
sass build cleanup for baseline fixes
marcotuts Jun 12, 2013
d2fae78
icon color changes and profile link style to match profile page
marcotuts Jun 12, 2013
1a267a5
removed icon stack from email area of helpgrid
marcotuts Jun 12, 2013
90e60c1
cleaned up topic header to allow for multiple line titles still being…
marcotuts Jun 13, 2013
e277946
new post button using font-awesome
marcotuts Jun 14, 2013
642b649
removed new post icon and added font-awesome replacement
marcotuts Jun 14, 2013
0e0ceb4
updated flag icons to be font-awesome based
marcotuts Jun 14, 2013
9c45293
updated pinning icons and removed images
marcotuts Jun 14, 2013
8d49007
blankslate edited, header bar now with home button
marcotuts Apr 12, 2013
38e040a
basic shell for discussion home page with both profile information an…
marcotuts Jun 3, 2013
2c9e4ca
addition of font-awesome to LMS sass vendor assets, in additio nto li…
marcotuts Jun 4, 2013
37c9de7
cleaned up font-awesome integration to work with new mako file .scss …
marcotuts Jun 4, 2013
e2f02cd
cleaned up variables styling to sync up closer to studio, incorporate…
marcotuts Jun 5, 2013
e87d071
basic shell for home page exists, along with start of color cleanup f…
marcotuts Jun 12, 2013
a9ea00a
removed border to the right of discussion list
marcotuts Jun 12, 2013
78ffc12
cleaned up margin and padding to use baseline variable
marcotuts Jun 12, 2013
d8498bf
new post button using font-awesome
marcotuts Jun 14, 2013
646ff9e
removed new post icon and added font-awesome replacement
marcotuts Jun 14, 2013
9eca557
updated flag icons to be font-awesome based
marcotuts Jun 14, 2013
3495ceb
modified html for discussion home to use tables instead of lists, cle…
marcotuts Jun 26, 2013
83b4dc6
final cleanup from git rebase
marcotuts Jul 22, 2013
747102c
additional git rebase cleanup
marcotuts Jul 22, 2013
5b3cb53
visual cleanup for discussion home bar
marcotuts Jul 22, 2013
820544c
pin and flag icons using fontawesome now render properly through inli…
marcotuts Jul 22, 2013
77a23a3
reordered email settings checkbox to impact styling for icon and clea…
marcotuts Jul 23, 2013
5d106ee
Merge branch 'master' into feature/kevin/email_notifications_panel
kevinchugh Jul 25, 2013
d95693e
hook up panel to new stats service
kevinchugh Jul 25, 2013
6276997
update checkbox with get settings
kevinchugh Jul 29, 2013
13ca61b
fix merge conflict with _variables.scss
kevinchugh Jul 29, 2013
7507921
merge with Marcos new design
kevinchugh Jul 29, 2013
4afa548
set and get settings and fix discussion.css post-variable-apocalypse
kevinchugh Jul 29, 2013
b7d6d77
visual cleanup for email icon and discussion context label post branc…
marcotuts Jul 29, 2013
33d4ae6
add feature flag to enable/disable discussion home panel
Jul 29, 2013
06eb5cd
Merge branch 'feature/kevin/email_notifications_panel' of https://git…
Jul 29, 2013
47dbf2e
updates but getting status and setting status not working
kevinchugh Jul 29, 2013
62f6e2d
home button working, default to home when no thread selected
kevinchugh Jul 30, 2013
99f235e
first pass at jasmine tests
kevinchugh Jul 30, 2013
0207255
fix strange comment typo
Jul 30, 2013
8f98a1c
remove failing jasmine tests and print statements
kevinchugh Jul 30, 2013
79994b5
Merge branch 'feature/kevin/email_notifications_panel' of https://git…
Jul 30, 2013
803b92f
add ajax endpoint for getting notifications status
kevinchugh Jul 30, 2013
986a2cd
Merge branch 'feature/kevin/email_notifications_panel' of github.com:…
kevinchugh Jul 30, 2013
908fd46
notification_prefs: add ajax endpoint to get preference status
Jul 30, 2013
5c91edd
update coffeescript to use new status url
kevinchugh Jul 30, 2013
c3e609f
fix merge conflict
kevinchugh Jul 30, 2013
4f7edbf
fix notifications URL
kevinchugh Jul 30, 2013
e1e591f
address code review comments
kevinchugh Jul 30, 2013
7a7c070
notification_prefs/views: correct docstring
Jul 30, 2013
05f31f8
Merge branch 'feature/kevin/email_notifications_panel' of https://git…
Jul 30, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/static/coffee/src/discussion/discussion_router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ if Backbone?

allThreads: ->
@nav.updateSidebar()
@nav.goHome()

setActiveThread: =>
if @thread
@nav.setActiveThread(@thread.get("id"))
else
@nav.goHome

showThread: (forum_name, thread_id) ->
@thread = @discussion.get(thread_id)
Expand Down
3 changes: 3 additions & 0 deletions common/static/coffee/src/discussion/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class @DiscussionUtil
user_profile : "/courses/#{$$course_id}/discussion/forum/users/#{param}"
followed_threads : "/courses/#{$$course_id}/discussion/forum/users/#{param}/followed"
threads : "/courses/#{$$course_id}/discussion/forum"
"enable_notifications" : "/notification_prefs/enable/"
"disable_notifications" : "/notification_prefs/disable/"
"notifications_status" : "/notification_prefs/status"
}[name]

@safeAjax: (params) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ if Backbone?
class @DiscussionThreadListView extends Backbone.View
events:
"click .search": "showSearch"
"click .home": "goHome"
"click .browse": "toggleTopicDrop"
"keydown .post-search-field": "performSearch"
"click .sort-bar a": "sortThreads"
Expand Down Expand Up @@ -43,6 +44,7 @@ if Backbone?
if active
@setActiveThread(thread_id)


#TODO fix this entire chain of events
addAndSelectThread: (thread) =>
commentable_id = thread.get("commentable_id")
Expand Down Expand Up @@ -191,6 +193,25 @@ if Backbone?
@$(".browse").removeClass('is-open')
setTimeout (-> @$(".post-search-field").focus()), 200

goHome: ->
@template = _.template($("#discussion-home").html())
$(".discussion-column").html(@template)
$(".post-list a").removeClass("active")
$("input.email-setting").bind "click", @updateEmailNotifications
url = DiscussionUtil.urlFor("notifications_status",window.user.get("id"))
DiscussionUtil.safeAjax
url: url
type: "GET"
success: (response, textStatus) =>
if response.status
$('input.email-setting').attr('checked','checked')
else
$('input.email-setting').removeAttr('checked')
thread_id = null
@trigger("thread:removed")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does thread:removed do something related to the home button?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it loads all threads with none selected. if the user clicks a thread, then clicks home, then hits refresh, we don't want to reload the previous selected thread, this accomplishes that

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

#select all threads


toggleTopicDrop: (event) =>
event.preventDefault()
event.stopPropagation()
Expand Down Expand Up @@ -312,6 +333,7 @@ if Backbone?
if callback?
callback()


retrieveDiscussions: (discussion_ids) ->
@discussionIds = discussion_ids.join(',')
@mode = 'commentables'
Expand Down Expand Up @@ -418,3 +440,19 @@ if Backbone?
retrieveFollowed: (event)=>
@mode = 'followed'
@retrieveFirstPage(event)

updateEmailNotifications: () =>
if $('input.email-setting').attr('checked')
DiscussionUtil.safeAjax
url: DiscussionUtil.urlFor("enable_notifications")
type: "POST"
error: () =>
$('input.email-setting').removeAttr('checked')
else
DiscussionUtil.safeAjax
url: DiscussionUtil.urlFor("disable_notifications")
type: "POST"
error: () =>
$('input.email-setting').attr('checked','checked')


1 change: 0 additions & 1 deletion lms/djangoapps/django_comment_client/base/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
url(r'threads/(?P<thread_id>[\w\-]+)/follow$', 'follow_thread', name='follow_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/unfollow$', 'unfollow_thread', name='unfollow_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/close$', 'openclose_thread', name='openclose_thread'),

url(r'comments/(?P<comment_id>[\w\-]+)/update$', 'update_comment', name='update_comment'),
url(r'comments/(?P<comment_id>[\w\-]+)/endorse$', 'endorse_comment', name='endorse_comment'),
url(r'comments/(?P<comment_id>[\w\-]+)/reply$', 'create_sub_comment', name='create_sub_comment'),
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/django_comment_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ def safe_content(content):
'updated_at', 'depth', 'type', 'commentable_id', 'comments_count',
'at_position_list', 'children', 'highlighted_title', 'highlighted_body',
'courseware_title', 'courseware_url', 'tags', 'unread_comments_count',
'read', 'group_id', 'group_name', 'group_string', 'pinned', 'abuse_flaggers'
'read', 'group_id', 'group_name', 'group_string', 'pinned', 'abuse_flaggers',
'stats'

]

Expand Down
32 changes: 31 additions & 1 deletion lms/djangoapps/notification_prefs/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import PermissionDenied
from django.http import Http404
Expand All @@ -7,7 +9,7 @@
from mock import Mock, patch

from notification_prefs import NOTIFICATION_PREF_KEY
from notification_prefs.views import ajax_enable, ajax_disable, unsubscribe
from notification_prefs.views import ajax_enable, ajax_disable, ajax_status, unsubscribe
from student.tests.factories import UserFactory
from user_api.models import UserPreference

Expand Down Expand Up @@ -57,6 +59,34 @@ def assertNotPrefExists(self, user):
UserPreference.objects.filter(user=user, key=NOTIFICATION_PREF_KEY).exists()
)

# AJAX status view

def test_ajax_status_get_0(self):
request = self.request_factory.get("dummy")
request.user = self.user
response = ajax_status(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content), {"status":0})

def test_ajax_status_get_1(self):
self.create_prefs()
request = self.request_factory.get("dummy")
request.user = self.user
response = ajax_status(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content), {"status":1})

def test_ajax_status_post(self):
request = self.request_factory.post("dummy")
request.user = self.user
response = ajax_status(request)
self.assertEqual(response.status_code, 405)

def test_ajax_status_anon_user(self):
request = self.request_factory.get("dummy")
request.user = AnonymousUser()
self.assertRaises(PermissionDenied, ajax_status, request)

# AJAX enable view

def test_ajax_enable_get(self):
Expand Down
20 changes: 20 additions & 0 deletions lms/djangoapps/notification_prefs/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from base64 import urlsafe_b64encode, urlsafe_b64decode
from hashlib import sha256
import json

from Crypto.Cipher import AES
from Crypto import Random
Expand Down Expand Up @@ -131,6 +132,25 @@ def ajax_disable(request):

return HttpResponse(status=204)

@require_GET
def ajax_status(request):
"""
A view that retrieves notifications status for the authenticated user.

This view should be invoked by an AJAX GET call. It returns status 200,
with a JSON-formatted payload, or an error.
"""
if not request.user.is_authenticated():
raise PermissionDenied


qs = UserPreference.objects.filter(
user=request.user,
key=NOTIFICATION_PREF_KEY
)

return HttpResponse(json.dumps({"status":len(qs)}), content_type="application/json")


@require_GET
def unsubscribe(request, token):
Expand Down
3 changes: 3 additions & 0 deletions lms/envs/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@
MITX_FEATURES['AUTOMATIC_AUTH_FOR_LOAD_TESTING'] = ENV_TOKENS.get('AUTOMATIC_AUTH_FOR_LOAD_TESTING')
MITX_FEATURES['MAX_AUTO_AUTH_USERS'] = ENV_TOKENS.get('MAX_AUTO_AUTH_USERS')

# discussion home panel must be explicitly enabled
MITX_FEATURES['ENABLE_DISCUSSION_HOME_PANEL'] = ENV_TOKENS.get('ENABLE_DISCUSSION_HOME_PANEL', False)

############################## SECURE AUTH ITEMS ###############
# Secret things: passwords, access keys, etc.

Expand Down
3 changes: 3 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@

'ENABLE_TEXTBOOK': True,
'ENABLE_DISCUSSION_SERVICE': True,
# discussion home panel, which includes a subscription on/off setting for discussion digest emails.
# this should remain off in production until digest notifications are online.
'ENABLE_DISCUSSION_HOME_PANEL': True,

'ENABLE_PSYCHOMETRICS': False, # real-time psychometrics (eg item response theory analysis in instructor dashboard)

Expand Down
5 changes: 5 additions & 0 deletions lms/lib/comment_client/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ def _url_for_user_active_threads(user_id):

def _url_for_user_subscribed_threads(user_id):
return "{prefix}/users/{user_id}/subscribed_threads".format(prefix=settings.PREFIX, user_id=user_id)

def _url_for_user_stats(user_id,course_id):
return "{prefix}/users/{user_id}/stats?course_id={course_id}".format(prefix=settings.PREFIX, user_id=user_id,course_id=course_id)


Binary file added lms/static/fonts/vendor/FontAwesome.otf
Binary file not shown.
Binary file added lms/static/fonts/vendor/fontawesome-webfont.eot
Binary file not shown.
Loading