changeset 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 9c58f31af69e
children 036fc4dce2ee
files MoinMoin/action/subscribe.py MoinMoin/action/unsubscribe.py MoinMoin/theme/__init__.py
diffstat 3 files changed, 35 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/subscribe.py	Thu Feb 21 20:06:02 2008 +0100
+++ b/MoinMoin/action/subscribe.py	Thu Feb 21 20:37:32 2008 +0100
@@ -9,7 +9,7 @@
 from MoinMoin.Page import Page
 
 def execute(pagename, request):
-    """ Subscribe or unsubscribe the user to pagename """
+    """ Subscribe the user to pagename """
     _ = request.getText
     cfg = request.cfg
 
@@ -29,14 +29,7 @@
         request.theme.add_msg(_("Add your email address or Jabber ID in your UserPreferences to use subscriptions."), "error")
 
     elif request.user.isSubscribedTo([pagename]):
-        # Try to unsubscribe
-        if request.user.unsubscribe(pagename):
-            request.theme.add_msg(_('Your subscription to this page has been removed.'), "info")
-        else:
-            request.theme.add_msg(_("Can't remove regular expression subscription!") + u' ' + \
-                  _("Edit the subscription regular expressions in your "
-                    "UserPreferences."), "error")
-
+        request.theme.add_msg(_('You are already subscribed to this page.', formatted=False))
     else:
         # Try to subscribe
         if request.user.subscribe(pagename):
@@ -45,4 +38,3 @@
             request.theme.add_msg(_('You could not get subscribed to this page.'), "error")
 
     Page(request, pagename).send_page()
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/unsubscribe.py	Thu Feb 21 20:37:32 2008 +0100
@@ -0,0 +1,30 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - unsubscribe from notifications to a page.
+
+    @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
+                2006 MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+from MoinMoin.Page import Page
+
+def execute(pagename, request):
+    """ Unsubscribe the user from pagename """
+    _ = request.getText
+    cfg = request.cfg
+    msg = None
+
+    if request.user.isSubscribedTo([pagename]):
+        # Try to unsubscribe
+        if request.user.unsubscribe(pagename):
+            msg = _('Your subscription to this page has been removed.', formatted=False)
+        else:
+            msg = _("Can't remove regular expression subscription!", formatted=False) + u' ' + \
+                  _("Edit the subscription regular expressions in your "
+                    "UserPreferences.", formatted=True)
+    else:
+        # The user is not subscribed
+        msg = _('You need to be subscribed to unsubscribe.', formatted=False)
+
+    Page(request, pagename).send_page(msg=msg)
+
--- a/MoinMoin/theme/__init__.py	Thu Feb 21 20:06:02 2008 +0100
+++ b/MoinMoin/theme/__init__.py	Thu Feb 21 20:37:32 2008 +0100
@@ -1230,10 +1230,10 @@
 
         _ = self.request.getText
         if self.request.user.isSubscribedTo([page.page_name]):
-            text = _("Unsubscribe", formatted=False)
+            action, text = 'unsubscribe', _("Unsubscribe", formatted=False)
         else:
-            text = _("Subscribe", formatted=False)
-        return page.link_to(self.request, text=text, querystr={'action': 'subscribe'}, css_class='nbsubscribe', rel='nofollow')
+            action, text = 'subscribe', _("Subscribe", formatted=False)
+        return page.link_to(self.request, text=text, querystr={'action': action}, css_class='nbsubscribe', rel='nofollow')
 
     def quicklinkLink(self, page):
         """ Return add/remove quicklink link