From cd3b7287041daa93acda28e8e9e7337de89875ae Mon Sep 17 00:00:00 2001 From: ryanmerolle Date: Wed, 20 Jul 2022 19:17:44 +0000 Subject: [PATCH] update verbose name to use 'Access List' --- .../ISSUE_TEMPLATE/documentation_change.yaml | 2 +- README.md | 2 +- netbox_access_lists/__init__.py | 2 +- netbox_access_lists/choices.py | 8 ++--- netbox_access_lists/forms/bulk_edit.py | 4 +-- netbox_access_lists/forms/models.py | 16 +++++----- .../migrations/0001_initial.py | 5 +++- .../models/access_list_rules.py | 30 +++++++++++++++++-- netbox_access_lists/models/access_lists.py | 5 +++- netbox_access_lists/navigation.py | 10 +++---- .../templates/inc/device/access_lists.html | 4 +-- .../netbox_access_lists/accesslist.html | 4 +-- .../netbox_access_lists/aclextendedrule.html | 4 +-- .../netbox_access_lists/aclstandardrule.html | 4 +-- netbox_access_lists/urls.py | 6 ++-- netbox_access_lists/views.py | 2 +- setup.py | 2 +- 17 files changed, 71 insertions(+), 39 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/documentation_change.yaml b/.github/ISSUE_TEMPLATE/documentation_change.yaml index 84ded74..2f8656e 100644 --- a/.github/ISSUE_TEMPLATE/documentation_change.yaml +++ b/.github/ISSUE_TEMPLATE/documentation_change.yaml @@ -1,6 +1,6 @@ --- name: 📖 Documentation Change -description: Suggest an addition or modification to the NetBox access-list plugin documentation +description: Suggest an addition or modification to the NetBox Access Lists plugin documentation title: "[Docs]: " labels: ["documentation"] body: diff --git a/README.md b/README.md index 093cd9f..daaa042 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # netbox-access-lists -A NetBox plugin for Access-List management +A NetBox plugin for Access List management ## Origin diff --git a/netbox_access_lists/__init__.py b/netbox_access_lists/__init__.py index 7d4ea90..3b49054 100644 --- a/netbox_access_lists/__init__.py +++ b/netbox_access_lists/__init__.py @@ -7,7 +7,7 @@ from extras.plugins import PluginConfig class NetBoxAccessListsConfig(PluginConfig): name = 'netbox_access_lists' - verbose_name = 'Access-Lists' + verbose_name = 'Access Lists' description = 'Manage simple ACLs in NetBox' version = '0.1' base_url = 'access-lists' diff --git a/netbox_access_lists/choices.py b/netbox_access_lists/choices.py index 71a4b7e..086c665 100644 --- a/netbox_access_lists/choices.py +++ b/netbox_access_lists/choices.py @@ -14,7 +14,7 @@ __all__ = ( class ACLActionChoices(ChoiceSet): """ - Defines the choices availble for the Access-List plugin specific to ACL default_action. + Defines the choices availble for the Access Lists plugin specific to ACL default_action. """ ACTION_DENY = 'deny' ACTION_PERMIT = 'permit' @@ -29,7 +29,7 @@ class ACLActionChoices(ChoiceSet): class ACLRuleActionChoices(ChoiceSet): """ - Defines the choices availble for the Access-List plugin specific to ACL rule actions. + Defines the choices availble for the Access Lists plugin specific to ACL rule actions. """ ACTION_DENY = 'deny' ACTION_PERMIT = 'permit' @@ -44,7 +44,7 @@ class ACLRuleActionChoices(ChoiceSet): class ACLTypeChoices(ChoiceSet): """ - Defines the choices availble for the Access-List plugin specific to ACL type. + Defines the choices availble for the Access Lists plugin specific to ACL type. """ CHOICES = [ ('extended', 'Extended', 'purple'), @@ -54,7 +54,7 @@ class ACLTypeChoices(ChoiceSet): class ACLProtocolChoices(ChoiceSet): """ - Defines the choices availble for the Access-List plugin specific to ACL Rule protocol. + Defines the choices availble for the Access Lists plugin specific to ACL Rule protocol. """ CHOICES = [ ('icmp', 'ICMP', 'purple'), diff --git a/netbox_access_lists/forms/bulk_edit.py b/netbox_access_lists/forms/bulk_edit.py index d984e46..56c1f34 100644 --- a/netbox_access_lists/forms/bulk_edit.py +++ b/netbox_access_lists/forms/bulk_edit.py @@ -57,7 +57,7 @@ from ..models import AccessList # # fieldsets = [ # ('Host Details', ('region', 'site_group', 'site', 'device')), -# ('Access-List Details', ('type', 'default_action', 'add_tags', 'remove_tags')), +# ('Access List Details', ('type', 'default_action', 'add_tags', 'remove_tags')), # ] # # @@ -67,7 +67,7 @@ from ..models import AccessList # help_texts = { # 'default_action': 'The default behavior of the ACL.', # 'name': 'The name uniqueness per device is case insensitive.', -# 'type': mark_safe('*Note: CANNOT be changed if ACL Rules are assoicated to this Access-List.'), +# 'type': mark_safe('*Note: CANNOT be changed if ACL Rules are assoicated to this Access List.'), # } # # def clean(self): # Not working given you are bulkd editing multiple forms diff --git a/netbox_access_lists/forms/models.py b/netbox_access_lists/forms/models.py index ddec355..c2e645d 100644 --- a/netbox_access_lists/forms/models.py +++ b/netbox_access_lists/forms/models.py @@ -57,7 +57,7 @@ class AccessListForm(NetBoxModelForm): fieldsets = [ ('Host Details', ('region', 'site_group', 'site', 'device')), - ('Access-List Details', ('name', 'type', 'default_action', 'tags')), + ('Access List Details', ('name', 'type', 'default_action', 'tags')), ] class Meta: @@ -66,7 +66,7 @@ class AccessListForm(NetBoxModelForm): help_texts = { 'default_action': 'The default behavior of the ACL.', 'name': 'The name uniqueness per device is case insensitive.', - 'type': mark_safe('*Note: CANNOT be changed if ACL Rules are assoicated to this Access-List.'), + 'type': mark_safe('*Note: CANNOT be changed if ACL Rules are assoicated to this Access List.'), } def clean(self): @@ -90,7 +90,7 @@ class AccessListForm(NetBoxModelForm): class ACLStandardRuleForm(NetBoxModelForm): """ - GUI form to add or edit Standard Access-List. + GUI form to add or edit Standard Access List. Requires an access_list, an index, and ACL rule type. See the clean function for logic on other field requirements. """ @@ -100,7 +100,7 @@ class ACLStandardRuleForm(NetBoxModelForm): 'type': 'standard' }, help_text=mark_safe('*Note: This field will only display Standard ACLs.'), - label='Access-List', + label='Access List', ) source_prefix = DynamicModelChoiceField( queryset=Prefix.objects.all(), @@ -114,7 +114,7 @@ class ACLStandardRuleForm(NetBoxModelForm): ) fieldsets = ( - ('Access-List Details', ('access_list', 'description', 'tags')), + ('Access List Details', ('access_list', 'description', 'tags')), ('Rule Definition', ('index', 'action', 'remark', 'source_prefix')), ) @@ -152,7 +152,7 @@ class ACLStandardRuleForm(NetBoxModelForm): class ACLExtendedRuleForm(NetBoxModelForm): """ - GUI form to add or edit Extended Access-List. + GUI form to add or edit Extended Access List. Requires an access_list, an index, and ACL rule type. See the clean function for logic on other field requirements. """ @@ -162,7 +162,7 @@ class ACLExtendedRuleForm(NetBoxModelForm): 'type': 'extended' }, help_text=mark_safe('*Note: This field will only display Extended ACLs.'), - label='Access-List', + label='Access List', ) tags = DynamicModelMultipleChoiceField( queryset=Tag.objects.all(), @@ -181,7 +181,7 @@ class ACLExtendedRuleForm(NetBoxModelForm): label='Destination Prefix', ) fieldsets = ( - ('Access-List Details', ('access_list', 'description', 'tags')), + ('Access List Details', ('access_list', 'description', 'tags')), ('Rule Definition', ('index', 'action', 'remark', 'source_prefix', 'source_ports', 'destination_prefix', 'destination_ports', 'protocol',)), ) diff --git a/netbox_access_lists/migrations/0001_initial.py b/netbox_access_lists/migrations/0001_initial.py index a1d4a58..e95f69f 100644 --- a/netbox_access_lists/migrations/0001_initial.py +++ b/netbox_access_lists/migrations/0001_initial.py @@ -14,7 +14,7 @@ __all__ = ( class Migration(migrations.Migration): """ - Defines the migrations required for the initial setup of the access-list plugin and its associated django models. + Defines the migrations required for the initial setup of the access lists plugin and its associated django models. """ initial = True @@ -42,6 +42,7 @@ class Migration(migrations.Migration): options={ 'ordering': ('name', 'device'), 'unique_together': {('name', 'device')}, + 'verbose_name': 'Access List', }, ), migrations.CreateModel( @@ -62,6 +63,7 @@ class Migration(migrations.Migration): options={ 'ordering': ('access_list', 'index'), 'unique_together': {('access_list', 'index')}, + 'verbose_name': 'ACL Standard Rule', }, ), migrations.CreateModel( @@ -86,6 +88,7 @@ class Migration(migrations.Migration): options={ 'ordering': ('access_list', 'index'), 'unique_together': {('access_list', 'index')}, + 'verbose_name': 'ACL Extended Rule', }, ), ] diff --git a/netbox_access_lists/models/access_list_rules.py b/netbox_access_lists/models/access_list_rules.py index e5e6fb4..417f720 100644 --- a/netbox_access_lists/models/access_list_rules.py +++ b/netbox_access_lists/models/access_list_rules.py @@ -25,7 +25,7 @@ class ACLRule(NetBoxModel): access_list = models.ForeignKey( on_delete=models.CASCADE, to=AccessList, - verbose_name='Access-List', + verbose_name='Access List', ) index = models.PositiveIntegerField() remark = models.CharField( @@ -57,8 +57,13 @@ class ACLRule(NetBoxModel): return ACLRuleActionChoices.colors.get(self.action) class Meta: + """ + Define the common model properties: + - as an abstract model + - ordering + - unique together + """ abstract = True - default_related_name='%(class)ss' ordering = ('access_list', 'index') unique_together = ('access_list', 'index') @@ -75,6 +80,16 @@ class ACLStandardRule(ACLRule): """ return reverse('plugins:netbox_access_lists:aclstandardrule', args=[self.pk]) + class Meta(ACLRule.Meta): + """ + Define the model properties adding to or overriding the inherited class: + - default_related_name for any FK relationships + - verbose name (for displaying in the GUI) + - verbose name plural (for displaying in the GUI) + """ + default_related_name='aclstandardrules' + verbose_name='ACL Standard Rule' + verbose_name_plural='ACL Standard Rules' class ACLExtendedRule(ACLRule): """ @@ -116,3 +131,14 @@ class ACLExtendedRule(ACLRule): def get_protocol_color(self): return ACLProtocolChoices.colors.get(self.protocol) + + class Meta(ACLRule.Meta): + """ + Define the model properties adding to or overriding the inherited class: + - default_related_name for any FK relationships + - verbose name (for displaying in the GUI) + - verbose name plural (for displaying in the GUI) + """ + default_related_name='aclextendedrules' + verbose_name='ACL Extended Rule' + verbose_name_plural='ACL Extended Rules' diff --git a/netbox_access_lists/models/access_lists.py b/netbox_access_lists/models/access_lists.py index bc3c7e2..6572600 100644 --- a/netbox_access_lists/models/access_lists.py +++ b/netbox_access_lists/models/access_lists.py @@ -15,7 +15,7 @@ __all__ = ( class AccessList(NetBoxModel): """ - Model defintion for Access-Lists. + Model defintion for Access Lists. """ name = models.CharField( max_length=100 @@ -42,6 +42,9 @@ class AccessList(NetBoxModel): class Meta: ordering = ('name', 'device') unique_together = ('name', 'device') + default_related_name='accesslists' + verbose_name='Access List' + verbose_name_plural='Access Lists' def __str__(self): return self.name diff --git a/netbox_access_lists/navigation.py b/netbox_access_lists/navigation.py index 4d6f5f1..0ba5610 100644 --- a/netbox_access_lists/navigation.py +++ b/netbox_access_lists/navigation.py @@ -43,19 +43,19 @@ aclextendedrule_butons = [ menu_items = ( PluginMenuItem( link='plugins:netbox_access_lists:accesslist_list', - link_text='Access-Lists', + link_text='Access Lists', buttons=accesslist_buttons ), - # Comment out Standard Access-List rule to force creation in the ACL view + # Comment out Standard Access List rule to force creation in the ACL view PluginMenuItem( link='plugins:netbox_access_lists:aclstandardrule_list', - link_text='Standard Access-List Rules', + link_text='ACL Standard Rule', buttons=aclstandardrule_butons ), - # Comment out Extended Access-List rule to force creation in the ACL view + # Comment out Extended Access List rule to force creation in the ACL view PluginMenuItem( link='plugins:netbox_access_lists:aclextendedrule_list', - link_text='Extended Access-List Rules', + link_text='ACL Extended Rules', buttons=aclextendedrule_butons ), ) diff --git a/netbox_access_lists/templates/inc/device/access_lists.html b/netbox_access_lists/templates/inc/device/access_lists.html index 374abba..7bdb9b9 100644 --- a/netbox_access_lists/templates/inc/device/access_lists.html +++ b/netbox_access_lists/templates/inc/device/access_lists.html @@ -1,13 +1,13 @@
- Access-Lists + Access Lists
{% include 'inc/device/assigned_access_lists.html' %}
diff --git a/netbox_access_lists/templates/netbox_access_lists/accesslist.html b/netbox_access_lists/templates/netbox_access_lists/accesslist.html index f8bb721..b608a86 100644 --- a/netbox_access_lists/templates/netbox_access_lists/accesslist.html +++ b/netbox_access_lists/templates/netbox_access_lists/accesslist.html @@ -2,7 +2,7 @@ {% load render_table from django_tables2 %} {% block breadcrumbs %} - + {% endblock %} {% block controls %}
@@ -46,7 +46,7 @@
-
Access-List
+
Access List
diff --git a/netbox_access_lists/templates/netbox_access_lists/aclextendedrule.html b/netbox_access_lists/templates/netbox_access_lists/aclextendedrule.html index fc3b3c9..0f06229 100644 --- a/netbox_access_lists/templates/netbox_access_lists/aclextendedrule.html +++ b/netbox_access_lists/templates/netbox_access_lists/aclextendedrule.html @@ -4,11 +4,11 @@
-
Extended Access-List Rule
+
ACL Extended Rule
- + diff --git a/netbox_access_lists/templates/netbox_access_lists/aclstandardrule.html b/netbox_access_lists/templates/netbox_access_lists/aclstandardrule.html index 41a13bb..a6cf25d 100644 --- a/netbox_access_lists/templates/netbox_access_lists/aclstandardrule.html +++ b/netbox_access_lists/templates/netbox_access_lists/aclstandardrule.html @@ -4,11 +4,11 @@
-
Standard Access-List Rule
+
ACL Standard Rule
Access-ListAccess List {{ object.access_list }}
- + diff --git a/netbox_access_lists/urls.py b/netbox_access_lists/urls.py index bf89314..32966c2 100644 --- a/netbox_access_lists/urls.py +++ b/netbox_access_lists/urls.py @@ -9,7 +9,7 @@ from . import models, views urlpatterns = ( - # Access-Lists + # Access Lists path('access-lists/', views.AccessListListView.as_view(), name='accesslist_list'), path('access-lists/add/', views.AccessListEditView.as_view(), name='accesslist_add'), #path('access-lists/edit/', views.AccessListBulkEditView.as_view(), name='accesslist_bulk_edit'), @@ -20,7 +20,7 @@ urlpatterns = ( 'model': models.AccessList }), - # Standard Access-List rules + # Standard Access List rules path('standard-rules/', views.ACLStandardRuleListView.as_view(), name='aclstandardrule_list'), path('standard-rules/add/', views.ACLStandardRuleEditView.as_view(), name='aclstandardrule_add'), path('standard-rules//', views.ACLStandardRuleView.as_view(), name='aclstandardrule'), @@ -30,7 +30,7 @@ urlpatterns = ( 'model': models.ACLStandardRule }), - # Extended Access-List rules + # Extended Access List rules path('extended-rules/', views.ACLExtendedRuleListView.as_view(), name='aclextendedrule_list'), path('extended-rules/add/', views.ACLExtendedRuleEditView.as_view(), name='aclextendedrule_add'), path('extended-rules//', views.ACLExtendedRuleView.as_view(), name='aclextendedrule'), diff --git a/netbox_access_lists/views.py b/netbox_access_lists/views.py index 465f72f..b58071a 100644 --- a/netbox_access_lists/views.py +++ b/netbox_access_lists/views.py @@ -35,7 +35,7 @@ class AccessListView(generic.ObjectView): def get_extra_context(self, request, instance): """ - Depending on the Access-List type, the list view will return the required ACL Rule using the previous defined tables in tables.py. + Depending on the Access List type, the list view will return the required ACL Rule using the previous defined tables in tables.py. """ if instance.type == 'extended': table = tables.ACLExtendedRuleTable(instance.aclextendedrules.all()) diff --git a/setup.py b/setup.py index dc35cc1..4dc7fdc 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ setup( name='netbox-access-lists', version='0.1.0', #version=get_version('netbox_access_lists/version.py'), - description='A NetBox plugin for Access-List management', + description='A NetBox plugin for Access List management', #long_description=long_description, long_description_content_type="text/markdown", url='https://github.com/ryanmerolle/netbox-access-lists',
Access-ListAccess List {{ object.access_list }}