changeset 2365:b9feee61d28e

split newaccount form from prefs
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 12 Jul 2007 11:40:04 +0200
parents 96ec23afac7d
children 2f36b737022a
files MoinMoin/action/newaccount.py MoinMoin/userprefs/prefs.py
diffstat 2 files changed, 59 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/newaccount.py	Thu Jul 12 11:39:35 2007 +0200
+++ b/MoinMoin/action/newaccount.py	Thu Jul 12 11:40:04 2007 +0200
@@ -10,7 +10,6 @@
 from MoinMoin.Page import Page
 from MoinMoin.widget import html
 import MoinMoin.events as events
-from MoinMoin.userprefs.prefs import Settings
 
 
 _debug = False
@@ -90,6 +89,59 @@
     return result
 
 
+def _create_form(request):
+    _ = request.getText
+    url = request.page.url(request)
+    ret = html.FORM(action=url)
+    ret.append(html.INPUT(type='hidden', name='action', value='newaccount'))
+    lang_attr = request.theme.ui_lang_attr()
+    ret.append(html.Raw('<div class="userpref"%s>' % lang_attr))
+    tbl = html.TABLE(border="0")
+    ret.append(tbl)
+    ret.append(html.Raw('</div>'))
+
+    row = html.TR()
+    tbl.append(row)
+    row.append(html.TD().append(html.STRONG().append(
+                                  html.Text(_("Name")))))
+    row.append(html.TD().append(html.INPUT(type="text", size="36",
+                                           name="name")))
+
+    row = html.TR()
+    tbl.append(row)
+    row.append(html.TD().append(html.STRONG().append(
+                                  html.Text(_("Password")))))
+    row.append(html.TD().append(html.INPUT(type="password", size="36",
+                                           name="password")))
+
+    row = html.TR()
+    tbl.append(row)
+    row.append(html.TD().append(html.STRONG().append(
+                                  html.Text(_("Password repeat")))))
+    row.append(html.TD().append(html.INPUT(type="password", size="36",
+                                           name="password2")))
+
+    row = html.TR()
+    tbl.append(row)
+    row.append(html.TD().append(html.STRONG().append(html.Text(_("Email")))))
+    row.append(html.TD().append(html.INPUT(type="text", size="36",
+                                           name="email")))
+
+    row = html.TR()
+    tbl.append(row)
+    row.append(html.TD())
+    td = html.TD()
+    row.append(td)
+    td.append(html.INPUT(type="submit", name="create_only",
+                         value=_('Create Profile')))
+    if request.cfg.mail_enabled:
+        td.append(html.Text(' '))
+        td.append(html.INPUT(type="submit", name="create_and_mail",
+                             value="%s + %s" % (_('Create Profile'),
+                                                _('Email'))))
+
+    return unicode(ret)
+
 def execute(pagename, request):
     pagename = pagename
     page = Page(request, pagename)
@@ -108,7 +160,7 @@
         request.write(request.formatter.startContent("content"))
 
         # THIS IS A BIG HACK. IT NEEDS TO BE CLEANED UP
-        request.write(Settings(request).create_form(create_only=True))
+        request.write(_create_form(request))
 
         request.write(request.formatter.endContent())
 
--- a/MoinMoin/userprefs/prefs.py	Thu Jul 12 11:39:35 2007 +0200
+++ b/MoinMoin/userprefs/prefs.py	Thu Jul 12 11:40:04 2007 +0200
@@ -16,11 +16,11 @@
 #################################################################
 # This is a mess.
 #
-# This plugin is also used by the 'recoverpass' and 'newaccount'
-# actions, and really shouldn't be.
+# This plugin is also used by the 'newaccount'
+# action and really shouldn't be.
 #
 # The plan for refactoring would be:
-#  1. make the mentioned actions create their own forms and not
+#  1. make the 'newaccount' action create its own form and not
 #     use the code here
 #  2. split the plugin into multiple preferences pages:
 #    - account details (name, email, timezone, ...)
@@ -376,12 +376,12 @@
         ]))
 
 
-    def create_form(self, create_only=False, recover_only=False):
+    def create_form(self, recover_only=False):
         """ Create the complete HTML form code. """
         _ = self._
         self._make_form()
 
-        if self.request.user.valid and not create_only and not recover_only:
+        if self.request.user.valid and not recover_only:
             buttons = [('save', _('Save')), ('cancel', _('Cancel')), ]
             uf_remove = self.cfg.user_form_remove
             uf_disable = self.cfg.user_form_disable
@@ -505,12 +505,6 @@
         if recover_only and self.cfg.mail_enabled:
             buttons.append(("account_sendmail", _('Mail me my account data')))
 
-        if create_only:
-            buttons = [("create_only", _('Create Profile'))]
-            if self.cfg.mail_enabled:
-                buttons.append(("create_and_mail", "%s + %s" %
-                                (_('Create Profile'), _('Email'))))
-
         # Add buttons
         button_cell = []
         for name, label in buttons: