changeset 2024:2d11470eb41b

fix userbrowser, enable/disable user
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 03 Mar 2013 02:25:21 +0100
parents 8300781142e5
children e2a235228c0f
files MoinMoin/apps/admin/templates/admin/userbrowser.html MoinMoin/apps/admin/views.py MoinMoin/storage/middleware/indexing.py
diffstat 3 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/admin/templates/admin/userbrowser.html	Sun Mar 03 01:41:14 2013 +0100
+++ b/MoinMoin/apps/admin/templates/admin/userbrowser.html	Sun Mar 03 02:25:21 2013 +0100
@@ -18,7 +18,7 @@
             {% endif %}
         </td>
         <td>
-            <form action="{{ url_for('admin.userprofile', user_name=u.name) }}" method="GET">
+            <form action="{{ url_for('admin.userprofile', user_name=u.name[0]) }}" method="POST">
                 <input type="hidden" name="key" value="disabled" />
                 <input type="hidden" name="val" value="{{ u.disabled and "0" or "1" }}" />
                 <input type="submit" name="userprofile" value="{{ u.disabled and _("Enable user") or _("Disable user") }}" />
--- a/MoinMoin/apps/admin/views.py	Sun Mar 03 01:41:14 2013 +0100
+++ b/MoinMoin/apps/admin/views.py	Sun Mar 03 02:25:21 2013 +0100
@@ -20,7 +20,7 @@
 from MoinMoin.themes import render_template
 from MoinMoin.apps.admin import admin
 from MoinMoin import user
-from MoinMoin.constants.keys import NAME, ITEMID, SIZE, EMAIL
+from MoinMoin.constants.keys import NAME, ITEMID, SIZE, EMAIL, DISABLED
 from MoinMoin.constants.rights import SUPERUSER
 from MoinMoin.security import require_permission
 
@@ -47,7 +47,7 @@
     user_accounts = [dict(uid=rev.meta[ITEMID],
                           name=rev.meta[NAME],
                           email=rev.meta[EMAIL],
-                          disabled=False,  # TODO: add to index
+                          disabled=rev.meta[DISABLED],
                           groups=[groupname for groupname in groups if rev.meta[NAME] in groups[groupname]],
                      ) for rev in revs]
     return render_template('admin/userbrowser.html', user_accounts=user_accounts, title_name=_(u"Users"))
@@ -70,9 +70,9 @@
         ok = False
         if hasattr(u, key):
             ok = True
-            oldval = getattr(u, key)
+            oldval = u.profile[key]
             if isinstance(oldval, bool):
-                val = bool(val)
+                val = bool(int(val))
             elif isinstance(oldval, int):
                 val = int(val)
             elif isinstance(oldval, unicode):
@@ -80,7 +80,7 @@
             else:
                 ok = False
         if ok:
-            setattr(u, key, val)
+            u.profile[key] = val
             u.save()
             flash(u'{0}.{1}: {2} -> {3}'.format(user_name, key, unicode(oldval), unicode(val), ), "info")
         else:
--- a/MoinMoin/storage/middleware/indexing.py	Sun Mar 03 01:41:14 2013 +0100
+++ b/MoinMoin/storage/middleware/indexing.py	Sun Mar 03 02:25:21 2013 +0100
@@ -74,7 +74,7 @@
 
 from MoinMoin.constants.keys import (WIKINAME, NAMESPACE, NAME, NAME_EXACT, MTIME, CONTENTTYPE, TAGS, LANGUAGE,
                                      USERID, ADDRESS, HOSTNAME, SIZE, ACTION, COMMENT, SUMMARY, CONTENT,
-                                     EXTERNALLINKS, ITEMLINKS, ITEMTRANSCLUSIONS, ACL, EMAIL, OPENID,
+                                     EXTERNALLINKS, ITEMLINKS, ITEMTRANSCLUSIONS, ACL, DISABLED, EMAIL, OPENID,
                                      ITEMID, REVID, CURRENT, PARENTID, PTIME, LATEST_REVS, ALL_REVS, BACKENDNAME)
 from MoinMoin.constants.contenttypes import CONTENTTYPE_USER
 from MoinMoin.constants.namespaces import NAMESPACE_DEFAULT
@@ -320,6 +320,7 @@
             # killing other users from index when update_document() is called!
             EMAIL: ID(stored=True),
             OPENID: ID(stored=True),
+            DISABLED: BOOLEAN(stored=True),
         }
         latest_revs_fields.update(**userprofile_fields)