You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/09/22 12:27:47 UTC
[06/31] git commit: [#7657] ticket:650 Add comment form to audit log
[#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/8fb16100
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8fb16100
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8fb16100
Branch: refs/heads/je/42cc_7657b
Commit: 8fb1610069a356f1694ea5d47326f3c4dad5c077
Parents: ec0e673
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Sep 12 15:08:20 2014 +0300
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Sep 22 11:05:37 2014 +0300
----------------------------------------------------------------------
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/8fb16100/Allura/allura/controllers/site_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 947de38..4a034d7 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -504,7 +504,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)
@@ -538,6 +538,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/8fb16100/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 %}