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"""
|
"""Class constructor"""
|
||||||
self.title = title
|
self.title = title
|
||||||
self.action = action
|
self.action = action
|
||||||
self.critical = []
|
self.critical_errors = []
|
||||||
self.errors = []
|
self.errors = []
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
@ -29,7 +29,7 @@ class Diagnosis:
|
|||||||
'title': self.title,
|
'title': self.title,
|
||||||
'action': self.action,
|
'action': self.action,
|
||||||
'errors': self.errors,
|
'errors': self.errors,
|
||||||
'critical': self.critical
|
'critical_errors': self.critical_errors
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -47,15 +47,15 @@ class Diagnosis:
|
|||||||
title = translate(title) or title
|
title = translate(title) or title
|
||||||
result = cls(title, action=valid_dict['action'])
|
result = cls(title, action=valid_dict['action'])
|
||||||
result.errors.extend(valid_dict['errors'])
|
result.errors.extend(valid_dict['errors'])
|
||||||
result.critical.extend(valid_dict['critical'])
|
result.critical_errors.extend(valid_dict['critical_errors'])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def critical(self, message_fmt, *args):
|
def critical(self, message_fmt, *args):
|
||||||
"""Append a message to the critical errors list"""
|
"""Append a message to the critical errors list"""
|
||||||
if args:
|
if args:
|
||||||
self.critical.append(message_fmt % args)
|
self.critical_errors.append(message_fmt % args)
|
||||||
else:
|
else:
|
||||||
self.critical.append(message_fmt)
|
self.critical_errors.append(message_fmt)
|
||||||
|
|
||||||
def error(self, message_fmt, *args):
|
def error(self, message_fmt, *args):
|
||||||
"""Append a message to the errors list"""
|
"""Append a message to the errors list"""
|
||||||
@ -69,7 +69,7 @@ class Diagnosis:
|
|||||||
if log:
|
if log:
|
||||||
self.write_logs()
|
self.write_logs()
|
||||||
|
|
||||||
if self.critical:
|
if self.critical_errors:
|
||||||
return [self.title, 'error']
|
return [self.title, 'error']
|
||||||
elif self.errors:
|
elif self.errors:
|
||||||
return [self.title, 'failed']
|
return [self.title, 'failed']
|
||||||
@ -79,19 +79,19 @@ class Diagnosis:
|
|||||||
@property
|
@property
|
||||||
def has_failed(self):
|
def has_failed(self):
|
||||||
"""True if the diagnosis has failed or contains an error"""
|
"""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):
|
def write_logs(self):
|
||||||
"""Log errors and failures"""
|
"""Log errors and failures"""
|
||||||
logger.debug('Ran audit: %s', self.title)
|
logger.debug('Ran audit: %s', self.title)
|
||||||
for message in self.critical:
|
for message in self.critical_errors:
|
||||||
logger.critical(message)
|
logger.critical(message)
|
||||||
for message in self.errors:
|
for message in self.errors:
|
||||||
logger.error(message)
|
logger.error(message)
|
||||||
|
|
||||||
def sorting_key(self):
|
def sorting_key(self):
|
||||||
"""The key function for list.sort"""
|
"""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):
|
class MainCfDiagnosis(Diagnosis):
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
<li class="list-group-item clearfix">
|
<li class="list-group-item clearfix">
|
||||||
|
|
||||||
<span>{{ model.title }}</span>
|
<span>{{ model.title }}</span>
|
||||||
{% if model.critical %}
|
{% if model.critical_errors %}
|
||||||
<span class="badge badge-danger">{% trans "error" %}</span>
|
<span class="badge badge-danger">{% trans "error" %}</span>
|
||||||
{% elif model.errors %}
|
{% elif model.errors %}
|
||||||
<span class="badge badge-warning">{% trans "failed" %}</span>
|
<span class="badge badge-warning">{% trans "failed" %}</span>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for message in model.critical %}
|
{% for message in model.critical_errors %}
|
||||||
<li>{{ message }}</li>
|
<li>{{ message }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for message in model.errors %}
|
{% for message in model.errors %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user