~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/action/unsubscribe.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - unsubscribe from notifications to a page.
 
4
 
 
5
    @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
 
6
                2006 MoinMoin:ThomasWaldmann
 
7
    @license: GNU GPL, see COPYING for details.
 
8
"""
 
9
from MoinMoin.Page import Page
 
10
 
 
11
def execute(pagename, request):
 
12
    """ Unsubscribe the user from pagename """
 
13
    _ = request.getText
 
14
    if not request.user.valid:
 
15
        actname = __name__.split('.')[-1]
 
16
        request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
 
17
        return Page(request, pagename).send_page()
 
18
 
 
19
    msg = None
 
20
 
 
21
    if request.user.isSubscribedTo([pagename]):
 
22
        # Try to unsubscribe
 
23
        if request.user.unsubscribe(pagename):
 
24
            msg = _('Your subscription to this page has been removed.')
 
25
        else:
 
26
            msg = _("Can't remove regular expression subscription!") + u' ' + \
 
27
                  _("Edit the subscription regular expressions in your settings.")
 
28
    else:
 
29
        # The user is not subscribed
 
30
        msg = _('You need to be subscribed to unsubscribe.')
 
31
 
 
32
    Page(request, pagename).send_page(msg=msg)
 
33