Exemplo n.º 1
0
class ClusterBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                          CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Cluster.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    type = DynamicModelChoiceField(queryset=ClusterType.objects.all(),
                                   required=False)
    group = DynamicModelChoiceField(queryset=ClusterGroup.objects.all(),
                                    required=False)
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    region = DynamicModelChoiceField(
        queryset=Region.objects.all(),
        required=False,
    )
    site_group = DynamicModelChoiceField(
        queryset=SiteGroup.objects.all(),
        required=False,
    )
    site = DynamicModelChoiceField(queryset=Site.objects.all(),
                                   required=False,
                                   query_params={
                                       'region_id': '$region',
                                       'group_id': '$site_group',
                                   })
    comments = CommentField(widget=SmallTextarea, label='Comments')

    class Meta:
        nullable_fields = [
            'group',
            'site',
            'comments',
            'tenant',
        ]
Exemplo n.º 2
0
class CircuitBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(
        queryset=Circuit.objects.all(),
        widget=forms.MultipleHiddenInput
    )
    type = DynamicModelChoiceField(
        queryset=CircuitType.objects.all(),
        required=False
    )
    provider = DynamicModelChoiceField(
        queryset=Provider.objects.all(),
        required=False
    )
    status = forms.ChoiceField(
        choices=add_blank_choice(CircuitStatusChoices),
        required=False,
        initial='',
        widget=StaticSelect2()
    )
    tenant = DynamicModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False
    )
    commit_rate = forms.IntegerField(
        required=False,
        label='Commit rate (Kbps)'
    )
    description = forms.CharField(
        max_length=100,
        required=False
    )
    comments = CommentField(
        widget=SmallTextarea,
        label='Comments'
    )

    class Meta:
        nullable_fields = [
            'tenant', 'commit_rate', 'description', 'comments',
        ]
Exemplo n.º 3
0
class RackBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Rack.objects.all(),
                                        widget=forms.MultipleHiddenInput)
    region = DynamicModelChoiceField(queryset=Region.objects.all(),
                                     required=False,
                                     initial_params={'sites': '$site'})
    site_group = DynamicModelChoiceField(queryset=SiteGroup.objects.all(),
                                         required=False,
                                         initial_params={'sites': '$site'})
    site = DynamicModelChoiceField(queryset=Site.objects.all(),
                                   required=False,
                                   query_params={
                                       'region_id': '$region',
                                       'group_id': '$site_group',
                                   })
    location = DynamicModelChoiceField(queryset=Location.objects.all(),
                                       required=False,
                                       query_params={'site_id': '$site'})
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    status = forms.ChoiceField(choices=add_blank_choice(RackStatusChoices),
                               required=False,
                               initial='',
                               widget=StaticSelect())
    role = DynamicModelChoiceField(queryset=RackRole.objects.all(),
                                   required=False)
    serial = forms.CharField(max_length=50,
                             required=False,
                             label='Serial Number')
    asset_tag = forms.CharField(max_length=50, required=False)
    type = forms.ChoiceField(choices=add_blank_choice(RackTypeChoices),
                             required=False,
                             widget=StaticSelect())
    width = forms.ChoiceField(choices=add_blank_choice(RackWidthChoices),
                              required=False,
                              widget=StaticSelect())
    u_height = forms.IntegerField(required=False, label='Height (U)')
    desc_units = forms.NullBooleanField(required=False,
                                        widget=BulkEditNullBooleanSelect,
                                        label='Descending units')
    outer_width = forms.IntegerField(required=False, min_value=1)
    outer_depth = forms.IntegerField(required=False, min_value=1)
    outer_unit = forms.ChoiceField(
        choices=add_blank_choice(RackDimensionUnitChoices),
        required=False,
        widget=StaticSelect())
    comments = CommentField(widget=SmallTextarea, label='Comments')

    class Meta:
        nullable_fields = [
            'location',
            'tenant',
            'role',
            'serial',
            'asset_tag',
            'outer_width',
            'outer_depth',
            'outer_unit',
            'comments',
        ]
Exemplo n.º 4
0
class TenantBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                         CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Tenant.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    group = DynamicModelChoiceField(
        queryset=TenantGroup.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/tenancy/tenant-groups/"))

    class Meta:
        nullable_fields = [
            'group',
        ]
Exemplo n.º 5
0
class SiteGroupForm(BootstrapMixin, CustomFieldModelForm):
    parent = DynamicModelChoiceField(queryset=SiteGroup.objects.all(),
                                     required=False)
    slug = SlugField()

    class Meta:
        model = SiteGroup
        fields = (
            'parent',
            'name',
            'slug',
            'description',
        )
Exemplo n.º 6
0
class RackReservationBulkEditForm(AddRemoveTagsForm,
                                  CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=RackReservation.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    user = forms.ModelChoiceField(queryset=User.objects.order_by('username'),
                                  required=False,
                                  widget=StaticSelect())
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = []
Exemplo n.º 7
0
class PowerPanelBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                             CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=PowerPanel.objects.all(),
                                        widget=forms.MultipleHiddenInput)
    region = DynamicModelChoiceField(queryset=Region.objects.all(),
                                     required=False,
                                     initial_params={'sites': '$site'})
    site_group = DynamicModelChoiceField(queryset=SiteGroup.objects.all(),
                                         required=False,
                                         initial_params={'sites': '$site'})
    site = DynamicModelChoiceField(queryset=Site.objects.all(),
                                   required=False,
                                   query_params={
                                       'region_id': '$region',
                                       'group_id': '$site_group',
                                   })
    location = DynamicModelChoiceField(queryset=Location.objects.all(),
                                       required=False,
                                       query_params={'site_id': '$site'})

    class Meta:
        nullable_fields = ['location']
Exemplo n.º 8
0
class PrefixBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                         CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Prefix.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/dcim/sites/"))
    vrf = DynamicModelChoiceField(queryset=VRF.objects.all(),
                                  required=False,
                                  label='VRF',
                                  widget=APISelect(api_url="/api/ipam/vrfs/"))
    prefix_length = forms.IntegerField(min_value=PREFIX_LENGTH_MIN,
                                       max_value=PREFIX_LENGTH_MAX,
                                       required=False)
    tenant = DynamicModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/tenancy/tenants/"))
    status = forms.ChoiceField(choices=add_blank_choice(PrefixStatusChoices),
                               required=False,
                               widget=StaticSelect2())
    role = DynamicModelChoiceField(
        queryset=Role.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/ipam/roles/"))
    is_pool = forms.NullBooleanField(required=False,
                                     widget=BulkEditNullBooleanSelect(),
                                     label='Is a pool')
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'site',
            'vrf',
            'tenant',
            'role',
            'description',
        ]
Exemplo n.º 9
0
class CommunityFilterForm(NetBoxModelFilterSetForm):
    q = forms.CharField(
        required=False,
        label='Search'
    )
    tenant = DynamicModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False
    )
    status = forms.MultipleChoiceField(
        choices=ASNStatusChoices,
        required=False,
        widget=StaticSelectMultiple()
    )
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False
    )

    tag = TagFilterField(Community)

    model = Community
Exemplo n.º 10
0
class TenantGroupForm(BootstrapMixin, forms.ModelForm):
    parent = DynamicModelChoiceField(queryset=TenantGroup.objects.all(),
                                     required=False)
    slug = SlugField()

    class Meta:
        model = TenantGroup
        fields = [
            'parent',
            'name',
            'slug',
            'description',
        ]
Exemplo n.º 11
0
class DeviceTypeBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                             CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=DeviceType.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    manufacturer = DynamicModelChoiceField(queryset=Manufacturer.objects.all(),
                                           required=False)
    u_height = forms.IntegerField(min_value=1, required=False)
    is_full_depth = forms.NullBooleanField(required=False,
                                           widget=BulkEditNullBooleanSelect(),
                                           label='Is full depth')

    class Meta:
        nullable_fields = []
Exemplo n.º 12
0
class VLANGroupForm(BootstrapMixin, forms.ModelForm):
    region = DynamicModelChoiceField(
        queryset=Region.objects.all(),
        required=False,
        initial_params={
            'sites': '$site'
        }
    )
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False,
        query_params={
            'region_id': '$region'
        }
    )
    slug = SlugField()

    class Meta:
        model = VLANGroup
        fields = [
            'region', 'site', 'name', 'slug', 'description',
        ]
Exemplo n.º 13
0
class ClusterForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
    type = DynamicModelChoiceField(
        queryset=ClusterType.objects.all()
    )
    group = DynamicModelChoiceField(
        queryset=ClusterGroup.objects.all(),
        required=False
    )
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False
    )
    comments = CommentField()
    tags = TagField(
        required=False
    )

    class Meta:
        model = Cluster
        fields = (
            'name', 'type', 'group', 'tenant', 'site', 'comments', 'tags',
        )
Exemplo n.º 14
0
class PowerFeedBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=PowerFeed.objects.all(),
                                        widget=forms.MultipleHiddenInput)
    power_panel = DynamicModelChoiceField(queryset=PowerPanel.objects.all(),
                                          required=False)
    rack = DynamicModelChoiceField(
        queryset=Rack.objects.all(),
        required=False,
    )
    status = forms.ChoiceField(
        choices=add_blank_choice(PowerFeedStatusChoices),
        required=False,
        initial='',
        widget=StaticSelect())
    type = forms.ChoiceField(choices=add_blank_choice(PowerFeedTypeChoices),
                             required=False,
                             initial='',
                             widget=StaticSelect())
    supply = forms.ChoiceField(
        choices=add_blank_choice(PowerFeedSupplyChoices),
        required=False,
        initial='',
        widget=StaticSelect())
    phase = forms.ChoiceField(choices=add_blank_choice(PowerFeedPhaseChoices),
                              required=False,
                              initial='',
                              widget=StaticSelect())
    voltage = forms.IntegerField(required=False)
    amperage = forms.IntegerField(required=False)
    max_utilization = forms.IntegerField(required=False)
    mark_connected = forms.NullBooleanField(required=False,
                                            widget=BulkEditNullBooleanSelect)
    comments = CommentField(widget=SmallTextarea, label='Comments')

    class Meta:
        nullable_fields = [
            'location',
            'comments',
        ]
Exemplo n.º 15
0
class RouteTargetBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                              CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=RouteTarget.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    description = forms.CharField(max_length=200, required=False)

    class Meta:
        nullable_fields = [
            'tenant',
            'description',
        ]
Exemplo n.º 16
0
class ASNForm(NetBoxModelForm):
    number = ASNField(
        widget=ASdotInput
    )
    tags = DynamicModelMultipleChoiceField(
        queryset=Tag.objects.all(),
        required=False
    )
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False
    )
    status = forms.ChoiceField(
        required=False,
        choices=ASNStatusChoices,
        widget=StaticSelect()
    )
    tenant = DynamicModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False
    )

    def clean(self):
        cleaned_data = super().clean()
        if self.errors.get('number'):
            return cleaned_data
        number = cleaned_data.get('number')
        tenant = cleaned_data.get('tenant')
        if 'number' in self.changed_data or 'tenant' in self.changed_data:
            if ASN.objects.filter(number=number, tenant=tenant).exists():
                raise forms.ValidationError('AS number with this number and tenant is already exists.')
        return cleaned_data

    class Meta:
        model = ASN
        fields = [
            'number', 'description', 'status', 'site', 'tenant', 'tags',
        ]
