Back to index

moin  1.9.0~rc2
unsubscribe.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - unsubscribe from notifications to a page.
00004 
00005     @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
00006                 2006 MoinMoin:ThomasWaldmann
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 from MoinMoin.Page import Page
00010 
00011 def execute(pagename, request):
00012     """ Unsubscribe the user from pagename """
00013     _ = request.getText
00014     if not request.user.valid:
00015         actname = __name__.split('.')[-1]
00016         request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
00017         return Page(request, pagename).send_page()
00018 
00019     if request.user.isSubscribedTo([pagename]):
00020         # Try to unsubscribe
00021         if request.user.unsubscribe(pagename):
00022             request.theme.add_msg(_('Your subscription to this page has been removed.'), "info")
00023         else:
00024             msg = _("Can't remove regular expression subscription!") + u' ' + \
00025                   _("Edit the subscription regular expressions in your settings.")
00026             request.theme.add_msg(msg, "error")
00027     else:
00028         # The user is not subscribed
00029         request.theme.add_msg(_('You need to be subscribed to unsubscribe.'), "info")
00030     Page(request, pagename).send_page()
00031