9
9
from notification.decorators import basic_auth_required, simple_basic_auth_callback
10
10
from notification.feeds import NoticeUserFeed
12
13
@basic_auth_required(realm='Notices Feed', callback_func=simple_basic_auth_callback)
13
14
def feed_for_user(request):
14
url = "feed/%s" % request.user.username
15
url = 'feed/%s' % request.user.username
15
16
return Feed(request, url, {
16
"feed": NoticeUserFeed,
17
'feed': NoticeUserFeed,
20
22
def notices(request):
21
23
notice_types = NoticeType.objects.all()
24
26
for notice_type in NoticeType.objects.all():
26
28
for medium_id, medium_display in NOTICE_MEDIA:
27
form_label = "%s_%s" % (notice_type.label, medium_id)
28
setting = get_notification_setting(request.user, notice_type, medium_id)
29
if request.method == "POST":
30
if request.POST.get(form_label) == "on":
29
form_label = '%s_%s' % (notice_type.label, medium_id)
30
setting = get_notification_setting(
31
request.user, notice_type, medium_id)
32
if request.method == 'POST':
33
if request.POST.get(form_label) == 'on':
31
34
setting.send = True
33
36
setting.send = False
35
38
settings_row.append((form_label, setting.send))
36
settings_table.append({"notice_type": notice_type, "cells": settings_row})
39
settings_table.append(
40
{'notice_type': notice_type, 'cells': settings_row})
38
42
notice_settings = {
39
"column_headers": [medium_display for medium_id, medium_display in NOTICE_MEDIA],
40
"rows": settings_table,
43
'column_headers': [medium_display for medium_id, medium_display in NOTICE_MEDIA],
44
'rows': settings_table,
43
return render_to_response("notification/notices.html", {
45
"notice_types": notice_types,
46
"notice_settings": notice_settings,
47
return render_to_response('notification/notices.html', {
49
'notice_types': notice_types,
50
'notice_settings': notice_settings,
47
51
}, context_instance=RequestContext(request))
50
55
def single(request, id):
51
56
notice = get_object_or_404(Notice, id=id)
52
57
if request.user == notice.user:
53
return render_to_response("notification/single.html", {
58
return render_to_response('notification/single.html', {
55
60
}, context_instance=RequestContext(request))
59
65
def archive(request, noticeid=None, next_page=None):
83
90
return HttpResponseRedirect(next_page)
84
91
return HttpResponseRedirect(next_page)
87
95
def mark_all_seen(request):
88
96
for notice in Notice.objects.notices_for(request.user, unseen=True):
89
97
notice.unseen = False
91
return HttpResponseRedirect(reverse("notification_notices"))
b'\\ No newline at end of file'
99
return HttpResponseRedirect(reverse('notification_notices'))