allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [07/27] git commit: [#7657] ticket:650 Add comment form to audit log
Date Mon, 29 Sep 2014 16:17:38 GMT
[#7657] ticket:650 Add comment form to audit log


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

Branch: refs/heads/db/7657
Commit: fd8dec2a094a428f6945f11212b197499baf1a0d
Parents: 90835eb
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Sep 12 15:08:20 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Sep 26 16:39:44 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/site_admin.py              | 15 ++++++++++++++-
 Allura/allura/templates/site_admin_user_details.html | 13 +++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fd8dec2a/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 52b4d0f..ad224f4 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -507,7 +507,7 @@ class AdminUserDetailsController(object):
     @expose('jinja:allura:templates/site_admin_user_details.html')
     def _default(self, username, limit=25, page=0):
         user = M.User.by_username(username)
-        if not user:
+        if not user or user.is_anonymous():
             raise HTTPNotFound()
         projects = user.my_projects().all()
         audit_log = self._audit_log(user, limit, page)
@@ -541,6 +541,19 @@ class AdminUserDetailsController(object):
             page=page,
             count=count)
 
+    @expose()
+    @require_post()
+    def add_audit_trail_entry(self, **kw):
+        username = kw.get('username')
+        comment = kw.get('comment')
+        user = M.User.by_username(username)
+        if user and not user.is_anonymous() and comment:
+            M.AuditLog.comment_user(c.user, comment, user=user)
+            flash('Comment added', 'ok')
+        else:
+            flash('Can not add comment "%s" for user %s' % (comment, user))
+        redirect(request.referer)
+
 
 class StatsSiteAdminExtension(SiteAdminExtension):
     controllers = {'stats': StatsController}

http://git-wip-us.apache.org/repos/asf/allura/blob/fd8dec2a/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 689e295..bfd17e7 100644
--- a/Allura/allura/templates/site_admin_user_details.html
+++ b/Allura/allura/templates/site_admin_user_details.html
@@ -65,6 +65,19 @@
       {% set al = audit_log %}
       <fieldset>
         <legend>Audit log</legend>
+        <form action='/nf/admin/user/add_audit_trail_entry' method='POST'>
+          <div class='grid-22'>
+            <label for='comment'>Comment:</label>
+          </div>
+          <div class='grid-22'>
+            <textarea name="comment" cols="38" rows="5"></textarea>
+          </div>
+          <div class='grid-5'>
+            <input type='hidden' name='username' value='{{ user.username }}'>
+            <input type='submit' value='Add comment'>
+            {{lib.csrf_token()}}
+          </div>
+        </form>
         {% if al['entries'] %}
           {{ c.audit_log_widget.display(entries=al['entries'], limit=al['limit'], page=al['page'],
count=al['count'], grid='22') }}
         {% endif %}


Mime
View raw message