# HG changeset patch # User Marcin Kuzminski # Date 2017-04-26 21:05:03 # Node ID 089e4a015b7aa1f71c3a6a5b9a4349f9b48dcfe3 # Parent afa71a5db10f33ab099f22788128ff6d31f7664c user-audit: share same template for rendering audit logs between user and admin views. diff --git a/rhodecode/apps/admin/views/users.py b/rhodecode/apps/admin/views/users.py --- a/rhodecode/apps/admin/views/users.py +++ b/rhodecode/apps/admin/views/users.py @@ -293,14 +293,14 @@ class AdminUsersView(BaseAppView, DataGr p = safe_int(self.request.GET.get('page', 1), 1) filter_term = self.request.GET.get('filter') - c.user_log = UserModel().get_user_log(c.user, filter_term) + user_log = UserModel().get_user_log(c.user, filter_term) def url_generator(**kw): if filter_term: kw['filter'] = filter_term return self.request.current_route_path(_query=kw) - c.user_log = Page(c.user_log, page=p, items_per_page=10, + c.audit_logs = Page(user_log, page=p, items_per_page=10, url=url_generator) c.filter_term = filter_term return self._get_template_context(c) diff --git a/rhodecode/controllers/admin/admin.py b/rhodecode/controllers/admin/admin.py --- a/rhodecode/controllers/admin/admin.py +++ b/rhodecode/controllers/admin/admin.py @@ -67,7 +67,7 @@ class AdminController(BaseController): def url_generator(**kw): return url.current(filter=c.search_term, **kw) - c.users_log = Page(users_log, page=p, items_per_page=10, + c.audit_logs = Page(users_log, page=p, items_per_page=10, url=url_generator) c.log_data = render('admin/admin_log.mako') diff --git a/rhodecode/templates/admin/admin.mako b/rhodecode/templates/admin/admin.mako --- a/rhodecode/templates/admin/admin.mako +++ b/rhodecode/templates/admin/admin.mako @@ -12,7 +12,7 @@ ${h.form(None, id_="filter_form", method="get")} - ${_('Admin journal')} - ${ungettext('%s entry', '%s entries', c.users_log.item_count) % (c.users_log.item_count)} + ${_('Admin journal')} - ${ungettext('%s entry', '%s entries', c.audit_logs.item_count) % (c.audit_logs.item_count)} ${h.end_form()}

${_('Example Queries')}

diff --git a/rhodecode/templates/admin/admin_log.mako b/rhodecode/templates/admin/admin_log.mako --- a/rhodecode/templates/admin/admin_log.mako +++ b/rhodecode/templates/admin/admin_log.mako @@ -1,64 +1,5 @@ ## -*- coding: utf-8 -*- -<%namespace name="base" file="/base/base.mako"/> - -%if c.users_log: - - - - - - - - - - - %for cnt,l in enumerate(c.users_log): - - - - - - - - - - %endfor -
${_('Username')}${_('Action')}${_('Action Data')}${_('Repository')}${_('Date')}${_('IP')}
- %if l.user is not None: - ${base.gravatar_with_user(l.user.email)} - %else: - ${l.username} - %endif - - % if l.version == l.VERSION_1: - ${h.action_parser(l)[0]()} - % else: - ${h.literal(l.action)} - % endif - -
- % if l.version == l.VERSION_1: - ${h.literal(h.action_parser(l)[1]())} - % endif -
-
- % if l.version == l.VERSION_2: - ${l.action_data} - % endif - - %if l.repository is not None: - ${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))} - %else: - ${l.repository_name} - %endif - ${h.format_date(l.action_date)}${l.user_ip}
- -
-${c.users_log.pager('$link_previous ~2~ $link_next')} -
-%else: - ${_('No actions yet')} -%endif +<%include file="/admin/admin_log_base.mako" />