1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

- Move do_not_call_in_templates to BaseScript

- Fix the name classproperty
This commit is contained in:
kkthxbye
2022-03-23 12:18:14 +01:00
parent 22980cea7b
commit ae46cd33b6
3 changed files with 6 additions and 4 deletions

View File

@ -259,6 +259,10 @@ class BaseScript:
Base model for custom scripts. User classes should inherit from this model if they want to extend Script
functionality for use in other subclasses.
"""
# Prevent django from instantiating the class on all accesses
do_not_call_in_templates = True
class Meta:
pass
@ -280,7 +284,7 @@ class BaseScript:
@classproperty
def name(self):
return getattr(self.Meta, 'name', self.__class__.__name__)
return getattr(self.Meta, 'name', self.__name__)
@classproperty
def full_name(self):

View File

@ -753,8 +753,6 @@ class ScriptListView(ContentTypePermissionRequiredMixin, View):
for _scripts 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)
return render(request, 'extras/script_list.html', {