Skip to content

Commit d241755

Browse files
authored
Added prerequisite models (#78)
* added prerequisite models #77
1 parent 3ce62ab commit d241755

File tree

7 files changed

+29
-12
lines changed

7 files changed

+29
-12
lines changed

.devcontainer/configuration/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"netbox_acls",
1010
]
1111

12-
PLUGINS_CONFIG = { # type: ignore
12+
PLUGINS_CONFIG = { # type: ignore
1313
"netbox_initializers": {},
1414
"netbox_acls": {},
1515
}

.github/workflows/sonarcloud.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
# separate terms of service, privacy policy, and support
44
# documentation.
55

6-
# This workflow helps you trigger a SonarCloud analysis of your code and populates
6+
# This workflow helps you trigger a SonarCloud analysis of your code and populates
77
# GitHub Code Scanning alerts with the vulnerabilities found.
88
# Free for open source project.
99

1010
# 1. Login to SonarCloud.io using your GitHub account
1111

1212
# 2. Import your project on SonarCloud
1313
# * Add your GitHub organization first, then add your repository as a new project.
14-
# * Please note that many languages are eligible for automatic analysis,
14+
# * Please note that many languages are eligible for automatic analysis,
1515
# which means that the analysis will start automatically without the need to set up GitHub Actions.
1616
# * This behavior can be changed in Administration > Analysis Method.
17-
#
17+
#
1818
# 3. Follow the SonarCloud in-product tutorial
1919
# * a. Copy/paste the Project Key and the Organization Key into the args parameter below
2020
# (You'll find this information in SonarCloud. Click on "Information" at the bottom left)
2121
#
2222
# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN
23-
# (On SonarCloud, click on your avatar on top-right > My account > Security
23+
# (On SonarCloud, click on your avatar on top-right > My account > Security
2424
# or go directly to https://sonarcloud.io/account/security/)
2525

2626
# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/)
@@ -41,9 +41,9 @@ permissions:
4141
jobs:
4242
Analysis:
4343
runs-on: ubuntu-latest
44-
44+
4545
steps:
46-
- name: Analyze with SonarCloud
46+
- name: Analyze with SonarCloud
4747

4848
# You can pin the exact commit or the version.
4949
# uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049
@@ -53,7 +53,7 @@ jobs:
5353
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
5454
with:
5555
# Additional arguments for the sonarcloud scanner
56-
args:
56+
args:
5757
# Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
5858
# mandatory
5959
-Dsonar.projectKey=
@@ -65,4 +65,4 @@ jobs:
6565
# Comma-separated paths to directories containing test source files.
6666
#-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
6767
# Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
68-
#-Dsonar.verbose= # optional, default is false
68+
#-Dsonar.verbose= # optional, default is false

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ repos:
6262
# entry: wily diff
6363
# verbose: true
6464
# language: python
65-
# additional_dependencies: [wily]
65+
# additional_dependencies: [wily]

netbox_acls/forms/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def clean(self):
410410
def save(self, *args, **kwargs):
411411
# Set assigned object
412412
self.instance.assigned_object = self.cleaned_data.get(
413-
"interface"
413+
"interface",
414414
) or self.cleaned_data.get("vminterface")
415415
return super().save(*args, **kwargs)
416416

netbox_acls/models/access_list_rules.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Define the django models for this plugin.
33
"""
44

5+
from django.apps import apps
56
from django.contrib.postgres.fields import ArrayField
67
from django.db import models
78
from django.urls import reverse
@@ -57,6 +58,10 @@ def __str__(self):
5758
def get_action_color(self):
5859
return ACLRuleActionChoices.colors.get(self.action)
5960

61+
@classmethod
62+
def get_prerequisite_models(cls):
63+
return [apps.get_model("ipam.Prefix"), AccessList]
64+
6065
class Meta:
6166
"""
6267
Define the common model properties:
@@ -90,6 +95,10 @@ def get_absolute_url(self):
9095
"""
9196
return reverse("plugins:netbox_acls:aclstandardrule", args=[self.pk])
9297

98+
@classmethod
99+
def get_prerequisite_models(cls):
100+
return [AccessList]
101+
93102
class Meta(ACLRule.Meta):
94103
"""
95104
Define the model properties adding to or overriding the inherited class:
@@ -151,6 +160,10 @@ def get_absolute_url(self):
151160
def get_protocol_color(self):
152161
return ACLProtocolChoices.colors.get(self.protocol)
153162

163+
@classmethod
164+
def get_prerequisite_models(cls):
165+
return [apps.get_model("ipam.Prefix"), AccessList]
166+
154167
class Meta(ACLRule.Meta):
155168
"""
156169
Define the model properties adding to or overriding the inherited class:

netbox_acls/models/access_lists.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def get_absolute_url(self):
139139
args=[self.pk],
140140
)
141141

142+
@classmethod
143+
def get_prerequisite_models(cls):
144+
return [AccessList]
145+
142146
def get_direction_color(self):
143147
return ACLAssignmentDirectionChoices.colors.get(self.direction)
144148

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from setuptools import find_packages, setup
55

6-
with open("README.md", "r") as fh:
6+
with open("README.md") as fh:
77
long_description = fh.read()
88

99

0 commit comments

Comments
 (0)