view MoinMoin/action/ @ 3521:c9f5e4f9a76e

action bookmark, subscribe, unsubscribe, userprefs: check for valid.user
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 26 Apr 2008 11:12:30 +0200
parents 928a45b60bb3
children 74f42592c7a0
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - unsubscribe from notifications to a page.

    @copyright: 2000-2004 Juergen Hermann <>,
                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
    actname = __name__.split('.')[-1]
    if not request.user.valid:
        request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
        return Page(request, pagename).send_page()

    msg = None

    if request.user.isSubscribedTo([pagename]):
        # Try to unsubscribe
        if request.user.unsubscribe(pagename):
            msg = _('Your subscription to this page has been removed.')
            msg = _("Can't remove regular expression subscription!") + u' ' + \
                  _("Edit the subscription regular expressions in your settings.")
        # The user is not subscribed
        msg = _('You need to be subscribed to unsubscribe.')

    Page(request, pagename).send_page(msg=msg)