Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobResult list view to show job Meta.name where available instead of class_path #775

Merged
merged 4 commits into from
Aug 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions nautobot/extras/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
<button data-url="{% url 'extras:gitrepository_sync' slug=record.slug %}" type="submit" class="btn btn-primary btn-xs sync-repository" title="Sync" {% if not perms.extras.change_gitrepository %}disabled="disabled"{% endif %}><i class="mdi mdi-source-branch-sync" aria-hidden="true"></i></button>
"""

JOB_RESULT_JOB = """
{% if record.related_object and record.related_object.Meta and record.related_object.Meta.name %}
glennmatthews marked this conversation as resolved.
Show resolved Hide resolved
{{ record.related_object.Meta.name }}
{% elif record.related_object %}
{{ record.related_object }}
{% else %}
{{ record.name }}
{% endif %}
"""

OBJECTCHANGE_OBJECT = """
{% if record.changed_object and record.changed_object.get_absolute_url %}
<a href="{{ record.changed_object.get_absolute_url }}">{{ record.object_repr }}</a>
Expand Down Expand Up @@ -259,8 +269,8 @@ def job_creator_link(value, record):
class JobResultTable(BaseTable):
pk = ToggleColumn()
obj_type = tables.Column(verbose_name="Object Type", accessor="obj_type.name")
job = tables.TemplateColumn(template_code=JOB_RESULT_JOB, linkify=job_creator_link)
name = tables.Column(linkify=job_creator_link)
job_id = tables.Column(linkify=job_creator_link, verbose_name="Job ID")
created = tables.DateTimeColumn(linkify=True, format=settings.SHORT_DATETIME_FORMAT)
status = tables.TemplateColumn(
template_code="{% include 'extras/inc/job_label.html' with result=record %}",
Expand All @@ -283,15 +293,15 @@ class Meta(BaseTable.Meta):
"pk",
"created",
"obj_type",
"job",
"name",
"job_id",
"duration",
"completed",
"user",
"status",
"data",
)
default_columns = ("pk", "created", "name", "user", "status", "data")
default_columns = ("pk", "created", "job", "user", "status", "data")


class ObjectChangeTable(BaseTable):
Expand Down