From c29e01843ff95a4b8c4c73edf1d3795e81a98699 Mon Sep 17 00:00:00 2001 From: Stoned Elipot Date: Sun, 22 Sep 2019 18:17:58 +0200 Subject: [PATCH] Fix custom scripts attributes usage and examples --- netbox/extras/scripts.py | 6 +++--- netbox/scripts/examples.py | 6 +++--- netbox/templates/extras/script.html | 2 +- netbox/templates/extras/script_list.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/netbox/extras/scripts.py b/netbox/extras/scripts.py index 4f1133603..3001da5c8 100644 --- a/netbox/extras/scripts.py +++ b/netbox/extras/scripts.py @@ -201,13 +201,13 @@ class BaseScript: self.source = inspect.getsource(self.__class__) def __str__(self): - return getattr(self.Meta, 'name', self.__class__.__name__) + return getattr(self, 'name', self.__class__.__name__) def _get_vars(self): vars = OrderedDict() - # Infer order from Meta.field_order (Python 3.5 and lower) - field_order = getattr(self.Meta, 'field_order', []) + # Infer order from self.field_order (Python 3.5 and lower) + field_order = getattr(self, 'field_order', []) for name in field_order: vars[name] = getattr(self, name) diff --git a/netbox/scripts/examples.py b/netbox/scripts/examples.py index b2adf8da4..631f27cb9 100644 --- a/netbox/scripts/examples.py +++ b/netbox/scripts/examples.py @@ -6,9 +6,9 @@ from extras.scripts import * class NewBranchScript(Script): - script_name = "New Branch" - script_description = "Provision a new branch site" - script_fields = ['site_name', 'switch_count', 'switch_model'] + name = "New Branch" + description = "Provision a new branch site" + field_order = ['site_name', 'switch_count', 'switch_model'] site_name = StringVar( description="Name of the new site" diff --git a/netbox/templates/extras/script.html b/netbox/templates/extras/script.html index fc10db80f..6211f66c2 100644 --- a/netbox/templates/extras/script.html +++ b/netbox/templates/extras/script.html @@ -16,7 +16,7 @@

{{ script }}

-

{{ script.Meta.description }}

+

{{ script.description }}