annotate MoinMoin/action/subscribe.py @ 3333:928a45b60bb3

remove remaining mentions of "UserPreferences", add to CHANGES
author Johannes Berg <johannes AT sipsolutions DOT net>
date Wed, 19 Mar 2008 12:45:14 +0100
parents a1322262398a
children c9f5e4f9a76e
rev   line source
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - subscribe to a page to get notified when it changes
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
5 @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1912
diff changeset
6 2006 MoinMoin:ThomasWaldmann
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 """
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 from MoinMoin.Page import Page
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 def execute(pagename, request):
3058
f48d46b39364 fix MoinMoinBugs/SubscribeAndUnsubscribeShareSameUrl (thanks to Federico Lorenzi) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
12 """ Subscribe the user to pagename """
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 _ = request.getText
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 cfg = request.cfg
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 if not request.user.may.read(pagename):
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2675
diff changeset
17 request.theme.add_msg(_("You are not allowed to subscribe to a page you can't read."), "error")
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 # Check if mail is enabled
2675
37449fd9e70a Whitespace/pep8 fixes.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 2674
diff changeset
20 elif not cfg.mail_enabled and not cfg.jabber_enabled:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2675
diff changeset
21 request.theme.add_msg(_("This wiki is not enabled for mail/Jabber processing."), "error")
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 # Suggest visitors to login
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 elif not request.user.valid:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2675
diff changeset
25 request.theme.add_msg(_("You must log in to use subscriptions."), "error")
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 # Suggest users without email to add their email address
2674
9817a90b6fde Fix subscriptions when there's no smtp host set, only notification bot.
Karol Nowak <grzywacz@sul.uni.lodz.pl>
parents: 1918
diff changeset
28 elif not request.user.email and not request.user.jid:
3333
928a45b60bb3 remove remaining mentions of "UserPreferences", add to CHANGES
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3122
diff changeset
29 request.theme.add_msg(_("Add your email address or Jabber ID in your user settings to use subscriptions."),
928a45b60bb3 remove remaining mentions of "UserPreferences", add to CHANGES
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3122
diff changeset
30 "error")
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 elif request.user.isSubscribedTo([pagename]):
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3058
diff changeset
33 request.theme.add_msg(_('You are already subscribed to this page.'))
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 else:
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 # Try to subscribe
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 if request.user.subscribe(pagename):
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2675
diff changeset
37 request.theme.add_msg(_('You have been subscribed to this page.'), "info")
1912
901ff624d942 subscribe action: give msg if page subscription failed
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1777
diff changeset
38 else: # should not happen
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2675
diff changeset
39 request.theme.add_msg(_('You could not get subscribed to this page.'), "error")
1105
289f93f2fd61 move subscribe code to action/subscribe.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2675
diff changeset
41 Page(request, pagename).send_page()