diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 98665a7a0..3cd423426 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -11,7 +11,7 @@ from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse from django.utils.html import escape from django.utils.safestring import mark_safe -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from django.views.generic import View from jinja2.exceptions import TemplateError diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 321842260..0d98b1324 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -1180,7 +1180,8 @@ class ScriptView(BaseScriptView): data=form.cleaned_data, request=copy_safe_request(request), job_timeout=script.python_class.job_timeout, - commit=form.cleaned_data.pop('_commit') + commit=form.cleaned_data.pop('_commit'), + name=script.name ) return redirect('extras:script_result', job_pk=job.pk) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index 5381ec187..b712ef3b6 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -3,7 +3,7 @@ from django.db.models import Prefetch from django.db.models.expressions import RawSQL from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from circuits.models import Provider from dcim.filtersets import InterfaceFilterSet diff --git a/netbox/netbox/views/generic/feature_views.py b/netbox/netbox/views/generic/feature_views.py index 451c9c01d..49862e83f 100644 --- a/netbox/netbox/views/generic/feature_views.py +++ b/netbox/netbox/views/generic/feature_views.py @@ -4,7 +4,7 @@ from django.contrib import messages from django.db import transaction from django.db.models import Q from django.shortcuts import get_object_or_404, redirect, render -from django.utils.translation import gettext as _ +from django.utils.translation import gettext_lazy as _ from django.views.generic import View from core.models import Job, ObjectChange diff --git a/netbox/templates/extras/script_list.html b/netbox/templates/extras/script_list.html index 5b7361a12..cbffbf8de 100644 --- a/netbox/templates/extras/script_list.html +++ b/netbox/templates/extras/script_list.html @@ -37,101 +37,104 @@ {% endif %} - {% if module.scripts %} - - - - - - - - - - - - {% for script in module.scripts.all %} - {% with last_job=script.get_latest_jobs|first %} - - +
{% trans "Name" %}{% trans "Description" %}{% trans "Last Run" %}{% trans "Status" %}
- {% if script.is_executable %} - {{ script.python_class.name }} + {% with scripts=module.scripts.all %} + {% if scripts %} + + + + + + + + + + + + {% for script in scripts %} + {% with last_job=script.get_latest_jobs|first %} + + + + {% if last_job %} + + {% else %} - {{ script.python_class.name }} - - - + + {% endif %} - - + + {% if last_job %} - - - {% else %} - - + {% for test_name, data in last_job.data.tests.items %} + + + + + {% endfor %} + {% elif not last_job.data.log %} + {# legacy #} + {% for method, stats in last_job.data.items %} + + + + + {% endfor %} {% endif %} - - - {% if last_job %} - {% for test_name, data in last_job.data.tests.items %} - - - - - {% endfor %} - {% elif not last_job.data.log %} - {# legacy #} - {% for method, stats in last_job.data.items %} - - - - - {% endfor %} - {% endif %} - {% endwith %} - {% endfor %} - -
{% trans "Name" %}{% trans "Description" %}{% trans "Last Run" %}{% trans "Status" %}
+ {% if script.is_executable %} + {{ script.python_class.name }} + {% else %} + {{ script.python_class.name }} + + + + {% endif %} + {{ script.python_class.Meta.description|markdown|placeholder }} + {{ last_job.created|isodatetime }} + + {% badge last_job.get_status_display last_job.get_status_color %} + {% trans "Never" %}{{ ''|placeholder }}{{ script.python_class.Meta.description|markdown|placeholder }} + {% if request.user|can_run:script and script.is_executable %} +
+
+ {% csrf_token %} + +
+
+ {% endif %} +
- {{ last_job.created|isodatetime }} - - {% badge last_job.get_status_display last_job.get_status_color %} - {% trans "Never" %}{{ ''|placeholder }}
+ {{ test_name }} + + {{ data.success }} + {{ data.info }} + {{ data.warning }} + {{ data.failure }} +
+ {{ method }} + + {{ stats.success }} + {{ stats.info }} + {{ stats.warning }} + {{ stats.failure }} +
- {% if request.user|can_run:script and script.is_executable %} -
-
- {% csrf_token %} - -
-
- {% endif %} -
- {{ test_name }} - - {{ data.success }} - {{ data.info }} - {{ data.warning }} - {{ data.failure }} -
- {{ method }} - - {{ stats.success }} - {{ stats.info }} - {{ stats.warning }} - {{ stats.failure }} -
- {% else %} -
-
+ {% else %} +
+
- - {% endif %} + {% endif %} + {% endwith %} {% empty %}