add the ability to mark all notifications read.
This commit is contained in:
parent
c62d174437
commit
d0708da727
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -33,4 +33,17 @@ var notifications = {};
|
||||
|
||||
$(document).ready(function () {
|
||||
notifications.init();
|
||||
|
||||
var mark_all_comments_seen = document.getElementById('mark_all_comments_seen');
|
||||
|
||||
if (mark_all_comments_seen) {
|
||||
mark_all_comments_seen.href = '#';
|
||||
mark_all_comments_seen.onclick = function() {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/notifications/comments/mark_all_seen/',
|
||||
success: function(res, status, xhr) { window.location.reload(); },
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -36,5 +36,9 @@
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<a href="{{ request.urlgen('mediagoblin.notifications.mark_all_comment_notifications_seen') }}?next={{
|
||||
request.base_url|urlencode }}" id="mark_all_comments_seen">
|
||||
{% trans %}Mark all read{% endtrans %}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user