mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-15 20:18:17 -06:00
Fix custom scripts attributes usage and examples
This commit is contained in:
parent
0798533201
commit
c29e01843f
@ -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)
|
||||
|
||||
|
@ -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"
|
||||
|
@ -16,7 +16,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<h1>{{ script }}</h1>
|
||||
<p>{{ script.Meta.description }}</p>
|
||||
<p>{{ script.description }}</p>
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active">
|
||||
<a href="#run" role="tab" data-toggle="tab" class="active">Run</a>
|
||||
|
@ -21,7 +21,7 @@
|
||||
<td>
|
||||
<a href="{% url 'extras:script' module=module name=class_name %}" name="script.{{ class_name }}"><strong>{{ script }}</strong></a>
|
||||
</td>
|
||||
<td>{{ script.Meta.description }}</td>
|
||||
<td>{{ script.description }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
Loading…
Reference in New Issue
Block a user