Jelajahi Sumber

Define __all__ for models.py within each app

Jeremy Stretch 6 tahun lalu
induk
melakukan
6959785cd1

+ 8 - 0
netbox/circuits/models.py

@@ -12,6 +12,14 @@ from utilities.utils import serialize_object
 from .choices import *
 
 
+__all__ = (
+    'Circuit',
+    'CircuitTermination',
+    'CircuitType',
+    'Provider',
+)
+
+
 class Provider(ChangeLoggedModel, CustomFieldModel):
     """
     Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model

+ 20 - 0
netbox/extras/models.py

@@ -19,6 +19,26 @@ from .constants import *
 from .querysets import ConfigContextQuerySet
 
 
+__all__ = (
+    'ConfigContext',
+    'ConfigContextModel',
+    'CustomField',
+    'CustomFieldChoice',
+    'CustomFieldModel',
+    'CustomFieldValue',
+    'CustomLink',
+    'ExportTemplate',
+    'Graph',
+    'ImageAttachment',
+    'ObjectChange',
+    'ReportResult',
+    'Script',
+    'Tag',
+    'TaggedItem',
+    'Webhook',
+)
+
+
 #
 # Webhooks
 #

+ 11 - 0
netbox/ipam/constants.py

@@ -0,0 +1,11 @@
+from .choices import IPAddressRoleChoices
+
+IPADDRESS_ROLES_NONUNIQUE = (
+    # IPAddress roles which are exempt from unique address enforcement
+    IPAddressRoleChoices.ROLE_ANYCAST,
+    IPAddressRoleChoices.ROLE_VIP,
+    IPAddressRoleChoices.ROLE_VRRP,
+    IPAddressRoleChoices.ROLE_HSRP,
+    IPAddressRoleChoices.ROLE_GLBP,
+    IPAddressRoleChoices.ROLE_CARP,
+)

+ 12 - 8
netbox/ipam/models.py

@@ -15,6 +15,7 @@ from utilities.models import ChangeLoggedModel
 from utilities.utils import serialize_object
 from virtualization.models import VirtualMachine
 from .choices import *
+from .constants import IPADDRESS_ROLES_NONUNIQUE
 from .fields import IPNetworkField, IPAddressField
 from .querysets import PrefixQuerySet
 from .validators import DNSValidator
@@ -26,14 +27,17 @@ AF_CHOICES = (
     (6, 'IPv6'),
 )
 
-IPADDRESS_ROLES_NONUNIQUE = (
-    # IPAddress roles which are exempt from unique address enforcement
-    IPAddressRoleChoices.ROLE_ANYCAST,
-    IPAddressRoleChoices.ROLE_VIP,
-    IPAddressRoleChoices.ROLE_VRRP,
-    IPAddressRoleChoices.ROLE_HSRP,
-    IPAddressRoleChoices.ROLE_GLBP,
-    IPAddressRoleChoices.ROLE_CARP,
+
+__all__ = (
+    'Aggregate',
+    'IPAddress',
+    'Prefix',
+    'RIR',
+    'Role',
+    'Service',
+    'VLAN',
+    'VLANGroup',
+    'VRF',
 )
 
 

+ 8 - 0
netbox/secrets/models.py

@@ -21,6 +21,14 @@ from .hashers import SecretValidationHasher
 from .querysets import UserKeyQuerySet
 
 
+__all__ = (
+    'Secret',
+    'SecretRole',
+    'SessionKey',
+    'UserKey',
+)
+
+
 def generate_random_key(bits=256):
     """
     Generate a random encryption key. Sizes is given in bits and must be in increments of 32.

+ 6 - 0
netbox/tenancy/models.py

@@ -7,6 +7,12 @@ from extras.models import CustomFieldModel, TaggedItem
 from utilities.models import ChangeLoggedModel
 
 
+__all__ = (
+    'Tenant',
+    'TenantGroup',
+)
+
+
 class TenantGroup(ChangeLoggedModel):
     """
     An arbitrary collection of Tenants.

+ 5 - 0
netbox/users/models.py

@@ -7,6 +7,11 @@ from django.db import models
 from django.utils import timezone
 
 
+__all__ = (
+    'Token',
+)
+
+
 class Token(models.Model):
     """
     An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens.

+ 5 - 0
netbox/utilities/models.py

@@ -4,6 +4,11 @@ from extras.models import ObjectChange
 from utilities.utils import serialize_object
 
 
+__all__ = (
+    'ChangeLoggedModel',
+)
+
+
 class ChangeLoggedModel(models.Model):
     """
     An abstract model which adds fields to store the creation and last-updated times for an object. Both fields can be

+ 8 - 0
netbox/virtualization/models.py

@@ -11,6 +11,14 @@ from utilities.models import ChangeLoggedModel
 from .choices import *
 
 
+__all__ = (
+    'Cluster',
+    'ClusterGroup',
+    'ClusterType',
+    'VirtualMachine',
+)
+
+
 #
 # Cluster types
 #

+ 1 - 0
netbox/virtualization/tests/test_models.py

@@ -1,3 +1,4 @@
+from django.core.exceptions import ValidationError
 from django.test import TestCase
 
 from virtualization.models import *