Exemplo n.º 17
0
class PrefixBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(
        queryset=Prefix.objects.all(),
        widget=forms.MultipleHiddenInput()
    )
    region = DynamicModelChoiceField(
        queryset=Region.objects.all(),
        required=False
    )
    site_group = DynamicModelChoiceField(
        queryset=SiteGroup.objects.all(),
        required=False
    )
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False,
        query_params={
            'region_id': '$region',
            'group_id': '$site_group',
        }
    )
    vrf = DynamicModelChoiceField(
        queryset=VRF.objects.all(),
        required=False,
        label='VRF'
    )
    prefix_length = forms.IntegerField(
        min_value=PREFIX_LENGTH_MIN,
        max_value=PREFIX_LENGTH_MAX,
        required=False
    )
    tenant = DynamicModelChoiceField(
        queryset=Tenant.objects.all(),
        required=False
    )
    status = forms.ChoiceField(
        choices=add_blank_choice(PrefixStatusChoices),
        required=False,
        widget=StaticSelect2()
    )
    role = DynamicModelChoiceField(
        queryset=Role.objects.all(),
        required=False
    )
    is_pool = forms.NullBooleanField(
        required=False,
        widget=BulkEditNullBooleanSelect(),
        label='Is a pool'
    )
    description = forms.CharField(
        max_length=100,
        required=False
    )

    class Meta:
        nullable_fields = [
            'site', 'vrf', 'tenant', 'role', 'description',
        ]
Exemplo n.º 18
0
class VLANForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
    site = DynamicModelChoiceField(queryset=Site.objects.all(),
                                   required=False,
                                   widget=APISelect(
                                       filter_for={'group': 'site_id'},
                                       attrs={
                                           'nullable': 'true',
                                       }))
    group = DynamicModelChoiceField(queryset=VLANGroup.objects.all(),
                                    required=False)
    role = DynamicModelChoiceField(queryset=Role.objects.all(), required=False)
    tags = TagField(required=False)

    class Meta:
        model = VLAN
        fields = [
            'site',
            'group',
            'vid',
            'name',
            'status',
            'role',
            'description',
            'tenant_group',
            'tenant',
            'tags',
        ]
        help_texts = {
            'site': "Leave blank if this VLAN spans multiple sites",
            'group': "VLAN group (optional)",
            'vid': "Configured VLAN ID",
            'name': "Configured VLAN name",
            'status': "Operational status of this VLAN",
            'role': "The primary function of this VLAN",
        }
        widgets = {
            'status': StaticSelect2(),
        }
Exemplo n.º 19
0
class VLANBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(
        queryset=VLAN.objects.all(),
        widget=forms.MultipleHiddenInput()
    )
    region = DynamicModelChoiceField(
        label='Регион',
        queryset=Region.objects.all(),
        required=False
    )
    site_group = DynamicModelChoiceField(
        label='site_group',
        queryset=SiteGroup.objects.all(),
        required=False
    )
    site = DynamicModelChoiceField(
        label='Адрес',
        queryset=Site.objects.all(),
        required=False,
        query_params={
            'region_id': '$region',
            'group_id': '$site_group',
        }
    )
    group = DynamicModelChoiceField(
        label='Группа',
        queryset=VLANGroup.objects.all(),
        required=False,
        query_params={
            'site_id': '$site'
        }
    )
    tenant = DynamicModelChoiceField(
        label='Учреждение',
        queryset=Tenant.objects.all(),
        required=False
    )
    status = forms.ChoiceField(
        label='Статус',
        choices=add_blank_choice(VLANStatusChoices),
        required=False,
        widget=StaticSelect2()
    )
    role = DynamicModelChoiceField(
        label='Роль',
        queryset=Role.objects.all(),
        required=False
    )
    description = forms.CharField(
        label='Описание',
        max_length=100,
        required=False
    )

    class Meta:
        nullable_fields = [
            'site', 'group', 'tenant', 'role', 'description',
        ]
Exemplo n.º 20
0
class ClusterForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
    type = DynamicModelChoiceField(queryset=ClusterType.objects.all())
    group = DynamicModelChoiceField(queryset=ClusterGroup.objects.all(),
                                    required=False)
    region = DynamicModelChoiceField(queryset=Region.objects.all(),
                                     required=False,
                                     initial_params={'sites': '$site'})
    site_group = DynamicModelChoiceField(queryset=SiteGroup.objects.all(),
                                         required=False,
                                         initial_params={'sites': '$site'})
    site = DynamicModelChoiceField(queryset=Site.objects.all(),
                                   required=False,
                                   query_params={
                                       'region_id': '$region',
                                       'group_id': '$site_group',
                                   })
    comments = CommentField()
    tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(),
                                           required=False)

    class Meta:
        model = Cluster
        fields = (
            'name',
            'type',
            'group',
            'tenant',
            'region',
            'site_group',
            'site',
            'comments',
            'tags',
        )
        fieldsets = (
            ('Cluster', ('name', 'type', 'group', 'region', 'site_group',
                         'site', 'tags')),
            ('Tenancy', ('tenant_group', 'tenant')),
        )
Exemplo n.º 21
0
class VLANGroupForm(BootstrapMixin, forms.ModelForm):
    site = DynamicModelChoiceField(
        queryset=Site.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/dcim/sites/"))
    slug = SlugField()

    class Meta:
        model = VLANGroup
        fields = [
            'site',
            'name',
            'slug',
        ]
Exemplo n.º 22
0
class IPAddressAssignForm(BootstrapMixin, forms.Form):
    vrf_id = DynamicModelChoiceField(
        queryset=VRF.objects.all(),
        required=False,
        label='VRF',
        empty_label='Global',
        widget=APISelect(
            api_url="/api/ipam/vrfs/"
        )
    )
    q = forms.CharField(
        required=False,
        label='Search',
    )
Exemplo n.º 23
0
class WirelessLANBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=WirelessLAN.objects.all(),
                                        widget=forms.MultipleHiddenInput)
    group = DynamicModelChoiceField(queryset=WirelessLANGroup.objects.all(),
                                    required=False)
    vlan = DynamicModelChoiceField(queryset=VLAN.objects.all(),
                                   required=False,
                                   label='VLAN')
    ssid = forms.CharField(max_length=SSID_MAX_LENGTH,
                           required=False,
                           label='SSID')
    description = forms.CharField(required=False)
    auth_type = forms.ChoiceField(
        choices=add_blank_choice(WirelessAuthTypeChoices), required=False)
    auth_cipher = forms.ChoiceField(
        choices=add_blank_choice(WirelessAuthCipherChoices), required=False)
    auth_psk = forms.CharField(required=False, label='Pre-shared key')

    class Meta:
        nullable_fields = [
            'ssid', 'group', 'vlan', 'description', 'auth_type', 'auth_cipher',
            'auth_psk'
        ]
Exemplo n.º 24
0
class VLANBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                       CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=VLAN.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    site = DynamicModelChoiceField(queryset=Site.objects.all(), required=False)
    group = DynamicModelChoiceField(queryset=VLANGroup.objects.all(),
                                    required=False)
    tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(),
                                     required=False)
    status = forms.ChoiceField(choices=add_blank_choice(VLANStatusChoices),
                               required=False,
                               widget=StaticSelect2())
    role = DynamicModelChoiceField(queryset=Role.objects.all(), required=False)
    description = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'site',
            'group',
            'tenant',
            'role',
            'description',
        ]
Exemplo n.º 25
0
class ContactBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Contact.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    group = DynamicModelChoiceField(queryset=ContactGroup.objects.all(),
                                    required=False)
    title = forms.CharField(max_length=100, required=False)
    phone = forms.CharField(max_length=50, required=False)
    email = forms.EmailField(required=False)
    address = forms.CharField(max_length=200, required=False)

    class Meta:
        nullable_fields = [
            'group', 'title', 'phone', 'email', 'address', 'comments'
        ]
Exemplo n.º 26
0
class SecretBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                         CustomFieldBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=Secret.objects.all(),
                                        widget=forms.MultipleHiddenInput())
    role = DynamicModelChoiceField(
        queryset=SecretRole.objects.all(),
        required=False,
        widget=APISelect(api_url="/api/secrets/secret-roles/"))
    name = forms.CharField(max_length=100, required=False)

    class Meta:
        nullable_fields = [
            'name',
        ]
