Commit | Line | Data |
---|---|---|
2d7b6bde JW |
1 | # GNU MediaGoblin -- federated, autonomous media hosting |
2 | # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. | |
3 | # | |
4 | # This program is free software: you can redistribute it and/or modify | |
5 | # it under the terms of the GNU Affero General Public License as published by | |
6 | # the Free Software Foundation, either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU Affero General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
1cca2a68 | 17 | from mediagoblin.tools.response import redirect |
2d7b6bde | 18 | from mediagoblin.tools.translate import pass_to_ugettext as _ |
1cca2a68 | 19 | from mediagoblin.decorators import get_user_media_entry, require_active_login |
2d7b6bde JW |
20 | from mediagoblin import messages |
21 | ||
22 | from mediagoblin.notifications import add_comment_subscription, \ | |
1cca2a68 | 23 | silence_comment_subscription, mark_comment_notification_seen |
2d7b6bde | 24 | |
2d7b6bde JW |
25 | |
26 | @get_user_media_entry | |
27 | @require_active_login | |
28 | def subscribe_comments(request, media): | |
29 | ||
30 | add_comment_subscription(request.user, media) | |
31 | ||
32 | messages.add_message(request, | |
33 | messages.SUCCESS, | |
34 | _('Subscribed to comments on %s!') | |
35 | % media.title) | |
36 | ||
37 | return redirect(request, location=media.url_for_self(request.urlgen)) | |
38 | ||
1cca2a68 | 39 | |
2d7b6bde JW |
40 | @get_user_media_entry |
41 | @require_active_login | |
42 | def silence_comments(request, media): | |
43 | silence_comment_subscription(request.user, media) | |
44 | ||
45 | messages.add_message(request, | |
46 | messages.SUCCESS, | |
47 | _('You will not receive notifications for comments on' | |
48 | ' %s.') % media.title) | |
49 | ||
50 | return redirect(request, location=media.url_for_self(request.urlgen)) | |
d0708da7 RE |
51 | |
52 | ||
53 | @require_active_login | |
54 | def mark_all_comment_notifications_seen(request): | |
55 | """ | |
56 | Marks all comment notifications seen. | |
57 | """ | |
58 | for comment in request.notifications.get_notifications(request.user.id): | |
59 | mark_comment_notification_seen(comment.subject_id, request.user) | |
60 | ||
61 | if request.GET.get('next'): | |
62 | return redirect(request, location=request.GET.get('next')) | |
63 | else: | |
64 | return redirect(request, 'index') |