mirror of
https://github.com/lucaspalomodevelop/netbox-acls.git
synced 2026-03-12 23:27:23 +00:00
Add ACL type - Closes #1
This commit is contained in:
parent
e100fcd18c
commit
c6c1556fbf
@ -42,7 +42,7 @@ class AccessListSerializer(NetBoxModelSerializer):
|
||||
class Meta:
|
||||
model = AccessList
|
||||
fields = (
|
||||
'id', 'url', 'display', 'name', 'default_action', 'comments', 'tags', 'custom_fields', 'created',
|
||||
'id', 'url', 'display', 'name', 'type', 'default_action', 'comments', 'tags', 'custom_fields', 'created',
|
||||
'last_updated', 'rule_count',
|
||||
)
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class AccessListForm(NetBoxModelForm):
|
||||
|
||||
class Meta:
|
||||
model = AccessList
|
||||
fields = ('name', 'default_action', 'comments', 'tags')
|
||||
fields = ('name', 'type', 'default_action', 'comments', 'tags')
|
||||
|
||||
|
||||
class AccessListRuleForm(NetBoxModelForm):
|
||||
|
||||
@ -23,6 +23,7 @@ class Migration(migrations.Migration):
|
||||
('last_updated', models.DateTimeField(auto_now=True, null=True)),
|
||||
('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('type', models.CharField(max_length=100)),
|
||||
('default_action', models.CharField(max_length=30)),
|
||||
('comments', models.TextField(blank=True)),
|
||||
('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
|
||||
|
||||
@ -16,6 +16,14 @@ class ActionChoices(ChoiceSet):
|
||||
]
|
||||
|
||||
|
||||
class TypeChoices(ChoiceSet):
|
||||
|
||||
CHOICES = [
|
||||
('standard', 'Standard', 'blue'),
|
||||
('extended', 'Extended', 'purple'),
|
||||
]
|
||||
|
||||
|
||||
class ProtocolChoices(ChoiceSet):
|
||||
|
||||
CHOICES = [
|
||||
@ -29,6 +37,10 @@ class AccessList(NetBoxModel):
|
||||
name = models.CharField(
|
||||
max_length=100
|
||||
)
|
||||
type = models.CharField(
|
||||
max_length=30,
|
||||
choices=TypeChoices
|
||||
)
|
||||
default_action = models.CharField(
|
||||
max_length=30,
|
||||
choices=ActionChoices
|
||||
@ -49,6 +61,9 @@ class AccessList(NetBoxModel):
|
||||
def get_default_action_color(self):
|
||||
return ActionChoices.colors.get(self.default_action)
|
||||
|
||||
def get_type_color(self):
|
||||
return TypeChoices.colors.get(self.type)
|
||||
|
||||
|
||||
class AccessListRule(NetBoxModel):
|
||||
access_list = models.ForeignKey(
|
||||
|
||||
@ -8,13 +8,14 @@ class AccessListTable(NetBoxTable):
|
||||
name = tables.Column(
|
||||
linkify=True
|
||||
)
|
||||
type = ChoiceFieldColumn()
|
||||
default_action = ChoiceFieldColumn()
|
||||
rule_count = tables.Column()
|
||||
|
||||
class Meta(NetBoxTable.Meta):
|
||||
model = AccessList
|
||||
fields = ('pk', 'id', 'name', 'rule_count', 'default_action', 'comments', 'actions')
|
||||
default_columns = ('name', 'rule_count', 'default_action')
|
||||
fields = ('pk', 'id', 'name', 'type', 'rule_count', 'default_action', 'comments', 'actions')
|
||||
default_columns = ('name', 'type', 'rule_count', 'default_action')
|
||||
|
||||
|
||||
class AccessListRuleTable(NetBoxTable):
|
||||
|
||||
@ -12,6 +12,10 @@
|
||||
<th scope="row">Name</th>
|
||||
<td>{{ object.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Default Action</th>
|
||||
<td>{{ object.get_type_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Default Action</th>
|
||||
<td>{{ object.get_default_action_display }}</td>
|
||||
|
||||
4
setup.py
4
setup.py
@ -2,8 +2,8 @@ from setuptools import find_packages, setup
|
||||
|
||||
setup(
|
||||
name='netbox-access-lists',
|
||||
version='0.1',
|
||||
description='An example NetBox plugin',
|
||||
version='0.2',
|
||||
description='A NetBox plugin for Access-List management',
|
||||
install_requires=[],
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user