allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/4] allura git commit: [#7816] ticket:713 Add status to admin user search & refactoring
Date Thu, 15 Jan 2015 18:29:38 GMT
[#7816] ticket:713 Add status to admin user search & refactoring


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/24ddf594
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/24ddf594
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/24ddf594

Branch: refs/heads/master
Commit: 24ddf594ada7323dc84483a6ff5aa3eee8124438
Parents: ca260f3
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Wed Jan 14 11:25:39 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Jan 14 11:25:39 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         |  2 ++
 Allura/allura/lib/helpers.py                    | 21 ++++++++++++++++++++
 .../site_admin_search_users_results.html        |  4 ++--
 .../templates/site_admin_user_details.html      |  6 +++---
 4 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/24ddf594/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 043678a..d284113 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -325,6 +325,7 @@ class SiteAdminController(object):
         fields = [('username', 'username'), ('display_name', 'display name')]
         add_fields = aslist(tg.config.get('search.user.additional_search_fields'), ',')
         r = self._search(M.User, fields, add_fields, q, f, page, limit, **kw)
+        r['objects'] = [dict(u, status=h.get_user_status(u)) for u in r['objects']]
         r['search_results_template'] = 'allura:templates/site_admin_search_users_results.html'
         r['additional_display_fields'] = \
             aslist(tg.config.get('search.user.additional_display_fields'), ',')
@@ -471,6 +472,7 @@ class AdminUserDetailsController(object):
         audit_log = self._audit_log(user, limit, page)
         info = {
             'user': user,
+            'status': h.get_user_status(user),
             'projects': projects,
             'audit_log': audit_log,
         }

http://git-wip-us.apache.org/repos/asf/allura/blob/24ddf594/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 3b6a1d5..ad238e3 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -1209,3 +1209,24 @@ def auditlog_user(message, *args, **kwargs):
         message = 'Done by user: {}\n'.format(c.user.username) + message
     return M.AuditLog.log_user(message, *args, **kwargs)
 
+
+def get_user_status(user):
+    '''
+    Get user status based on disabled and pending attrs
+
+    :param user: a dict or :class:`allura.model.auth.User`
+    '''
+    from allura import model as M
+    if isinstance(user, M.User):
+        disabled = user.disabled
+        pending = user.pending
+    else:
+        disabled = user['disabled']
+        pending = user['pending']
+
+    if not disabled and not pending:
+        return 'enabled'
+    elif disabled:
+        return 'disabled'
+    elif pending:
+        return 'pending'

http://git-wip-us.apache.org/repos/asf/allura/blob/24ddf594/Allura/allura/templates/site_admin_search_users_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_search_users_results.html b/Allura/allura/templates/site_admin_search_users_results.html
index c718b02..bbb0693 100644
--- a/Allura/allura/templates/site_admin_search_users_results.html
+++ b/Allura/allura/templates/site_admin_search_users_results.html
@@ -21,7 +21,7 @@
   <th>Display name</th>
   <th>Email</th>
   <th>Registered</th>
-  <th>Disabled?</th>
+  <th>Status</th>
   {% for field in additional_display_fields %}
   <th>{{ field }}</th>
   {% endfor %}
@@ -34,7 +34,7 @@
   <td>{{ u['display_name'] }}</td>
   <td>{{ u['object'].get_pref('email_address') }}</td>
   <td>{{ h.ago(provider.user_registration_date(u['object']).replace(tzinfo=None)) }}</td>
-  <td>{{ u['disabled'] }}</td>
+  <td>{{ u['status'] }}</td>
   {% for field in additional_display_fields %}
   <td>{{ u[field] }}</td>
   {% endfor %}

http://git-wip-us.apache.org/repos/asf/allura/blob/24ddf594/Allura/allura/templates/site_admin_user_details.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/site_admin_user_details.html b/Allura/allura/templates/site_admin_user_details.html
index f5a8d2d..1288ecb 100644
--- a/Allura/allura/templates/site_admin_user_details.html
+++ b/Allura/allura/templates/site_admin_user_details.html
@@ -42,9 +42,9 @@
         <div class="grid-6">
         <form action='/nf/admin/user/set_status' method="POST">
           <div class='grid-6'>
-            <label><input type="radio" name="status" value="enable"{% if not user.disabled
and not user.pending %} checked="checked"{% endif %}>Enabled</label><br>
-            <label><input type="radio" name="status" value="disable"{% if user.disabled
%} checked="checked"{% endif %}>Disabled</label><br>
-            <label><input type="radio" name="status" value="pending"{% if user.pending
and not user.disabled %} checked="checked"{% endif %}>Pending</label>
+            <label><input type="radio" name="status" value="enable"{% if status
== 'enabled' %} checked="checked"{% endif %}>Enabled</label><br>
+            <label><input type="radio" name="status" value="disable"{% if status
== 'disabled' %} checked="checked"{% endif %}>Disabled</label><br>
+            <label><input type="radio" name="status" value="pending"{% if status
== 'pending' %} checked="checked"{% endif %}>Pending</label>
           </div>
           <input type='hidden' name='username' value='{{ user.username }}'>
           {{lib.csrf_token()}}


Mime
View raw message