mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
email: Fix self.critical not callable error
This commit is contained in:
parent
1e2ee690d7
commit
06d8aade23
@ -19,7 +19,7 @@ class Diagnosis:
|
||||
"""Class constructor"""
|
||||
self.title = title
|
||||
self.action = action
|
||||
self.critical = []
|
||||
self.critical_errors = []
|
||||
self.errors = []
|
||||
|
||||
def to_json(self):
|
||||
@ -29,7 +29,7 @@ class Diagnosis:
|
||||
'title': self.title,
|
||||
'action': self.action,
|
||||
'errors': self.errors,
|
||||
'critical': self.critical
|
||||
'critical_errors': self.critical_errors
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@ -47,15 +47,15 @@ class Diagnosis:
|
||||
title = translate(title) or title
|
||||
result = cls(title, action=valid_dict['action'])
|
||||
result.errors.extend(valid_dict['errors'])
|
||||
result.critical.extend(valid_dict['critical'])
|
||||
result.critical_errors.extend(valid_dict['critical_errors'])
|
||||
return result
|
||||
|
||||
def critical(self, message_fmt, *args):
|
||||
"""Append a message to the critical errors list"""
|
||||
if args:
|
||||
self.critical.append(message_fmt % args)
|
||||
self.critical_errors.append(message_fmt % args)
|
||||
else:
|
||||
self.critical.append(message_fmt)
|
||||
self.critical_errors.append(message_fmt)
|
||||
|
||||
def error(self, message_fmt, *args):
|
||||
"""Append a message to the errors list"""
|
||||
@ -69,7 +69,7 @@ class Diagnosis:
|
||||
if log:
|
||||
self.write_logs()
|
||||
|
||||
if self.critical:
|
||||
if self.critical_errors:
|
||||
return [self.title, 'error']
|
||||
elif self.errors:
|
||||
return [self.title, 'failed']
|
||||
@ -79,19 +79,19 @@ class Diagnosis:
|
||||
@property
|
||||
def has_failed(self):
|
||||
"""True if the diagnosis has failed or contains an error"""
|
||||
return (self.critical or self.errors)
|
||||
return (self.critical_errors or self.errors)
|
||||
|
||||
def write_logs(self):
|
||||
"""Log errors and failures"""
|
||||
logger.debug('Ran audit: %s', self.title)
|
||||
for message in self.critical:
|
||||
for message in self.critical_errors:
|
||||
logger.critical(message)
|
||||
for message in self.errors:
|
||||
logger.error(message)
|
||||
|
||||
def sorting_key(self):
|
||||
"""The key function for list.sort"""
|
||||
return (-len(self.critical), -len(self.errors), self.title)
|
||||
return (-len(self.critical_errors), -len(self.errors), self.title)
|
||||
|
||||
|
||||
class MainCfDiagnosis(Diagnosis):
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<li class="list-group-item clearfix">
|
||||
|
||||
<span>{{ model.title }}</span>
|
||||
{% if model.critical %}
|
||||
{% if model.critical_errors %}
|
||||
<span class="badge badge-danger">{% trans "error" %}</span>
|
||||
{% elif model.errors %}
|
||||
<span class="badge badge-warning">{% trans "failed" %}</span>
|
||||
@ -41,7 +41,7 @@
|
||||
{% endif %}
|
||||
|
||||
<ul>
|
||||
{% for message in model.critical %}
|
||||
{% for message in model.critical_errors %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
{% for message in model.errors %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user