allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [08/27] git commit: [#7657] ticket:650 Add audit log to user details page
Date Wed, 01 Oct 2014 11:23:49 GMT
[#7657] ticket:650 Add audit log to user details page


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

Branch: refs/heads/master
Commit: e11c61b2107579b28d053ad762354f2af946cf95
Parents: 36de025
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Sep 12 14:04:20 2014 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Wed Oct 1 10:26:40 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py         | 28 +++++++++++++++++++-
 .../ext/admin/templates/widgets/audit.html      |  4 +--
 .../templates/site_admin_user_details.html      | 22 +++++++++++++++
 3 files changed, 51 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e11c61b2/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index b61db8b..52b4d0f 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -505,16 +505,42 @@ class StatsController(object):
 class AdminUserDetailsController(object):
 
     @expose('jinja:allura:templates/site_admin_user_details.html')
-    def _default(self, username):
+    def _default(self, username, limit=25, page=0):
         user = M.User.by_username(username)
         if not user:
             raise HTTPNotFound()
         projects = user.my_projects().all()
+        audit_log = self._audit_log(user, limit, page)
         return {
             'user': user,
             'projects': projects,
+            'audit_log': audit_log,
         }
 
+    def _audit_log(self, user, limit, page):
+        limit = int(limit)
+        page = int(page)
+        if user is None or user.is_anonymous():
+            return dict(
+                entries=[],
+                imit=limit,
+                page=page,
+                count=0)
+        q = M.AuditLog.for_user(user)
+        count = q.count()
+        q = q.sort('timestamp', -1)
+        q = q.skip(page * limit)
+        if count > limit:
+            q = q.limit(limit)
+        else:
+            limit = count
+        c.audit_log_widget = W.audit
+        return dict(
+            entries=q.all(),
+            limit=limit,
+            page=page,
+            count=count)
+
 
 class StatsSiteAdminExtension(SiteAdminExtension):
     controllers = {'stats': StatsController}

http://git-wip-us.apache.org/repos/asf/allura/blob/e11c61b2/Allura/allura/ext/admin/templates/widgets/audit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/widgets/audit.html b/Allura/allura/ext/admin/templates/widgets/audit.html
index 0339be8..5c9dc68 100644
--- a/Allura/allura/ext/admin/templates/widgets/audit.html
+++ b/Allura/allura/ext/admin/templates/widgets/audit.html
@@ -16,7 +16,7 @@
        specific language governing permissions and limitations
        under the License.
 -#}
-<div class="grid-19">
+<div class="grid-{{ grid if grid else '19' }}">
   <div style="overflow:auto">
     <table>
       <thead>
@@ -44,7 +44,7 @@
     </table>
   </div>
 </div>
-<div class="grid-19" style="clear:both">
+<div class="grid-{{ grid if grid else '19' }}" style="clear:both">
   {{widget.fields.page_list.display(limit=limit, page=page, count=count)}}
   {{widget.fields.page_size.display(limit=limit, count=count)}}
 </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/e11c61b2/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 f86e75c..689e295 100644
--- a/Allura/allura/templates/site_admin_user_details.html
+++ b/Allura/allura/templates/site_admin_user_details.html
@@ -60,6 +60,18 @@
   {% block extra_info %}
   {% endblock extra_info %}
 
+  {% block audit_log %}
+    <div class="grid-23">
+      {% set al = audit_log %}
+      <fieldset>
+        <legend>Audit log</legend>
+        {% if al['entries'] %}
+          {{ c.audit_log_widget.display(entries=al['entries'], limit=al['limit'], page=al['page'],
count=al['count'], grid='22') }}
+        {% endif %}
+      </fieldset>
+    </div>
+  {% endblock audit_log %}
+
   {% block user_projects %}
     <div class="grid-23">
       <fieldset>
@@ -73,3 +85,13 @@
     </div>
   {% endblock user_projects %}
 {% endblock %}
+
+{% block extra_css %}
+{{ super() }}
+<style>
+.pad table {
+  width: 860px;
+  margin-left: 0;
+}
+</style>
+{% endblock %}


Mime
View raw message