Skip to content

Commit 5bae52f

Browse files
authored
Merge branch 'dev' into chore/migration
2 parents f128fc9 + d042603 commit 5bae52f

File tree

6 files changed

+102
-114
lines changed

6 files changed

+102
-114
lines changed

netbox_acls/forms/models.py

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
DynamicModelChoiceField,
1515
DynamicModelMultipleChoiceField,
1616
)
17-
from virtualization.models import VirtualMachine, VMInterface
17+
from virtualization.models import (
18+
Cluster,
19+
ClusterGroup,
20+
ClusterType,
21+
VirtualMachine,
22+
VMInterface,
23+
)
1824

1925
from ..models import (
2026
AccessList,
@@ -59,6 +65,7 @@ class AccessListForm(NetBoxModelForm):
5965
Requires a device, a name, a type, and a default_action.
6066
"""
6167

68+
# Device selector
6269
region = DynamicModelChoiceField(
6370
queryset=Region.objects.all(),
6471
required=False,
@@ -85,21 +92,49 @@ class AccessListForm(NetBoxModelForm):
8592
"site_id": "$site",
8693
},
8794
)
95+
96+
# Virtual Chassis selector
8897
virtual_chassis = DynamicModelChoiceField(
8998
queryset=VirtualChassis.objects.all(),
9099
required=False,
91100
label="Virtual Chassis",
92101
)
102+
103+
# Virtual Machine selector
104+
cluster_type = DynamicModelChoiceField(
105+
queryset=ClusterType.objects.all(),
106+
required=False,
107+
)
108+
109+
cluster_group = DynamicModelChoiceField(
110+
queryset=ClusterGroup.objects.all(),
111+
required=False,
112+
query_params={
113+
"type_id": "$cluster_type",
114+
},
115+
)
116+
117+
cluster = DynamicModelChoiceField(
118+
queryset=Cluster.objects.all(),
119+
required=False,
120+
query_params={
121+
"type_id": "$cluster_type",
122+
"group_id": "$cluster_group",
123+
},
124+
)
125+
93126
virtual_machine = DynamicModelChoiceField(
94127
queryset=VirtualMachine.objects.all(),
95128
required=False,
96129
label="Virtual Machine",
130+
query_params={
131+
"cluster_type_id": "$cluster_type",
132+
"cluster_group_id": "$cluster_group",
133+
"cluster_id": "$cluster",
134+
},
97135
)
136+
98137
comments = CommentField()
99-
tags = DynamicModelMultipleChoiceField(
100-
queryset=Tag.objects.all(),
101-
required=False,
102-
)
103138

104139
class Meta:
105140
model = AccessList

netbox_acls/models/access_list_rules.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class ACLRule(NetBoxModel):
5252
verbose_name="Source Prefix",
5353
)
5454

55+
clone_fields = ("access_list", "action", "source_prefix")
56+
5557
def __str__(self):
5658
return f"{self.access_list}: Rule {self.index}"
5759

netbox_acls/models/access_lists.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class AccessList(NetBoxModel):
5959
blank=True,
6060
)
6161

62+
clone_fields = (
63+
"type",
64+
"default_action",
65+
)
66+
6267
class Meta:
6368
unique_together = ["assigned_object_type", "assigned_object_id", "name"]
6469
ordering = ["assigned_object_type", "assigned_object_id", "name"]
@@ -113,6 +118,8 @@ class ACLInterfaceAssignment(NetBoxModel):
113118
blank=True,
114119
)
115120

121+
clone_fields = ("access_list", "direction")
122+
116123
class Meta:
117124
unique_together = [
118125
"assigned_object_type",
Lines changed: 50 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,63 @@
11
{% extends 'generic/object.html' %}
22
{% load render_table from django_tables2 %}
33

4-
{% block breadcrumbs %}
5-
<li class="breadcrumb-item"><a href="{% url 'plugins:netbox_acls:accesslist_list' %}">Access Lists</a></li>
6-
{% endblock %}
7-
{% block controls %}
8-
<div class="pull-right noprint">
4+
{% block extra_controls %}
95
{% if perms.netbox_acls.change_policy %}
10-
{% if object.type == 'extended' %}
11-
<a href="{% url 'plugins:netbox_acls:aclextendedrule_add' %}?access_list={{ object.pk }}" class="btn btn-success">
12-
{% elif object.type == 'standard' %}
13-
<a href="{% url 'plugins:netbox_acls:aclstandardrule_add' %}?access_list={{ object.pk }}" class="btn btn-success">
14-
{% endif %}
15-
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Rule
16-
</a>
17-
<a href="{% url 'plugins:netbox_acls:accesslist_edit' pk=object.pk %}" class="btn btn-warning">
18-
<span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
19-
</a>
20-
{% endif %}
21-
{% if perms.netbox_acls.delete_policy %}
22-
<a href="{% url 'plugins:netbox_acls:accesslist_delete' pk=object.pk %}" class="btn btn-danger">
23-
<span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
6+
{% if object.type == 'extended' %}
7+
<a href="{% url 'plugins:netbox_acls:aclextendedrule_add' %}?access_list={{ object.pk }}" class="btn btn-sm btn-primary">
8+
{% elif object.type == 'standard' %}
9+
<a href="{% url 'plugins:netbox_acls:aclstandardrule_add' %}?access_list={{ object.pk }}" class="btn btn-sm btn-primary">
10+
{% endif %}
11+
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Rule
2412
</a>
2513
{% endif %}
26-
</div>
27-
{% endblock controls %}
28-
{% block tabs %}
29-
<ul class="nav nav-tabs px-3">
30-
{% block tab_items %}
31-
<li class="nav-item" role="presentation">
32-
<a class="nav-link{% if not active_tab %} active{% endif %}" href="{{ object.get_absolute_url }}">{{ object|meta:"verbose_name"|bettertitle }}</a>
33-
</li>
34-
{% endblock tab_items %}
35-
{% if perms.extras.view_objectchange %}
36-
<li role="presentation" class="nav-item">
37-
<a href="{% url 'plugins:netbox_acls:accesslist_changelog' pk=object.pk %}" class="nav-link{% if active_tab == 'changelog'%} active{% endif %}">Change Log</a>
38-
</li>
39-
{% endif %}
40-
</ul>
41-
{% endblock tabs %}
14+
{% endblock extra_controls %}
4215

4316
{% block content %}
44-
<div class="row mb-3">
45-
<div class="col col-md-6">
46-
<div class="card">
47-
<h5 class="card-header">Access List</h5>
48-
<div class="card-body">
49-
<table class="table table-hover attr-table">
50-
<tr>
51-
<th scope="row">Type</th>
52-
<td>{{ object.get_type_display }}</td>
53-
</tr>
54-
<tr>
55-
<th scope="row">Default Action</th>
56-
<td>{% badge object.get_default_action_display bg_color=object.get_default_action_color %}</td>
57-
</tr>
58-
<tr>
59-
<th scope="row">Rules</th>
60-
{% if object.type == 'standard' %}
61-
<td>{{ object.aclstandardrules.count|placeholder }}</td>
62-
{% elif object.type == 'extended' %}
63-
<td>{{ object.aclextendedrules.count|placeholder }}</td>
64-
{% endif %}
65-
<tr>
66-
<th scope="row">Assigned Host</th>
67-
<td>{{ object.assigned_object|linkify }}</td>
68-
</tr>
69-
</tr>
70-
</table>
17+
<div class="row mb-3">
18+
<div class="col col-md-6">
19+
<div class="card">
20+
<h5 class="card-header">Access List</h5>
21+
<div class="card-body">
22+
<table class="table table-hover attr-table">
23+
<tr>
24+
<th scope="row">Type</th>
25+
<td>{{ object.get_type_display }}</td>
26+
</tr>
27+
<tr>
28+
<th scope="row">Default Action</th>
29+
<td>{% badge object.get_default_action_display bg_color=object.get_default_action_color %}</td>
30+
</tr>
31+
<tr>
32+
<th scope="row">Rules</th>
33+
{% if object.type == 'standard' %}
34+
<td>{{ object.aclstandardrules.count|placeholder }}</td>
35+
{% elif object.type == 'extended' %}
36+
<td>{{ object.aclextendedrules.count|placeholder }}</td>
37+
{% endif %}
38+
</tr>
39+
<tr>
40+
<th scope="row">Assigned Host</th>
41+
<td>{{ object.assigned_object|linkify }}</td>
42+
</tr>
43+
</table>
44+
</div>
45+
</div>
46+
{% include 'inc/panels/custom_fields.html' %}
47+
</div>
48+
<div class="col col-md-6">
49+
{% include 'inc/panels/tags.html' %}
50+
{% include 'inc/panels/comments.html' %}
7151
</div>
72-
</div>
73-
{% include 'inc/panels/custom_fields.html' %}
74-
</div>
75-
<div class="col col-md-6">
76-
{% include 'inc/panels/tags.html' %}
77-
{% include 'inc/panels/comments.html' %}
7852
</div>
79-
</div>
80-
<div class="row">
81-
<div class="col col-md-12">
82-
<div class="card">
83-
<h5 class="card-header">{{ object.get_type_display }} Rules</h5>
84-
<div class="card-body table-responsive">
85-
{% render_table rules_table %}
53+
<div class="row">
54+
<div class="col col-md-12">
55+
<div class="card">
56+
<h5 class="card-header">{{ object.get_type_display }} Rules</h5>
57+
<div class="card-body table-responsive">
58+
{% render_table rules_table %}
59+
</div>
60+
</div>
8661
</div>
87-
</div>
8862
</div>
89-
</div>
9063
{% endblock content %}

netbox_acls/templates/netbox_acls/accesslist_edit.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ <h4>Host Assignment</h4>
6767
{% render_field form.virtual_chassis %}
6868
</div>
6969
<div class="tab-pane{% if form.initial.virtual_machine %} active{% endif %}" id="virtualmachine">
70+
{% render_field form.cluster_type %}
71+
{% render_field form.cluster_group %}
72+
{% render_field form.cluster %}
7073
{% render_field form.virtual_machine %}
7174
</div>
7275
</div>

netbox_acls/templates/netbox_acls/aclinterfaceassignment.html

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
{% extends 'generic/object.html' %}
22
{% load render_table from django_tables2 %}
33

4-
{% block breadcrumbs %}
5-
<li class="breadcrumb-item"><a href="{% url 'plugins:netbox_acls:aclinterfaceassignment_list' %}">ACL Interface Assignments</a></li>
6-
{% endblock %}
7-
{% block controls %}
8-
<div class="pull-right noprint">
9-
{% if perms.netbox_acls.change_policy %}
10-
<a href="{% url 'plugins:netbox_acls:aclinterfaceassignment_edit' pk=object.pk %}" class="btn btn-warning">
11-
<span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
12-
</a>
13-
{% endif %}
14-
{% if perms.netbox_acls.delete_policy %}
15-
<a href="{% url 'plugins:netbox_acls:aclinterfaceassignment_delete' pk=object.pk %}" class="btn btn-danger">
16-
<span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
17-
</a>
18-
{% endif %}
19-
</div>
20-
{% endblock controls %}
21-
{% block tabs %}
22-
<ul class="nav nav-tabs px-3">
23-
{% block tab_items %}
24-
<li class="nav-item" role="presentation">
25-
<a class="nav-link{% if not active_tab %} active{% endif %}" href="{{ object.get_absolute_url }}">{{ object|meta:"verbose_name"|bettertitle }}</a>
26-
</li>
27-
{% endblock tab_items %}
28-
{% if perms.extras.view_objectchange %}
29-
<li role="presentation" class="nav-item">
30-
<a href="{% url 'plugins:netbox_acls:aclinterfaceassignment_changelog' pk=object.pk %}" class="nav-link{% if active_tab == 'changelog'%} active{% endif %}">Change Log</a>
31-
</li>
32-
{% endif %}
33-
</ul>
34-
{% endblock tabs %}
35-
364
{% block content %}
375
<div class="row mb-3">
386
<div class="col col-md-6">

0 commit comments

Comments
 (0)