Attachment 'MakeInvitation_v1.7.2.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - MakeInvitation macro
   4 
   5     Syntax:
   6         <<MakeInvitation>>
   7 
   8     Lot of code take from userform.py
   9     MoinMoin - userform.py
  10     @copyright: 2001-2004 by Jürgen Hermann <jh@web.de> (for v. 1.5.4)
  11     @license: GNU GPL, see COPYING for details.
  12     
  13     MoinMoin - MakeInvitation Macro
  14     @copyright: 2006 by Oliver Siemoneit (for v. 1.6.x)
  15     @copyright: 2008 by Renard (for v. 1.7.2)
  16     @license: GNU GPL, see COPYING for details.
  17 """
  18 
  19 from MoinMoin.widget import html
  20 
  21 
  22 def make_row(table, label, cell, **kw):
  23     """ Create a row in the form table.
  24     """
  25     table.append(html.TR().extend([
  26         html.TD(**kw).extend([html.B().append(label), '   ']),
  27         html.TD().extend(cell),
  28     ]))
  29     return table
  30 
  31 def execute(macro, args):
  32     request = macro.request
  33     _ = request.getText
  34     formatter = macro.formatter
  35 
  36     # Check if user is superuser. If not: return with error msg
  37     if not request.user.isSuperUser():
  38         err = _('You are not allowed to perform this action.')
  39         return err
  40 
  41     sn = request.getScriptname()
  42     pi = request.getPathinfo()
  43     action = u"%s%s" % (sn, pi)
  44     form = html.FORM(action=action)
  45     table = html.TABLE(border="0")
  46 
  47     # Create 6 digits dummy password
  48     from random import choice
  49     letters = "abcdefghijklmnopqrstuvwxyz"
  50     letters += "0123456789"
  51     pwd = ''
  52     for i in range(6):
  53         pwd += choice(letters)
  54         
  55     # Add form fields                
  56     for key, label, type, length, textafter in request.cfg.user_form_fields:
  57         if key in ('name', 'email'):
  58             table = make_row(table, _(label),
  59                   [ html.INPUT(type=type, size=length, name=key,
  60                                value=''),
  61                     ' ', _(textafter), ])
  62 
  63     table = make_row(table, _('Password'),
  64           [ html.INPUT(type="password", size=36, name="password1",
  65                        value='%s' % pwd),
  66             ' ',])
  67     table = make_row(table, _('Password repeat'),
  68           [ html.INPUT(type="password", size=36, name="password2",
  69                        value='%s' % pwd),
  70             ' ',])
  71     # Add buttons
  72     buttons = []
  73     if request.cfg.mail_enabled:
  74         buttons.append(("create_only", "%s" %
  75                         (_('Create Profile'))))
  76         buttons.append(("create_and_mail", "%s + %s" %
  77                         (_('Create Profile'), _('Email'))))
  78 
  79     buttons.append(('cancel', _('Cancel')))
  80 
  81     button_cell = []
  82     for name, label in buttons:
  83         if not name in request.cfg.user_form_remove:
  84             button_cell.extend([
  85                 html.INPUT(type="submit", name=name, value=label),
  86                 ' ',
  87             ])
  88     make_row(table,'', button_cell)
  89 
  90 
  91     # Use the user interface language and direction
  92     lang_attr = request.theme.ui_lang_attr()
  93     form.append(html.Raw('<div class="userprefs"%s>' % lang_attr))
  94     form.append(html.INPUT(type="hidden", name="action", value="newaccount"))
  95     form.append(table)
  96     form.append(html.Raw("</div>"))
  97    
  98     return unicode(form)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-11-25 20:10:35, 1.4 KB) [[attachment:MakeInvitation.py]]
  • [get | view] (2006-12-10 22:20:31, 1.1 KB) [[attachment:MakeInvitation.txt]]
  • [get | view] (2006-12-10 22:20:06, 2.8 KB) [[attachment:MakeInvitation1-6-dev.py]]
  • [get | view] (2008-11-20 08:40:46, 9.3 KB) [[attachment:MakeInvitation_v1.7.2.gif]]
  • [get | view] (2008-11-20 07:33:50, 3.0 KB) [[attachment:MakeInvitation_v1.7.2.py]]
  • [get | view] (2008-11-20 07:34:07, 1.2 KB) [[attachment:MakeInvitation_v1.7.2.txt]]
  • [get | view] (2006-12-10 22:19:33, 2.5 KB) [[attachment:mailAccountData.py]]
  • [get | view] (2006-11-25 20:10:53, 2.3 KB) [[attachment:moin1-5-4-1user.diff]]
  • [get | view] (2006-11-25 20:13:16, 4.1 KB) [[attachment:moin1-5-4-1userform.diff]]
  • [get | view] (2006-12-10 22:19:03, 2.2 KB) [[attachment:user-1-6-dev.diff]]
  • [get | view] (2006-11-25 20:12:10, 33.3 KB) [[attachment:user_moin1-5-4-1_patched.py]]
  • [get | view] (2006-12-10 22:18:31, 1.0 KB) [[attachment:userform.diff]]
  • [get | view] (2006-11-25 20:12:52, 31.5 KB) [[attachment:userform_moin1-5-4-1_patched.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.