mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
[Spring Metrics] Fix code smell "redefine built-in" and flake8 complaints
This commit is contained in:
parent
9e6f7c8723
commit
a1d3bbc09f
1 changed files with 11 additions and 8 deletions
|
|
@ -52,8 +52,9 @@ def spring_metrics(parser, token):
|
|||
|
||||
class SpringMetricsNode(Node):
|
||||
def __init__(self):
|
||||
self.tracking_id = get_required_setting('SPRING_METRICS_TRACKING_ID',
|
||||
TRACKING_ID_RE, "must be a hexadecimal string")
|
||||
self.tracking_id = get_required_setting(
|
||||
'SPRING_METRICS_TRACKING_ID',
|
||||
TRACKING_ID_RE, "must be a hexadecimal string")
|
||||
|
||||
def render(self, context):
|
||||
custom = {}
|
||||
|
|
@ -63,23 +64,25 @@ class SpringMetricsNode(Node):
|
|||
custom[var[15:]] = val
|
||||
if 'email' not in custom:
|
||||
identity = get_identity(context, 'spring_metrics',
|
||||
lambda u: u.email)
|
||||
lambda u: u.email)
|
||||
if identity is not None:
|
||||
custom['email'] = identity
|
||||
|
||||
html = TRACKING_CODE % {'tracking_id': self.tracking_id,
|
||||
'custom_commands': self._generate_custom_javascript(custom)}
|
||||
html = TRACKING_CODE % {
|
||||
'tracking_id': self.tracking_id,
|
||||
'custom_commands': self._generate_custom_javascript(custom),
|
||||
}
|
||||
if is_internal_ip(context, 'SPRING_METRICS'):
|
||||
html = disable_html(html, 'Spring Metrics')
|
||||
return html
|
||||
|
||||
def _generate_custom_javascript(self, vars):
|
||||
def _generate_custom_javascript(self, params):
|
||||
commands = []
|
||||
convert = vars.pop('convert', None)
|
||||
convert = params.pop('convert', None)
|
||||
if convert is not None:
|
||||
commands.append("_springMetq.push(['convert', '%s'])" % convert)
|
||||
commands.extend("_springMetq.push(['setdata', {'%s': '%s'}]);"
|
||||
% (var, val) for var, val in vars.items())
|
||||
% (var, val) for var, val in params.items())
|
||||
return " ".join(commands)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue