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

« back to all changes in this revision

Viewing changes to MoinMoin/action/subscribe.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 - subscribe to a page to get notified when it changes
 
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
    """ Subscribe the user to 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
    cfg = request.cfg
 
20
 
 
21
    if not request.user.may.read(pagename):
 
22
        request.theme.add_msg(_("You are not allowed to subscribe to a page you can't read."), "error")
 
23
 
 
24
    # Check if mail is enabled
 
25
    elif not cfg.mail_enabled and not cfg.jabber_enabled:
 
26
        request.theme.add_msg(_("This wiki is not enabled for mail/Jabber processing."), "error")
 
27
 
 
28
    # Suggest visitors to login
 
29
    elif not request.user.valid:
 
30
        request.theme.add_msg(_("You must log in to use subscriptions."), "error")
 
31
 
 
32
    # Suggest users without email to add their email address
 
33
    elif not request.user.email and not request.user.jid:
 
34
        request.theme.add_msg(_("Add your email address or Jabber ID in your user settings to use subscriptions."),
 
35
                              "error")
 
36
 
 
37
    elif request.user.isSubscribedTo([pagename]):
 
38
        request.theme.add_msg(_('You are already subscribed to this page.'))
 
39
    else:
 
40
        # Try to subscribe
 
41
        if request.user.subscribe(pagename):
 
42
            request.theme.add_msg(_('You have been subscribed to this page.'), "info")
 
43
        else: # should not happen
 
44
            request.theme.add_msg(_('You could not get subscribed to this page.'), "error")
 
45
 
 
46
    Page(request, pagename).send_page()