X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=mediagoblin%2Fnotifications%2Fviews.py;h=cfe66b2e7d5c88527859dee90c92849f23e02492;hb=2e22cefdd901dabcd1e0376984e414624b8676c0;hp=d275bc9273f19b22f3b5c95e61ddffacb641cce3;hpb=2ae78574b3eb8c393136e7ebbc922d33bf6482f2;p=mediagoblin.git diff --git a/mediagoblin/notifications/views.py b/mediagoblin/notifications/views.py index d275bc92..cfe66b2e 100644 --- a/mediagoblin/notifications/views.py +++ b/mediagoblin/notifications/views.py @@ -14,19 +14,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.tools.response import render_to_response, render_404, redirect +from mediagoblin.tools.response import redirect from mediagoblin.tools.translate import pass_to_ugettext as _ -from mediagoblin.decorators import (uses_pagination, get_user_media_entry, - get_media_entry_by_id, - require_active_login, user_may_delete_media, user_may_alter_collection, - get_user_collection, get_user_collection_item, active_user_from_url) - +from mediagoblin.decorators import get_user_media_entry, require_active_login from mediagoblin import messages -from mediagoblin.notifications import add_comment_subscription, \ - silence_comment_subscription +from mediagoblin.notifications import (add_comment_subscription, + silence_comment_subscription, mark_comment_notification_seen, + get_notifications) -from werkzeug.exceptions import BadRequest @get_user_media_entry @require_active_login @@ -41,6 +37,7 @@ def subscribe_comments(request, media): return redirect(request, location=media.url_for_self(request.urlgen)) + @get_user_media_entry @require_active_login def silence_comments(request, media): @@ -52,3 +49,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 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')