Skip to content

Commit 8f87c72

Browse files
authored
16050 Show script python_class name and description (netbox-community#16185)
* 16050 Show script python_class name and description * 16050 change to use Meta.description * 16050 change to use Meta.description * 16050 remove module name customization from docs
1 parent 18b4340 commit 8f87c72

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

docs/customization/custom-scripts.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ class AnotherCustomScript(Script):
6565
script_order = (MyCustomScript, AnotherCustomScript)
6666
```
6767

68-
## Module Attributes
69-
70-
### `name`
71-
72-
You can define `name` within a script module (the Python file which contains one or more scripts) to set the module name. If `name` is not defined, the module's file name will be used.
73-
7468
## Script Attributes
7569

7670
Script attributes are defined under a class named `Meta` within the script. These are optional, but encouraged.

netbox/templates/extras/script/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% load log_levels %}
55
{% load i18n %}
66

7-
{% block title %}{{ script }}{% endblock %}
7+
{% block title %}{{ script.python_class.name }}{% endblock %}
88

99
{% block object_identifier %}
1010
{{ script.full_name }}
@@ -17,7 +17,7 @@
1717

1818
{% block subtitle %}
1919
<div class="text-secondary fs-5">
20-
{{ script.Meta.description|markdown }}
20+
{{ script.python_class.Meta.description|markdown }}
2121
</div>
2222
{% endblock subtitle %}
2323

netbox/templates/extras/script_list.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ <h5 class="card-header justify-content-between" id="module{{ module.pk }}">
5656
<tr>
5757
<td>
5858
{% if script.is_executable %}
59-
<a href="{% url 'extras:script' script.pk %}" id="{{ script.module }}.{{ script.class_name }}">{{ script.name }}</a>
59+
<a href="{% url 'extras:script' script.pk %}" id="{{ script.module }}.{{ script.class_name }}">{{ script.python_class.name }}</a>
6060
{% else %}
61-
<a href="{% url 'extras:script_jobs' script.pk %}" id="{{ script.module }}.{{ script.class_name }}">{{ script.name }}</a>
61+
<a href="{% url 'extras:script_jobs' script.pk %}" id="{{ script.module }}.{{ script.class_name }}">{{ script.python_class.name }}</a>
6262
<span class="text-danger">
6363
<i class="mdi mdi-alert" title="{% trans "Script is no longer present in the source file" %}"></i>
6464
</span>
6565
{% endif %}
6666
</td>
67-
<td>{{ script.description|markdown|placeholder }}</td>
67+
<td>{{ script.python_class.Meta.description|markdown|placeholder }}</td>
6868
{% if last_job %}
6969
<td>
7070
<a href="{% url 'extras:script_result' job_pk=last_job.pk %}">{{ last_job.created|isodatetime }}</a>

0 commit comments

Comments
 (0)