changeset 4220:39b7dd8d0747

Fixed: userprefs forms and chooser page
author Florian Krupicka <florian.krupicka@googlemail.com>
date Tue, 15 Jul 2008 11:18:04 +0200
parents ce1265ca021a
children f37c12f53bf2
files MoinMoin/action/userprefs.py MoinMoin/userprefs/prefs.py
diffstat 2 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/userprefs.py	Mon Jul 14 19:06:25 2008 +0200
+++ b/MoinMoin/action/userprefs.py	Tue Jul 15 11:18:04 2008 +0200
@@ -68,7 +68,7 @@
     else:
         msg_class, msg = None, None
 
-    sub = request.form.get('sub', '')
+    sub = request.args.get('sub', '')
     cls = None
     if sub and sub not in request.cfg.userprefs_disabled:
         try:
--- a/MoinMoin/userprefs/prefs.py	Mon Jul 14 19:06:25 2008 +0200
+++ b/MoinMoin/userprefs/prefs.py	Tue Jul 15 11:18:04 2008 +0200
@@ -47,7 +47,7 @@
         @rtype: list of unicode strings
         @return: list of normalized names
         """
-        text = self.request.form.get(key, [''])[0]
+        text = self.request.form.get(key, '')
         text = text.replace('\r', '')
         items = []
         for item in text.split('\n'):
@@ -67,7 +67,7 @@
 
         if not 'name' in request.user.auth_attribs:
             # Require non-empty name
-            new_name = form.get('name', [request.user.name])[0]
+            new_name = form.get('name', request.user.name)
 
             # Don't allow changing the name to an invalid one
             if not user.isValidName(request, new_name):
@@ -90,7 +90,7 @@
 
         if not 'email' in request.user.auth_attribs:
             # try to get the email
-            new_email = wikiutil.clean_input(form.get('email', [request.user.email])[0])
+            new_email = wikiutil.clean_input(form.get('email', request.user.email))
             new_email = new_email.strip()
 
             # Require email
@@ -110,7 +110,7 @@
 
         if not 'jid' in request.user.auth_attribs:
             # try to get the jid
-            new_jid = wikiutil.clean_input(form.get('jid', [''])[0]).strip()
+            new_jid = wikiutil.clean_input(form.get('jid', '')).strip()
 
             jid_changed = request.user.jid != new_jid
             previous_jid = request.user.jid
@@ -132,15 +132,15 @@
 
         if not 'aliasname' in request.user.auth_attribs:
             # aliasname
-            request.user.aliasname = wikiutil.clean_input(form.get('aliasname', [''])[0])
+            request.user.aliasname = wikiutil.clean_input(form.get('aliasname', ''))
 
         # editor size
         request.user.edit_rows = util.web.getIntegerInput(request, 'edit_rows',
                                                           request.user.edit_rows, 10, 60)
 
         # try to get the editor
-        request.user.editor_default = form.get('editor_default', [self.cfg.editor_default])[0]
-        request.user.editor_ui = form.get('editor_ui', [self.cfg.editor_ui])[0]
+        request.user.editor_default = form.get('editor_default', self.cfg.editor_default)
+        request.user.editor_ui = form.get('editor_ui', self.cfg.editor_ui)
 
         # time zone
         request.user.tz_offset = util.web.getIntegerInput(request, 'tz_offset',
@@ -148,14 +148,14 @@
 
         # datetime format
         try:
-            dt_d_combined = Settings._date_formats.get(form['datetime_fmt'][0], '')
+            dt_d_combined = Settings._date_formats.get(form['datetime_fmt'], '')
             request.user.datetime_fmt, request.user.date_fmt = dt_d_combined.split(' & ')
         except (KeyError, ValueError):
             request.user.datetime_fmt = '' # default
             request.user.date_fmt = '' # default
 
         # try to get the (optional) theme
-        theme_name = form.get('theme_name', [self.cfg.theme_default])[0]
+        theme_name = form.get('theme_name', self.cfg.theme_default)
         if theme_name != request.user.theme_name:
             # if the theme has changed, load the new theme
             # so the user has a direct feedback
@@ -169,7 +169,7 @@
                 return 'error', _("The theme '%(theme_name)s' could not be loaded!") % locals()
 
         # try to get the (optional) preferred language
-        request.user.language = form.get('language', [''])[0]
+        request.user.language = form.get('language', '')
         if request.user.language == u'': # For language-statistics
             from MoinMoin import i18n
             request.user.real_language = i18n.get_browser_language(request)
@@ -194,13 +194,13 @@
                 or (key in already_handled)):
                 continue
             default = self.cfg.user_form_defaults[key]
-            value = form.get(key, [default])[0]
+            value = form.get(key, default)
             setattr(request.user, key, value)
 
         # checkbox options
         for key, label in self.cfg.user_checkbox_fields:
             if key not in self.cfg.user_checkbox_disable and key not in self.cfg.user_checkbox_remove:
-                value = form.get(key, ["0"])[0]
+                value = form.get(key, "0")
                 try:
                     value = int(value)
                 except ValueError:
@@ -228,10 +228,10 @@
         _ = self._
         form = self.request.form
 
-        if form.has_key('cancel'):
+        if 'cancel' in form:
             return
 
-        if form.has_key('save'): # Save user profile
+        if 'save' in form: # Save user profile
             return self._save_user_prefs()
 
     # form generation part