Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 439ffaec authored by Laurent VENIER's avatar Laurent VENIER :speech_balloon:
Browse files

Merge branch 'navigation_helper' into 'main'

Add navigation helper

See merge request !20
parents d0c73bc0 4b81d08e
No related branches found
No related tags found
1 merge request!20Add navigation helper
Pipeline #69886 passed
......@@ -104,3 +104,6 @@ class HttpHeader(NetBoxModel):
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('plugins:netbox_rps_plugin:httpheader', args=[self.pk])
import django_tables2 as tables
from netbox.tables import NetBoxTable, ChoiceFieldColumn
from netbox.tables import NetBoxTable, ChoiceFieldColumn, columns
from .models import Mapping, HttpHeader
class MappingTable(NetBoxTable):
authentication = ChoiceFieldColumn()
source = tables.Column(linkify=True)
httpheader_count = columns.LinkedCountColumn(
viewname='plugins:netbox_rps_plugin:httpheader_list',
url_params={'mapping_id': 'pk'},
verbose_name='HTTP Headers count'
)
class Meta(NetBoxTable.Meta):
model = Mapping
fields = (
'pk', 'id', 'source', 'target', 'authentication', 'testingpage', 'webdav', 'Comment'
'pk', 'id', 'source', 'target', 'authentication', 'testingpage', 'webdav', 'Comment', 'httpheader_count'
)
default_columns = (
'source', 'target', 'authentication', 'Comment'
'source', 'target', 'authentication', 'Comment', 'httpheader_count'
)
class HttpHeaderTable(NetBoxTable):
mapping = tables.Column(
name = tables.Column(
linkify=True
)
......
{% extends 'generic/object.html' %}
{% block content %}
<div class="row mb-3">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">HEADERS</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Value</th>
<td>{{ object.value }}</td>
</tr>
<tr>
<th scope="row">Apply To</th>
<td>{{ object.apply_to }}</td>
</tr>
</table>
</div>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
</div>
</div>
{% endblock content %}
from django.urls import path
from netbox_rps_plugin import views, models
from netbox.views.generic import ObjectChangeLogView
from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
urlpatterns = (
......@@ -17,13 +17,21 @@ urlpatterns = (
path('mappings/<int:pk>/changelog/', ObjectChangeLogView.as_view(), name='mapping_changelog', kwargs={
'model': models.Mapping
}),
path('mappings/<int:pk>/journal/', ObjectJournalView.as_view(), name='mapping_journal', kwargs={
'model': models.Mapping
}),
# HTTP Headers
path('http-headers/', views.HttpHeaderListView.as_view(), name='httpheader_list'),
path('http-headers/add/', views.HttpHeaderEditView.as_view(), name='httpheader_add'),
path('http-headers/delete/', views.HttpHeaderBulkDeleteView.as_view(), name='httpheaders_bulk_delete'),
path('http-headers/<int:pk>/', views.HttpHeaderView.as_view(), name='httpheader'),
path('http-headers/<int:pk>/edit/', views.HttpHeaderEditView.as_view(), name='httpheader_edit'),
path('http-headers/<int:pk>/delete/', views.HttpHeaderDeleteView.as_view(), name='httpheader_delete'),
path('http-headers/<int:pk>/changelog/', ObjectChangeLogView.as_view(), name='httpheader_changelog', kwargs={
'model': models.HttpHeader
}),
path('http-headers/<int:pk>/journal/', ObjectJournalView.as_view(), name='httpheader_journal', kwargs={
'model': models.Mapping
}),
)
......@@ -4,12 +4,16 @@ from netbox_rps_plugin import forms, tables, filtersets, models
from utilities.views import ViewTab, register_model_view
from django.utils.translation import gettext as _
class MappingView(generic.ObjectView):
queryset = models.Mapping.objects.all().prefetch_related('http_headers')
class MappingListView(generic.ObjectListView):
queryset = models.Mapping.objects.all()
#queryset = models.Mapping.objects.all()
queryset = models.Mapping.objects.annotate(
httpheader_count=count_related(models.HttpHeader, 'mapping')
)
table = tables.MappingTable
filterset = filtersets.MappingFilterSet
filterset_form = forms.MappingFilterForm
......@@ -54,6 +58,17 @@ class MappingHttpHeadersView(generic.ObjectChildrenView):
return parent.http_headers
class HttpHeaderView(generic.ObjectView):
queryset = models.HttpHeader.objects.all()
class HttpHeaderListView(generic.ObjectListView):
queryset = models.HttpHeader.objects.all()
table = tables.HttpHeaderTable
filterset = filtersets.HttpHeaderFilterSet
filterset_form = forms.HttpHeaderForm
class HttpHeaderEditView(generic.ObjectEditView):
queryset = models.HttpHeader.objects.all()
form = forms.HttpHeaderForm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment