mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
- Move do_not_call_in_templates to BaseScript
- Fix the name classproperty
This commit is contained in:
parent
22980cea7b
commit
ae46cd33b6
@ -259,6 +259,10 @@ class BaseScript:
|
|||||||
Base model for custom scripts. User classes should inherit from this model if they want to extend Script
|
Base model for custom scripts. User classes should inherit from this model if they want to extend Script
|
||||||
functionality for use in other subclasses.
|
functionality for use in other subclasses.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Prevent django from instantiating the class on all accesses
|
||||||
|
do_not_call_in_templates = True
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -280,7 +284,7 @@ class BaseScript:
|
|||||||
|
|
||||||
@classproperty
|
@classproperty
|
||||||
def name(self):
|
def name(self):
|
||||||
return getattr(self.Meta, 'name', self.__class__.__name__)
|
return getattr(self.Meta, 'name', self.__name__)
|
||||||
|
|
||||||
@classproperty
|
@classproperty
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
|
@ -753,8 +753,6 @@ class ScriptListView(ContentTypePermissionRequiredMixin, View):
|
|||||||
|
|
||||||
for _scripts in scripts.values():
|
for _scripts in scripts.values():
|
||||||
for script in _scripts.values():
|
for script in _scripts.values():
|
||||||
# Prevent django from instantiating the class on all accesses
|
|
||||||
script.do_not_call_in_templates = True
|
|
||||||
script.result = results.get(script.full_name)
|
script.result = results.get(script.full_name)
|
||||||
|
|
||||||
return render(request, 'extras/script_list.html', {
|
return render(request, 'extras/script_list.html', {
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
{% for class_name, script in module_scripts.items %}
|
{% for class_name, script in module_scripts.items %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script.Meta.name }}</a>
|
<a href="{% url 'extras:script' module=script.module name=class_name %}" name="script.{{ class_name }}">{{ script.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% include 'extras/inc/job_label.html' with result=script.result %}
|
{% include 'extras/inc/job_label.html' with result=script.result %}
|
||||||
|
Loading…
Reference in New Issue
Block a user