Define __all__ for models.py within each app

This commit is contained in:
Jeremy Stretch 2020-01-14 12:01:23 -05:00
parent 26a257b794
commit 6959785cd1
10 changed files with 84 additions and 8 deletions

View File

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

View File

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

11
netbox/ipam/constants.py Normal file
View File

@ -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,
)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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