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