##// END OF EJS Templates
user-audit: share same template for rendering audit logs between user and admin views.
marcink -
r1696:089e4a01 default
parent child Browse files
Show More
@@ -0,0 +1,60 b''
1 <%namespace name="base" file="/base/base.mako"/>
2
3 %if c.audit_logs:
4 <table class="rctable admin_log">
5 <tr>
6 <th>${_('Username')}</th>
7 <th>${_('Action')}</th>
8 <th>${_('Action Data')}</th>
9 <th>${_('Repository')}</th>
10 <th>${_('Date')}</th>
11 <th>${_('IP')}</th>
12 </tr>
13
14 %for cnt,l in enumerate(c.audit_logs):
15 <tr class="parity${cnt%2}">
16 <td class="td-user">
17 %if l.user is not None:
18 ${base.gravatar_with_user(l.user.email)}
19 %else:
20 ${l.username}
21 %endif
22 </td>
23 <td class="td-journalaction">
24 % if l.version == l.VERSION_1:
25 ${h.action_parser(l)[0]()}
26 % else:
27 ${h.literal(l.action)}
28 % endif
29
30 <div class="journal_action_params">
31 % if l.version == l.VERSION_1:
32 ${h.literal(h.action_parser(l)[1]())}
33 % endif
34 </div>
35 </td>
36 <td>
37 % if l.version == l.VERSION_2:
38 ${l.action_data}
39 % endif
40 </td>
41 <td class="td-componentname">
42 %if l.repository is not None:
43 ${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))}
44 %else:
45 ${l.repository_name}
46 %endif
47 </td>
48
49 <td class="td-time">${h.format_date(l.action_date)}</td>
50 <td class="td-ip">${l.user_ip}</td>
51 </tr>
52 %endfor
53 </table>
54
55 <div class="pagination-wh pagination-left">
56 ${c.audit_logs.pager('$link_previous ~2~ $link_next')}
57 </div>
58 %else:
59 ${_('No actions yet')}
60 %endif No newline at end of file
@@ -293,14 +293,14 b' class AdminUsersView(BaseAppView, DataGr'
293 p = safe_int(self.request.GET.get('page', 1), 1)
293 p = safe_int(self.request.GET.get('page', 1), 1)
294
294
295 filter_term = self.request.GET.get('filter')
295 filter_term = self.request.GET.get('filter')
296 c.user_log = UserModel().get_user_log(c.user, filter_term)
296 user_log = UserModel().get_user_log(c.user, filter_term)
297
297
298 def url_generator(**kw):
298 def url_generator(**kw):
299 if filter_term:
299 if filter_term:
300 kw['filter'] = filter_term
300 kw['filter'] = filter_term
301 return self.request.current_route_path(_query=kw)
301 return self.request.current_route_path(_query=kw)
302
302
303 c.user_log = Page(c.user_log, page=p, items_per_page=10,
303 c.audit_logs = Page(user_log, page=p, items_per_page=10,
304 url=url_generator)
304 url=url_generator)
305 c.filter_term = filter_term
305 c.filter_term = filter_term
306 return self._get_template_context(c)
306 return self._get_template_context(c)
@@ -67,7 +67,7 b' class AdminController(BaseController):'
67 def url_generator(**kw):
67 def url_generator(**kw):
68 return url.current(filter=c.search_term, **kw)
68 return url.current(filter=c.search_term, **kw)
69
69
70 c.users_log = Page(users_log, page=p, items_per_page=10,
70 c.audit_logs = Page(users_log, page=p, items_per_page=10,
71 url=url_generator)
71 url=url_generator)
72 c.log_data = render('admin/admin_log.mako')
72 c.log_data = render('admin/admin_log.mako')
73
73
@@ -12,7 +12,7 b''
12 ${h.form(None, id_="filter_form", method="get")}
12 ${h.form(None, id_="filter_form", method="get")}
13 <input class="q_filter_box ${'' if c.search_term else 'initial'}" id="j_filter" size="15" type="text" name="filter" value="${c.search_term or ''}" placeholder="${_('journal filter...')}"/>
13 <input class="q_filter_box ${'' if c.search_term else 'initial'}" id="j_filter" size="15" type="text" name="filter" value="${c.search_term or ''}" placeholder="${_('journal filter...')}"/>
14 <input type='submit' value="${_('filter')}" class="btn" />
14 <input type='submit' value="${_('filter')}" class="btn" />
15 ${_('Admin journal')} - ${ungettext('%s entry', '%s entries', c.users_log.item_count) % (c.users_log.item_count)}
15 ${_('Admin journal')} - ${ungettext('%s entry', '%s entries', c.audit_logs.item_count) % (c.audit_logs.item_count)}
16 ${h.end_form()}
16 ${h.end_form()}
17 <p class="tooltip filterexample" title="${h.tooltip(h.journal_filter_help())}">${_('Example Queries')}</p>
17 <p class="tooltip filterexample" title="${h.tooltip(h.journal_filter_help())}">${_('Example Queries')}</p>
18 </%def>
18 </%def>
@@ -1,64 +1,5 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%namespace name="base" file="/base/base.mako"/>
2 <%include file="/admin/admin_log_base.mako" />
3
4 %if c.users_log:
5 <table class="rctable admin_log">
6 <tr>
7 <th>${_('Username')}</th>
8 <th>${_('Action')}</th>
9 <th>${_('Action Data')}</th>
10 <th>${_('Repository')}</th>
11 <th>${_('Date')}</th>
12 <th>${_('IP')}</th>
13 </tr>
14
15 %for cnt,l in enumerate(c.users_log):
16 <tr class="parity${cnt%2}">
17 <td class="td-user">
18 %if l.user is not None:
19 ${base.gravatar_with_user(l.user.email)}
20 %else:
21 ${l.username}
22 %endif
23 </td>
24 <td class="td-journalaction">
25 % if l.version == l.VERSION_1:
26 ${h.action_parser(l)[0]()}
27 % else:
28 ${h.literal(l.action)}
29 % endif
30
31 <div class="journal_action_params">
32 % if l.version == l.VERSION_1:
33 ${h.literal(h.action_parser(l)[1]())}
34 % endif
35 </div>
36 </td>
37 <td>
38 % if l.version == l.VERSION_2:
39 ${l.action_data}
40 % endif
41 </td>
42 <td class="td-componentname">
43 %if l.repository is not None:
44 ${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))}
45 %else:
46 ${l.repository_name}
47 %endif
48 </td>
49
50 <td class="td-time">${h.format_date(l.action_date)}</td>
51 <td class="td-ip">${l.user_ip}</td>
52 </tr>
53 %endfor
54 </table>
55
56 <div class="pagination-wh pagination-left">
57 ${c.users_log.pager('$link_previous ~2~ $link_next')}
58 </div>
59 %else:
60 ${_('No actions yet')}
61 %endif
62
3
63 <script type="text/javascript">
4 <script type="text/javascript">
64 $(function(){
5 $(function(){
@@ -5,7 +5,7 b''
5 <div class="panel panel-default">
5 <div class="panel panel-default">
6 <div class="panel-heading">
6 <div class="panel-heading">
7 <h3 class="panel-title">${_('User Audit Logs')} -
7 <h3 class="panel-title">${_('User Audit Logs')} -
8 ${_ungettext('%s entry', '%s entries', c.user_log.item_count) % (c.user_log.item_count)}
8 ${_ungettext('%s entry', '%s entries', c.audit_logs.item_count) % (c.audit_logs.item_count)}
9 </h3>
9 </h3>
10 </div>
10 </div>
11 <div class="panel-body">
11 <div class="panel-body">
@@ -16,50 +16,7 b''
16 ${h.end_form()}
16 ${h.end_form()}
17 <p class="tooltip filterexample" style="position: inherit" title="${h.tooltip(h.journal_filter_help())}">${_('Example Queries')}</p>
17 <p class="tooltip filterexample" style="position: inherit" title="${h.tooltip(h.journal_filter_help())}">${_('Example Queries')}</p>
18
18
19 % if c.user_log:
19 <%include file="/admin/admin_log_base.mako" />
20 <table class="rctable admin_log">
21 <tr>
22 <th>${_('Username')}</th>
23 <th>${_('Action')}</th>
24 <th>${_('Repository')}</th>
25 <th>${_('Date')}</th>
26 <th>${_('From IP')}</th>
27 </tr>
28
29 %for cnt,l in enumerate(c.user_log):
30 <tr class="parity${cnt%2}">
31 <td class="td-user">
32 %if l.user is not None:
33 ${base.gravatar_with_user(l.user.email)}
34 %else:
35 ${l.username}
36 %endif
37 </td>
38 <td class="td-journalaction">${h.action_parser(l)[0]()}
39 <div class="journal_action_params">
40 ${h.literal(h.action_parser(l)[1]())}
41 </div>
42 </td>
43 <td class="td-componentname">
44 %if l.repository is not None:
45 ${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))}
46 %else:
47 ${l.repository_name}
48 %endif
49 </td>
50
51 <td class="td-time">${h.format_date(l.action_date)}</td>
52 <td class="td-ip">${l.user_ip}</td>
53 </tr>
54 %endfor
55 </table>
56
57 <div class="pagination-wh pagination-left">
58 ${c.user_log.pager('$link_previous ~2~ $link_next')}
59 </div>
60 % else:
61 ${_('No actions yet')}
62 % endif
63
20
64 </div>
21 </div>
65 </div>
22 </div>
General Comments 0
You need to be logged in to leave comments. Login now