Exemplo n.º 27
0
class ProviderNetworkBulkEditForm(BootstrapMixin, AddRemoveTagsForm,
                                  CustomFieldModelBulkEditForm):
    pk = forms.ModelMultipleChoiceField(queryset=ProviderNetwork.objects.all(),
                                        widget=forms.MultipleHiddenInput)
    provider = DynamicModelChoiceField(queryset=Provider.objects.all(),
                                       required=False)
    description = forms.CharField(max_length=100, required=False)
    comments = CommentField(widget=SmallTextarea, label='Comments')

    class Meta:
        nullable_fields = [
            'description',
            'comments',
        ]
Exemplo n.º 28
0
class IPAddressFilterForm(BootstrapMixin, TenancyFilterForm,
                          CustomFieldFilterForm):
    model = IPAddress
    field_order = [
        'q',
        'parent',
        'family',
        'mask_length',
        'vrf_id',
        'present_in_vrf_id',
        'status',
        'role',
        'assigned_to_interface',
        'tenant_group',
        'tenant',
    ]
    q = forms.CharField(required=False, label='Search')
    parent = forms.CharField(required=False,
                             widget=forms.TextInput(attrs={
                                 'placeholder': 'Prefix',
                             }),
                             label='Parent Prefix')
    family = forms.ChoiceField(
        required=False,
        choices=add_blank_choice(IPAddressFamilyChoices),
        label='Address family',
        widget=StaticSelect2())
    mask_length = forms.ChoiceField(required=False,
                                    choices=IPADDRESS_MASK_LENGTH_CHOICES,
                                    label='Mask length',
                                    widget=StaticSelect2())
    vrf_id = DynamicModelMultipleChoiceField(queryset=VRF.objects.all(),
                                             required=False,
                                             label='Assigned VRF',
                                             null_option='Global')
    present_in_vrf_id = DynamicModelChoiceField(queryset=VRF.objects.all(),
                                                required=False,
                                                label='Present in VRF')
    status = forms.MultipleChoiceField(choices=IPAddressStatusChoices,
                                       required=False,
                                       widget=StaticSelect2Multiple())
    role = forms.MultipleChoiceField(choices=IPAddressRoleChoices,
                                     required=False,
                                     widget=StaticSelect2Multiple())
    assigned_to_interface = forms.NullBooleanField(
        required=False,
        label='Assigned to an interface',
        widget=StaticSelect2(choices=BOOLEAN_WITH_BLANK_CHOICES))
    tag = TagFilterField(model)
Exemplo n.º 29
0
class CircuitForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
    provider = DynamicModelChoiceField(queryset=Provider.objects.all())
    type = DynamicModelChoiceField(queryset=CircuitType.objects.all())
    comments = CommentField()
    tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(),
                                           required=False)

    class Meta:
        model = Circuit
        fields = [
            'cid',
            'type',
            'provider',
            'status',
            'install_date',
            'commit_rate',
            'description',
            'tenant_group',
            'tenant',
            'comments',
            'tags',
        ]
        fieldsets = (
            ('Circuit', ('provider', 'cid', 'type', 'status', 'install_date',
                         'commit_rate', 'description', 'tags')),
            ('Tenancy', ('tenant_group', 'tenant')),
        )
        help_texts = {
            'cid': "Unique circuit ID",
            'commit_rate': "Committed rate",
        }
        widgets = {
            'status': StaticSelect(),
            'install_date': DatePicker(),
            'commit_rate': SelectSpeedWidget(),
        }
Exemplo n.º 30
0
class InventoryItemForm(CustomFieldModelForm):
    device = DynamicModelChoiceField(queryset=Device.objects.all())
    parent = DynamicModelChoiceField(queryset=InventoryItem.objects.all(),
                                     required=False,
                                     query_params={'device_id': '$device'})
    manufacturer = DynamicModelChoiceField(queryset=Manufacturer.objects.all(),
                                           required=False)
    tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(),
                                           required=False)

    class Meta:
        model = InventoryItem
        fields = [
            'device',
            'parent',
            'name',
            'label',
            'manufacturer',
            'part_id',
            'serial',
            'asset_tag',
            'description',
            'tags',
        ]