diff options
author | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-07 12:44:43 -0700 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-20 08:09:29 -0700 |
commit | d0708da727b72cfc95defe14dd6780d2cba0a0b7 (patch) | |
tree | 2d1c707e8eceb7a38712e982c8d6bb2a6f5da69a /mediagoblin/notifications | |
parent | c62d174437445565b55b220396e7571a323a159c (diff) | |
download | mediagoblin-d0708da727b72cfc95defe14dd6780d2cba0a0b7.tar.lz mediagoblin-d0708da727b72cfc95defe14dd6780d2cba0a0b7.tar.xz mediagoblin-d0708da727b72cfc95defe14dd6780d2cba0a0b7.zip |
add the ability to mark all notifications read.
Diffstat (limited to 'mediagoblin/notifications')
-rw-r--r-- | mediagoblin/notifications/routing.py | 4 | ||||
-rw-r--r-- | mediagoblin/notifications/views.py | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/mediagoblin/notifications/routing.py b/mediagoblin/notifications/routing.py index e57956d3..cd7bbc21 100644 --- a/mediagoblin/notifications/routing.py +++ b/mediagoblin/notifications/routing.py @@ -23,3 +23,7 @@ add_route('mediagoblin.notifications.subscribe_comments', add_route('mediagoblin.notifications.silence_comments', '/u/<string:user>/m/<string:media>/notifications/silence/', 'mediagoblin.notifications.views:silence_comments') + +add_route('mediagoblin.notifications.mark_all_comment_notifications_seen', + '/notifications/comments/mark_all_seen/', + 'mediagoblin.notifications.views:mark_all_comment_notifications_seen') diff --git a/mediagoblin/notifications/views.py b/mediagoblin/notifications/views.py index d275bc92..cda7f0af 100644 --- a/mediagoblin/notifications/views.py +++ b/mediagoblin/notifications/views.py @@ -24,7 +24,7 @@ from mediagoblin.decorators import (uses_pagination, get_user_media_entry, from mediagoblin import messages from mediagoblin.notifications import add_comment_subscription, \ - silence_comment_subscription + silence_comment_subscription, mark_comment_notification_seen from werkzeug.exceptions import BadRequest @@ -52,3 +52,17 @@ def silence_comments(request, media): ' %s.') % media.title) return redirect(request, location=media.url_for_self(request.urlgen)) + + +@require_active_login +def mark_all_comment_notifications_seen(request): + """ + Marks all comment notifications seen. + """ + for comment in request.notifications.get_notifications(request.user.id): + mark_comment_notification_seen(comment.subject_id, request.user) + + if request.GET.get('next'): + return redirect(request, location=request.GET.get('next')) + else: + return redirect(request, 'index') |