mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
Fix module child ordering
This commit is contained in:
parent
bf6cfd22b4
commit
87442f2a4f
@ -874,13 +874,20 @@ class ScriptModule(PythonModuleMixin, ManagedFile):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def scripts(self):
|
def scripts(self):
|
||||||
module = self.get_module()
|
|
||||||
|
|
||||||
scripts = {}
|
def _get_name(cls):
|
||||||
for name, cls in inspect.getmembers(module, is_script):
|
|
||||||
# For child objects in submodules use the full import path w/o the root module as the name
|
# For child objects in submodules use the full import path w/o the root module as the name
|
||||||
child_name = cls.full_name.split(".", maxsplit=1)[1]
|
return cls.full_name.split(".", maxsplit=1)[1]
|
||||||
scripts[child_name] = cls
|
|
||||||
|
module = self.get_module()
|
||||||
|
scripts = {}
|
||||||
|
ordered = getattr(module, 'script_order', [])
|
||||||
|
|
||||||
|
for cls in ordered:
|
||||||
|
scripts[_get_name(cls)] = cls
|
||||||
|
for name, cls in inspect.getmembers(module, is_script):
|
||||||
|
if cls not in ordered:
|
||||||
|
scripts[_get_name(cls)] = cls
|
||||||
|
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
@ -928,13 +935,20 @@ class ReportModule(PythonModuleMixin, ManagedFile):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def reports(self):
|
def reports(self):
|
||||||
module = self.get_module()
|
|
||||||
|
|
||||||
reports = {}
|
def _get_name(cls):
|
||||||
for name, cls in inspect.getmembers(module, is_report):
|
|
||||||
# For child objects in submodules use the full import path w/o the root module as the name
|
# For child objects in submodules use the full import path w/o the root module as the name
|
||||||
child_name = cls().full_name.split(".", maxsplit=1)[1]
|
return cls.full_name.split(".", maxsplit=1)[1]
|
||||||
reports[child_name] = cls
|
|
||||||
|
module = self.get_module()
|
||||||
|
reports = {}
|
||||||
|
ordered = getattr(module, 'report_order', [])
|
||||||
|
|
||||||
|
for cls in ordered:
|
||||||
|
reports[_get_name(cls)] = cls
|
||||||
|
for name, cls in inspect.getmembers(module, is_report):
|
||||||
|
if cls not in ordered:
|
||||||
|
reports[_get_name(cls)] = cls
|
||||||
|
|
||||||
return reports
|
return reports
|
||||||
|
|
||||||
|
@ -805,6 +805,7 @@ class ReportModuleCreateView(generic.ObjectEditView):
|
|||||||
@register_model_view(ReportModule, 'delete')
|
@register_model_view(ReportModule, 'delete')
|
||||||
class ReportModuleDeleteView(generic.ObjectDeleteView):
|
class ReportModuleDeleteView(generic.ObjectDeleteView):
|
||||||
queryset = ReportModule.objects.all()
|
queryset = ReportModule.objects.all()
|
||||||
|
default_return_url = 'extras:report_list'
|
||||||
|
|
||||||
|
|
||||||
class ReportListView(ContentTypePermissionRequiredMixin, View):
|
class ReportListView(ContentTypePermissionRequiredMixin, View):
|
||||||
@ -943,6 +944,7 @@ class ScriptModuleCreateView(generic.ObjectEditView):
|
|||||||
@register_model_view(ScriptModule, 'delete')
|
@register_model_view(ScriptModule, 'delete')
|
||||||
class ScriptModuleDeleteView(generic.ObjectDeleteView):
|
class ScriptModuleDeleteView(generic.ObjectDeleteView):
|
||||||
queryset = ScriptModule.objects.all()
|
queryset = ScriptModule.objects.all()
|
||||||
|
default_return_url = 'extras:script_list'
|
||||||
|
|
||||||
|
|
||||||
class ScriptListView(ContentTypePermissionRequiredMixin, View):
|
class ScriptListView(ContentTypePermissionRequiredMixin, View):
|
||||||
|
Loading…
Reference in New Issue
Block a user