annotate MoinMoin/userprefs/notification.py @ 6133:a6283e189869 tip

fixup: remove nonexisting passlib.utils._blowfish this was removed by the passlib 1.7.1 upgrade.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Jun 2017 18:10:19 +0200
parents b0dfed9a569f
children
rev   line source
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
2 """
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
3 MoinMoin - Notification preferences
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
4
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
5 @copyright: 2001-2004 Juergen Hermann <jh@web.de>,
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
6 2003-2007 MoinMoin:ThomasWaldmann
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
7 2007 MoinMoin:JohannesBerg
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
8 @license: GNU GPL, see COPYING for details.
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
9 """
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
10
5485
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
11 from MoinMoin import events, wikiutil
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
12 from MoinMoin.widget import html
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
13 from MoinMoin.userprefs import UserPrefBase
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
14
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
15
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
16 class Settings(UserPrefBase):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
17 def __init__(self, request):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
18 """ Initialize user settings form. """
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
19 UserPrefBase.__init__(self, request)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
20 self.request = request
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
21 self._ = request.getText
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
22 self.cfg = request.cfg
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
23 self.title = self._("Notification")
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
24 self.name = 'notification'
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
25
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
26 def _decode_pagelist(self, key):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
27 """ Decode list of pages from form input
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
28
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
29 Each line is a page name, empty lines ignored.
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
30
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
31 @param key: the form key to get
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
32 @rtype: list of unicode strings
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
33 @return: list of normalized names
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
34 """
4428
ded09bdc3902 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4186
diff changeset
35 text = self.request.form.get(key, '')
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
36 text = text.replace('\r', '')
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
37 items = []
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
38 for item in text.split('\n'):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
39 item = item.strip()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
40 if not item:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
41 continue
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
42 items.append(item)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
43 return items
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
44
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
45 def _save_notification_settings(self):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
46 _ = self._
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
47 form = self.request.form
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
48
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
49 theuser = self.request.user
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
50 if not theuser:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
51 return
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
52
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
53 # subscription for page change notification
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
54 theuser.subscribed_pages = self._decode_pagelist('subscribed_pages')
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
55
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
56 # subscription to various events
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
57 available = events.get_subscribable_events()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
58 theuser.email_subscribed_events = []
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
59 theuser.jabber_subscribed_events = []
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
60 types = {
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
61 'email': theuser.email_subscribed_events,
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
62 'jabber': theuser.jabber_subscribed_events
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
63 }
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64 for tp in types:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
65 for evt in available:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
66 fieldname = 'subscribe:%s:%s' % (tp, evt)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
67 if fieldname in form:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
68 types[tp].append(evt)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
69 # save data
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
70 theuser.save()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
71
3513
7bfd4232cfb7 builtin userprefs plugins: return appropriate message class
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3175
diff changeset
72 return 'info', _("Notification settings saved!")
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
73
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
74
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
75 def handle_form(self):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
76 _ = self._
5485
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
77 request = self.request
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
78 form = request.form
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
79
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
80 if form.has_key('cancel'):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
81 return
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
82
5488
b0dfed9a569f merged moin/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4428 5485
diff changeset
83 if request.method != 'POST':
5485
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
84 return
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
85
5488
b0dfed9a569f merged moin/1.8
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4428 5485
diff changeset
86 if not wikiutil.checkTicket(request, form.get('ticket', '')):
5485
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
87 return
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
88
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
89 if form.has_key('save'): # Save user profile
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
90 return self._save_notification_settings()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
91
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
92 # form generation part
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
93
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
94 def _event_select(self):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
95 """ Create event subscription list. """
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
96 _ = self._
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
97
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
98 types = []
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
99 if self.cfg.mail_enabled and self.request.user.email:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
100 types.append(('email', _("'''Email'''", wiki=True)))
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
101 if self.cfg.jabber_enabled and self.request.user.jid:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
102 types.append(('jabber', _("'''Jabber'''", wiki=True)))
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
103
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
104 table = html.TABLE()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
105 header = html.TR()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
106 table.append(header)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
107 for name, descr in types:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
108 header.append(html.TH().append(html.Raw(descr)))
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
109 header.append(html.TH(align='left').append(html.Raw(_("'''Event type'''", wiki=True))))
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
110
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
111 event_list = events.get_subscribable_events()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
112 super = self.request.user.isSuperUser()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
113
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
114 # Create a list of (value, name) tuples for display as radiobuttons
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
115 # Only include super-user visible events if current user has these rights.
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
116 # It's cosmetic - the check for super-user rights should be performed
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
117 # in event handling code as well!
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
118 allowed = []
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
119 for key in event_list.keys():
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
120 if not event_list[key]['superuser'] or super:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
121 allowed.append((key, event_list[key]['desc']))
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
122
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
123 for evname, evdescr in allowed:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
124 tr = html.TR()
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
125 table.append(tr)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
126 for notiftype, notifdescr in types:
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
127 checked = evname in getattr(self.request.user,
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
128 '%s_subscribed_events' % notiftype)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
129 tr.append(html.TD().append(html.INPUT(
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
130 type='checkbox',
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
131 checked=checked,
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
132 name='subscribe:%s:%s' % (notiftype, evname))))
2428
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
133 tr.append(html.TD().append(html.Raw(self.request.getText(evdescr))))
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
134
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
135 return table
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
136
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
137 def create_form(self):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
138 """ Create the complete HTML form code. """
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
139 _ = self._
2428
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
140 self._form = self.make_form(
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
141 _('Select the events you want to be notified about.'))
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
142
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
143 self._form.append(html.INPUT(type="hidden", name="action", value="userprefs"))
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
144 self._form.append(html.INPUT(type="hidden", name="handler", value="prefs"))
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
145
5485
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
146 ticket = wikiutil.createTicket(self.request)
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
147 self._form.append(html.INPUT(type="hidden", name="ticket", value="%s" % ticket))
9faee4b754c0 userprefs notifications: add ticket
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3513
diff changeset
148
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
149 if (not (self.cfg.mail_enabled and self.request.user.email)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
150 and not (self.cfg.jabber_enabled and self.request.user.jid)):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
151 self.make_row('', [html.Text(
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
152 _("Before you can be notified, you need to provide a way"
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
153 " to contact you in the general preferences."))])
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
154 self.make_row('', [
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
155 html.INPUT(type="submit", name="cancel", value=_("Cancel"))])
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
156 return unicode(self._form)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
157
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
158 self.make_row(_('Subscribed events'), [self._event_select()])
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
159
2428
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
160 # Get list of subscribe pages, DO NOT sort! it should
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
161 # stay in the order the user entered it in his input
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
162 # box.
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
163 notifylist = self.request.user.getSubscriptionList()
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
164
2428
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
165 self.make_row(
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
166 html.Raw(_('Subscribed wiki pages<<BR>>(one regex per line)', wiki=True)),
2428
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
167 [html.TEXTAREA(name="subscribed_pages", rows="6", cols="50").append(
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
168 '\n'.join(notifylist)), ],
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
169 valign="top"
3ddef6c321b1 small fixes to notification userprefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2427
diff changeset
170 )
2427
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
171
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
172 # Add buttons
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
173 self.make_row('', [
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
174 html.INPUT(type="submit", name="save", value=_("Save")),
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
175 ' ',
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
176 html.INPUT(type="submit", name="cancel", value=_("Cancel"))])
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
177
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
178 return unicode(self._form)
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
179
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
180 def allowed(self):
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
181 return UserPrefBase.allowed(self) and (
dd138b728c1f initial cut at a notification prefs dialog
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
182 self.cfg.mail_enabled or self.cfg.jabber_enabled)