comparison MoinMoin/action/subscribe.py @ 3058:f48d46b39364

fix MoinMoinBugs/SubscribeAndUnsubscribeShareSameUrl (thanks to Federico Lorenzi) (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 Feb 2008 20:37:32 +0100
parents ba14d391c2ba
children a1322262398a
comparison
equal deleted inserted replaced
3057:9c58f31af69e 3058:f48d46b39364
7 @license: GNU GPL, see COPYING for details. 7 @license: GNU GPL, see COPYING for details.
8 """ 8 """
9 from MoinMoin.Page import Page 9 from MoinMoin.Page import Page
10 10
11 def execute(pagename, request): 11 def execute(pagename, request):
12 """ Subscribe or unsubscribe the user to pagename """ 12 """ Subscribe the user to pagename """
13 _ = request.getText 13 _ = request.getText
14 cfg = request.cfg 14 cfg = request.cfg
15 15
16 if not request.user.may.read(pagename): 16 if not request.user.may.read(pagename):
17 request.theme.add_msg(_("You are not allowed to subscribe to a page you can't read."), "error") 17 request.theme.add_msg(_("You are not allowed to subscribe to a page you can't read."), "error")
27 # Suggest users without email to add their email address 27 # Suggest users without email to add their email address
28 elif not request.user.email and not request.user.jid: 28 elif not request.user.email and not request.user.jid:
29 request.theme.add_msg(_("Add your email address or Jabber ID in your UserPreferences to use subscriptions."), "error") 29 request.theme.add_msg(_("Add your email address or Jabber ID in your UserPreferences to use subscriptions."), "error")
30 30
31 elif request.user.isSubscribedTo([pagename]): 31 elif request.user.isSubscribedTo([pagename]):
32 # Try to unsubscribe 32 request.theme.add_msg(_('You are already subscribed to this page.', formatted=False))
33 if request.user.unsubscribe(pagename):
34 request.theme.add_msg(_('Your subscription to this page has been removed.'), "info")
35 else:
36 request.theme.add_msg(_("Can't remove regular expression subscription!") + u' ' + \
37 _("Edit the subscription regular expressions in your "
38 "UserPreferences."), "error")
39
40 else: 33 else:
41 # Try to subscribe 34 # Try to subscribe
42 if request.user.subscribe(pagename): 35 if request.user.subscribe(pagename):
43 request.theme.add_msg(_('You have been subscribed to this page.'), "info") 36 request.theme.add_msg(_('You have been subscribed to this page.'), "info")
44 else: # should not happen 37 else: # should not happen
45 request.theme.add_msg(_('You could not get subscribed to this page.'), "error") 38 request.theme.add_msg(_('You could not get subscribed to this page.'), "error")
46 39
47 Page(request, pagename).send_page() 40 Page(request, pagename).send_page()
48