mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
Fix URLs for nested reports & scripts
This commit is contained in:
parent
657944e193
commit
e7a26dccc6
@ -56,9 +56,16 @@ class ManagedFile(SyncedDataMixin, models.Model):
|
||||
models.Index(fields=('file_root', 'file_path'), name='core_managedfile_root_path'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('core:managedfile', args=[self.pk])
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.file_path
|
||||
|
||||
@property
|
||||
def full_path(self):
|
||||
return os.path.join(self._resolve_root_path(), self.file_path)
|
||||
|
@ -823,9 +823,13 @@ class ConfigRevision(models.Model):
|
||||
|
||||
class PythonModuleMixin:
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return os.path.splitext(self.file_path)[0]
|
||||
|
||||
def get_module_info(self):
|
||||
path = os.path.dirname(self.full_path)
|
||||
module_name = os.path.splitext(os.path.basename(self.file_path))[0]
|
||||
module_name = os.path.basename(self.path)
|
||||
return ModuleInfo(
|
||||
module_finder=get_importer(path),
|
||||
name=module_name,
|
||||
@ -861,16 +865,9 @@ class ScriptModule(PythonModuleMixin, ManagedFile):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
def __str__(self):
|
||||
return self.file_path
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('extras:script_list')
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.file_path
|
||||
|
||||
@cached_property
|
||||
def scripts(self):
|
||||
|
||||
@ -922,16 +919,9 @@ class ReportModule(PythonModuleMixin, ManagedFile):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
def __str__(self):
|
||||
return self.file_path
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('extras:report_list')
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.file_path
|
||||
|
||||
@cached_property
|
||||
def reports(self):
|
||||
|
||||
|
@ -97,14 +97,14 @@ urlpatterns = [
|
||||
path('reports/add/', views.ReportModuleCreateView.as_view(), name='reportmodule_add'),
|
||||
path('reports/results/<int:job_result_pk>/', views.ReportResultView.as_view(), name='report_result'),
|
||||
path('reports/<int:pk>/', include(get_model_urls('extras', 'reportmodule'))),
|
||||
path('reports/<str:module>.<str:name>/', views.ReportView.as_view(), name='report'),
|
||||
path('reports/<path:module>.<str:name>/', views.ReportView.as_view(), name='report'),
|
||||
|
||||
# Scripts
|
||||
path('scripts/', views.ScriptListView.as_view(), name='script_list'),
|
||||
path('scripts/add/', views.ScriptModuleCreateView.as_view(), name='scriptmodule_add'),
|
||||
path('scripts/results/<int:job_result_pk>/', views.ScriptResultView.as_view(), name='script_result'),
|
||||
path('scripts/<int:pk>/', include(get_model_urls('extras', 'scriptmodule'))),
|
||||
path('scripts/<str:module>.<str:name>/', views.ScriptView.as_view(), name='script'),
|
||||
path('scripts/<path:module>.<str:name>/', views.ScriptView.as_view(), name='script'),
|
||||
|
||||
# Job results
|
||||
path('job-results/', views.JobResultListView.as_view(), name='jobresult_list'),
|
||||
|
@ -53,7 +53,7 @@
|
||||
{% with last_result=job_results|get_key:report.full_name %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'extras:report' module=report.module name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
|
||||
<a href="{% url 'extras:report' module=module.path name=report.class_name %}" id="{{ report.module }}.{{ report.class_name }}">{{ report.name }}</a>
|
||||
</td>
|
||||
<td>{{ report.description|markdown|placeholder }}</td>
|
||||
{% if last_result %}
|
||||
|
@ -51,7 +51,7 @@
|
||||
{% with last_result=job_results|get_key:script_class.full_name %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'extras:script' module=script_class.root_module name=script_name %}" name="script.{{ script_name }}">{{ script_class.name }}</a>
|
||||
<a href="{% url 'extras:script' module=module.path name=script_name %}" name="script.{{ script_name }}">{{ script_class.name }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ script_class.Meta.description|markdown|placeholder }}
|
||||
|
Loading…
Reference in New Issue
Block a user