# HG changeset patch # User Marcin Kuzminski # Date 2017-06-23 10:22:39 # Node ID b61778628941982711eed3d1d8b80defa22155cc # Parent 56150ab5f307b97ed94605c9ade754f6b2a45558 audit-logs: don't use old style parser for new audit logs. diff --git a/rhodecode/lib/action_parser.py b/rhodecode/lib/action_parser.py --- a/rhodecode/lib/action_parser.py +++ b/rhodecode/lib/action_parser.py @@ -42,8 +42,13 @@ def action_parser(user_log, feed=False, :param feed: use output for feeds (no html and fancy icons) :param parse_cs: parse Changesets into VCS instances """ - ap = ActionParser(user_log, feed=False, parse_commits=False) - return ap.callbacks() + if user_log.version == 'v2': + ap = AuditLogParser(user_log) + return ap.callbacks() + else: + # old style + ap = ActionParser(user_log, feed=False, parse_commits=False) + return ap.callbacks() class ActionParser(object): @@ -304,6 +309,34 @@ class ActionParser(object): return self.user_log.repository is None +class AuditLogParser(object): + def __init__(self, audit_log_entry): + self.audit_log_entry = audit_log_entry + + def get_icon(self, action): + return 'icon-rhodecode' + + def callbacks(self): + action_str = self.audit_log_entry.action + + def callback(): + # returned callbacks we need to call to get + action = action_str \ + .replace('[', '')\ + .replace(']', '') + return literal(action) + + def icon(): + tmpl = """""" + ico = self.get_icon(action_str) + return literal(tmpl % (ico, action_str)) + + action_params_func = _no_params_func + + return [ + callback, action_params_func, icon] + + def _no_params_func(): return ""