audit-logs: don't use old style parser for new audit logs.
This commit is contained in:
parent
c315ee8d30
commit
ccf69ffec7
1 changed files with 35 additions and 2 deletions
|
|
@ -42,8 +42,13 @@ def action_parser(user_log, feed=False, parse_cs=False):
|
||||||
:param feed: use output for feeds (no html and fancy icons)
|
:param feed: use output for feeds (no html and fancy icons)
|
||||||
:param parse_cs: parse Changesets into VCS instances
|
:param parse_cs: parse Changesets into VCS instances
|
||||||
"""
|
"""
|
||||||
ap = ActionParser(user_log, feed=False, parse_commits=False)
|
if user_log.version == 'v2':
|
||||||
return ap.callbacks()
|
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):
|
class ActionParser(object):
|
||||||
|
|
@ -304,6 +309,34 @@ class ActionParser(object):
|
||||||
return self.user_log.repository is None
|
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('[', '<span class="journal_highlight">')\
|
||||||
|
.replace(']', '</span>')
|
||||||
|
return literal(action)
|
||||||
|
|
||||||
|
def icon():
|
||||||
|
tmpl = """<i class="%s" alt="%s"></i>"""
|
||||||
|
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():
|
def _no_params_func():
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue