14729 review changes

This commit is contained in:
Arthur 2024-01-23 15:16:37 -08:00
parent 679faaca39
commit 0ac2c6e364
3 changed files with 9 additions and 13 deletions

View File

@ -4,7 +4,7 @@ from django.urls import reverse
from django.utils.html import mark_safe
from django.utils.translation import gettext_lazy as _
from netbox.tables import BaseTable
from netbox.tables import BaseTable, columns
from utilities.templatetags.helpers import annotated_date
@ -38,7 +38,7 @@ class BackgroundTaskTable(BaseTable):
created_at = tables.DateTimeColumn(verbose_name=_("Created"))
enqueued_at = tables.DateTimeColumn(verbose_name=_("Enqueued"))
ended_at = tables.DateTimeColumn(verbose_name=_("Ended"))
status = tables.Column(empty_values=(), verbose_name=_("Status"))
status = columns.ChoiceFieldColumn(verbose_name=_("Status"), accessor='get_status')
callable = tables.Column(empty_values=(), verbose_name=_("Callable"))
class Meta(BaseTable.Meta):
@ -50,9 +50,6 @@ class BackgroundTaskTable(BaseTable):
'id', 'created_at', 'enqueued_at', 'ended_at', 'status', 'callable',
)
def render_status(self, value, record):
return record.get_status
def render_callable(self, value, record):
try:
return record.func_name

View File

@ -399,12 +399,6 @@ class BackgroundTaskDetailView(UserPassesTestMixin, View):
queue_index = QUEUES_MAP[job.origin]
queue = get_queue_by_index(queue_index)
try:
job.func_name
data_is_valid = True
except Exception:
data_is_valid = False
try:
exc_info = job._exc_info
except AttributeError:
@ -414,7 +408,6 @@ class BackgroundTaskDetailView(UserPassesTestMixin, View):
'queue': queue,
'job': job,
'queue_index': queue_index,
'data_is_valid': data_is_valid,
'dependency_id': job._dependency_id,
'exc_info': exc_info,
})

View File

@ -92,9 +92,15 @@
<th scope="row">{% trans "Kwargs" %}</th>
<td>{{ job.kwargs|placeholder }}</td>
</tr>
{% if dependency_id %}
<tr>
<th scope="row">{% trans "Depends on" %}</th>
<td><a href="{% url 'core:background_task' job.id %}">{{ dependency_id }}</a></td>
</tr>
{% endif %}
{% if exc_info %}
<tr>
<th scope="row">{% trans "Exception:" %}</th>
<th scope="row">{% trans "Exception" %}</th>
<td><pre>{% if job.exc_info %}{{ job.exc_info|linebreaks }}{% endif %}</pre></td>
</tr>
{% endif %}