From 80d9fe6573af41a1172e7e9b3b1cce17422b2f7b Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sat, 21 Jan 2023 18:05:18 +0530 Subject: [PATCH] Added clone fields and cleaned templates (#80) --- netbox_acls/models/access_list_rules.py | 2 + netbox_acls/models/access_lists.py | 7 + .../templates/netbox_acls/accesslist.html | 129 +++++++----------- .../netbox_acls/aclinterfaceassignment.html | 32 ----- 4 files changed, 60 insertions(+), 110 deletions(-) diff --git a/netbox_acls/models/access_list_rules.py b/netbox_acls/models/access_list_rules.py index 2dff662..f37aca8 100644 --- a/netbox_acls/models/access_list_rules.py +++ b/netbox_acls/models/access_list_rules.py @@ -52,6 +52,8 @@ class ACLRule(NetBoxModel): verbose_name="Source Prefix", ) + clone_fields = ("access_list", "action", "source_prefix") + def __str__(self): return f"{self.access_list}: Rule {self.index}" diff --git a/netbox_acls/models/access_lists.py b/netbox_acls/models/access_lists.py index 729e024..1feb635 100644 --- a/netbox_acls/models/access_lists.py +++ b/netbox_acls/models/access_lists.py @@ -59,6 +59,11 @@ class AccessList(NetBoxModel): blank=True, ) + clone_fields = ( + "type", + "default_action", + ) + class Meta: unique_together = ["assigned_object_type", "assigned_object_id", "name"] ordering = ["assigned_object_type", "assigned_object_id", "name"] @@ -113,6 +118,8 @@ class ACLInterfaceAssignment(NetBoxModel): blank=True, ) + clone_fields = ("access_list", "direction") + class Meta: unique_together = [ "assigned_object_type", diff --git a/netbox_acls/templates/netbox_acls/accesslist.html b/netbox_acls/templates/netbox_acls/accesslist.html index 6870f30..5821402 100644 --- a/netbox_acls/templates/netbox_acls/accesslist.html +++ b/netbox_acls/templates/netbox_acls/accesslist.html @@ -1,90 +1,63 @@ {% extends 'generic/object.html' %} {% load render_table from django_tables2 %} -{% block breadcrumbs %} - -{% endblock %} -{% block controls %} -
+{% block extra_controls %} {% if perms.netbox_acls.change_policy %} - {% if object.type == 'extended' %} - - {% elif object.type == 'standard' %} - - {% endif %} - Rule - - - Edit + {% if object.type == 'extended' %} + + {% elif object.type == 'standard' %} + + {% endif %} + Rule {% endif %} - {% if perms.netbox_acls.delete_policy %} - - Delete - - {% endif %} -
-{% endblock controls %} -{% block tabs %} - -{% endblock tabs %} +{% endblock extra_controls %} {% block content %} -
-
-
-
Access List
-
- - - - - - - - - - - - {% if object.type == 'standard' %} - - {% elif object.type == 'extended' %} - - {% endif %} - - - - - -
Type{{ object.get_type_display }}
Default Action{% badge object.get_default_action_display bg_color=object.get_default_action_color %}
Rules{{ object.aclstandardrules.count|placeholder }}{{ object.aclextendedrules.count|placeholder }}
Assigned Host{{ object.assigned_object|linkify }}
+
+
+
+
Access List
+
+ + + + + + + + + + + + {% if object.type == 'standard' %} + + {% elif object.type == 'extended' %} + + {% endif %} + + + + + +
Type{{ object.get_type_display }}
Default Action{% badge object.get_default_action_display bg_color=object.get_default_action_color %}
Rules{{ object.aclstandardrules.count|placeholder }}{{ object.aclextendedrules.count|placeholder }}
Assigned Host{{ object.assigned_object|linkify }}
+
+
+ {% include 'inc/panels/custom_fields.html' %}
-
- {% include 'inc/panels/custom_fields.html' %} -
-
- {% include 'inc/panels/tags.html' %} - {% include 'inc/panels/comments.html' %} -
-
-
-
-
-
{{ object.get_type_display }} Rules
-
- {% render_table rules_table %} +
+ {% include 'inc/panels/tags.html' %} + {% include 'inc/panels/comments.html' %} +
+
+
+
+
+
{{ object.get_type_display }} Rules
+
+ {% render_table rules_table %} +
+
-
-
{% endblock content %} diff --git a/netbox_acls/templates/netbox_acls/aclinterfaceassignment.html b/netbox_acls/templates/netbox_acls/aclinterfaceassignment.html index b46a26a..4cabeb0 100644 --- a/netbox_acls/templates/netbox_acls/aclinterfaceassignment.html +++ b/netbox_acls/templates/netbox_acls/aclinterfaceassignment.html @@ -1,38 +1,6 @@ {% extends 'generic/object.html' %} {% load render_table from django_tables2 %} -{% block breadcrumbs %} - -{% endblock %} -{% block controls %} -
- {% if perms.netbox_acls.change_policy %} - - Edit - - {% endif %} - {% if perms.netbox_acls.delete_policy %} - - Delete - - {% endif %} -
-{% endblock controls %} -{% block tabs %} - -{% endblock tabs %} - {% block content %}