netbox-plugin-dns 0.22.8__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of netbox-plugin-dns might be problematic. Click here for more details.
- netbox_dns/__init__.py +4 -15
- netbox_dns/api/nested_serializers.py +4 -60
- netbox_dns/api/serializers.py +8 -314
- netbox_dns/api/serializers_/__init__.py +0 -0
- netbox_dns/api/serializers_/contact.py +37 -0
- netbox_dns/api/serializers_/nameserver.py +39 -0
- netbox_dns/api/serializers_/record.py +90 -0
- netbox_dns/api/serializers_/registrar.py +31 -0
- netbox_dns/api/serializers_/view.py +34 -0
- netbox_dns/api/serializers_/zone.py +159 -0
- netbox_dns/api/views.py +13 -13
- netbox_dns/fields/network.py +21 -22
- netbox_dns/fields/rfc2317.py +3 -3
- netbox_dns/{filters → filtersets}/contact.py +2 -1
- netbox_dns/filtersets/nameserver.py +37 -0
- netbox_dns/{filters → filtersets}/record.py +51 -6
- netbox_dns/{filters → filtersets}/registrar.py +2 -1
- netbox_dns/{filters → filtersets}/view.py +2 -2
- netbox_dns/filtersets/zone.py +205 -0
- netbox_dns/forms/contact.py +61 -33
- netbox_dns/forms/nameserver.py +21 -8
- netbox_dns/forms/record.py +65 -38
- netbox_dns/forms/registrar.py +45 -15
- netbox_dns/forms/view.py +23 -9
- netbox_dns/forms/zone.py +182 -188
- netbox_dns/graphql/__init__.py +17 -27
- netbox_dns/graphql/filters.py +49 -0
- netbox_dns/graphql/schema.py +66 -7
- netbox_dns/graphql/types.py +143 -0
- netbox_dns/management/commands/cleanup_database.py +0 -4
- netbox_dns/management/commands/cleanup_rrset_ttl.py +3 -5
- netbox_dns/management/commands/setup_coupling.py +15 -15
- netbox_dns/management/commands/update_soa.py +1 -1
- netbox_dns/migrations/0001_squashed_netbox_dns_0_15.py +0 -27
- netbox_dns/migrations/0001_squashed_netbox_dns_0_22.py +558 -0
- netbox_dns/migrations/{0013_add_nameserver_zone_record_description.py → 0002_contact_description_registrar_description.py} +4 -9
- netbox_dns/migrations/0003_default_view.py +15 -0
- netbox_dns/migrations/0004_create_and_assign_default_view.py +26 -0
- netbox_dns/migrations/0005_alter_zone_view_not_null.py +18 -0
- netbox_dns/migrations/0020_netbox_3_4.py +1 -1
- netbox_dns/models/contact.py +6 -1
- netbox_dns/models/nameserver.py +5 -1
- netbox_dns/models/record.py +32 -34
- netbox_dns/models/registrar.py +5 -1
- netbox_dns/models/view.py +54 -1
- netbox_dns/models/zone.py +68 -54
- netbox_dns/navigation.py +1 -15
- netbox_dns/signals/ipam_coupling.py +3 -9
- netbox_dns/tables/contact.py +1 -0
- netbox_dns/tables/nameserver.py +0 -2
- netbox_dns/tables/registrar.py +1 -0
- netbox_dns/tables/view.py +9 -2
- netbox_dns/template_content.py +4 -8
- netbox_dns/templates/netbox_dns/contact.html +60 -56
- netbox_dns/templates/netbox_dns/nameserver.html +27 -27
- netbox_dns/templates/netbox_dns/record.html +92 -94
- netbox_dns/templates/netbox_dns/registrar.html +38 -36
- netbox_dns/templates/netbox_dns/view.html +25 -21
- netbox_dns/templates/netbox_dns/zone/base.html +5 -3
- netbox_dns/templates/netbox_dns/zone/child.html +3 -3
- netbox_dns/templates/netbox_dns/zone/managed_record.html +1 -1
- netbox_dns/templates/netbox_dns/zone/record.html +3 -3
- netbox_dns/templates/netbox_dns/zone/registration.html +26 -27
- netbox_dns/templates/netbox_dns/zone/rfc2317_child_zone.html +1 -1
- netbox_dns/templates/netbox_dns/zone.html +148 -149
- netbox_dns/urls/__init__.py +17 -0
- netbox_dns/urls/contact.py +51 -0
- netbox_dns/urls/nameserver.py +69 -0
- netbox_dns/urls/record.py +41 -0
- netbox_dns/urls/registrar.py +63 -0
- netbox_dns/urls/view.py +39 -0
- netbox_dns/urls/zone.py +57 -0
- netbox_dns/utilities/__init__.py +1 -6
- netbox_dns/utilities/ipam_coupling.py +2 -7
- netbox_dns/validators/dns_name.py +4 -9
- netbox_dns/validators/rfc2317.py +2 -2
- netbox_dns/views/contact.py +4 -4
- netbox_dns/views/nameserver.py +5 -5
- netbox_dns/views/record.py +14 -29
- netbox_dns/views/registrar.py +4 -4
- netbox_dns/views/view.py +4 -4
- netbox_dns/views/zone.py +7 -8
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/METADATA +27 -13
- netbox_plugin_dns-1.0.0.dist-info/RECORD +112 -0
- netbox_dns/filters/nameserver.py +0 -18
- netbox_dns/filters/zone.py +0 -112
- netbox_dns/graphql/contact.py +0 -19
- netbox_dns/graphql/nameserver.py +0 -19
- netbox_dns/graphql/record.py +0 -19
- netbox_dns/graphql/registrar.py +0 -19
- netbox_dns/graphql/view.py +0 -19
- netbox_dns/graphql/zone.py +0 -19
- netbox_dns/migrations/0001_initial.py +0 -115
- netbox_dns/migrations/0002_zone_default_ttl.py +0 -18
- netbox_dns/migrations/0003_soa_managed_records.py +0 -112
- netbox_dns/migrations/0004_create_ptr_for_a_aaaa_records.py +0 -80
- netbox_dns/migrations/0005_update_ns_records.py +0 -41
- netbox_dns/migrations/0006_zone_soa_serial_auto.py +0 -29
- netbox_dns/migrations/0007_alter_zone_soa_serial_auto.py +0 -17
- netbox_dns/migrations/0008_zone_status_names.py +0 -21
- netbox_dns/migrations/0009_netbox32.py +0 -71
- netbox_dns/migrations/0010_update_soa_records.py +0 -58
- netbox_dns/migrations/0011_add_view_model.py +0 -70
- netbox_dns/migrations/0012_adjust_zone_and_record.py +0 -17
- netbox_dns/migrations/0014_add_view_description.py +0 -16
- netbox_dns/migrations/0015_add_record_status.py +0 -17
- netbox_dns/migrations/0016_cleanup_ptr_records.py +0 -38
- netbox_dns/migrations/0017_alter_record_ttl.py +0 -17
- netbox_dns/migrations/0018_zone_arpa_network.py +0 -51
- netbox_dns/migrations/0019_update_ns_ttl.py +0 -19
- netbox_dns/urls.py +0 -297
- netbox_plugin_dns-0.22.8.dist-info/RECORD +0 -117
- /netbox_dns/{filters → filtersets}/__init__.py +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/LICENSE +0 -0
- {netbox_plugin_dns-0.22.8.dist-info → netbox_plugin_dns-1.0.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import netaddr
|
|
2
|
+
|
|
3
|
+
import django_filters
|
|
4
|
+
from django.db.models import Q
|
|
5
|
+
|
|
6
|
+
from netbox.filtersets import NetBoxModelFilterSet
|
|
7
|
+
from tenancy.filtersets import TenancyFilterSet
|
|
8
|
+
from utilities.filters import MultiValueCharFilter
|
|
9
|
+
|
|
10
|
+
from netbox_dns.models import (
|
|
11
|
+
View,
|
|
12
|
+
Zone,
|
|
13
|
+
ZoneStatusChoices,
|
|
14
|
+
Registrar,
|
|
15
|
+
Contact,
|
|
16
|
+
NameServer,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ZoneFilterSet(TenancyFilterSet, NetBoxModelFilterSet):
|
|
21
|
+
status = django_filters.MultipleChoiceFilter(
|
|
22
|
+
choices=ZoneStatusChoices,
|
|
23
|
+
)
|
|
24
|
+
view_id = django_filters.ModelMultipleChoiceFilter(
|
|
25
|
+
queryset=View.objects.all(),
|
|
26
|
+
label="View ID",
|
|
27
|
+
)
|
|
28
|
+
view = django_filters.ModelMultipleChoiceFilter(
|
|
29
|
+
queryset=View.objects.all(),
|
|
30
|
+
field_name="view__name",
|
|
31
|
+
to_field_name="name",
|
|
32
|
+
label="View",
|
|
33
|
+
)
|
|
34
|
+
# DEPRECATED: Remove in 1.1
|
|
35
|
+
name_server_id = django_filters.ModelMultipleChoiceFilter(
|
|
36
|
+
queryset=NameServer.objects.all(),
|
|
37
|
+
field_name="nameservers",
|
|
38
|
+
to_field_name="id",
|
|
39
|
+
label="Nameserver IDs",
|
|
40
|
+
)
|
|
41
|
+
# DEPRECATED: Remove in 1.1
|
|
42
|
+
name_server = django_filters.ModelMultipleChoiceFilter(
|
|
43
|
+
queryset=NameServer.objects.all(),
|
|
44
|
+
field_name="nameservers__name",
|
|
45
|
+
to_field_name="name",
|
|
46
|
+
label="Nameservers",
|
|
47
|
+
)
|
|
48
|
+
nameserver_id = django_filters.ModelMultipleChoiceFilter(
|
|
49
|
+
queryset=NameServer.objects.all(),
|
|
50
|
+
field_name="nameservers",
|
|
51
|
+
to_field_name="id",
|
|
52
|
+
label="Nameservers ID",
|
|
53
|
+
)
|
|
54
|
+
nameserver = django_filters.ModelMultipleChoiceFilter(
|
|
55
|
+
queryset=NameServer.objects.all(),
|
|
56
|
+
field_name="nameservers__name",
|
|
57
|
+
to_field_name="name",
|
|
58
|
+
label="Nameserver",
|
|
59
|
+
)
|
|
60
|
+
soa_mname_id = django_filters.ModelMultipleChoiceFilter(
|
|
61
|
+
queryset=NameServer.objects.all(),
|
|
62
|
+
label="SOA MName ID",
|
|
63
|
+
)
|
|
64
|
+
soa_mname = django_filters.ModelMultipleChoiceFilter(
|
|
65
|
+
queryset=NameServer.objects.all(),
|
|
66
|
+
field_name="soa_mname__name",
|
|
67
|
+
to_field_name="name",
|
|
68
|
+
label="SOA MName",
|
|
69
|
+
)
|
|
70
|
+
arpa_network = MultiValueCharFilter(
|
|
71
|
+
method="filter_arpa_network",
|
|
72
|
+
label="ARPA Network",
|
|
73
|
+
)
|
|
74
|
+
rfc2317_prefix = MultiValueCharFilter(
|
|
75
|
+
method="filter_rfc2317_prefix",
|
|
76
|
+
label="RFC2317 Prefix",
|
|
77
|
+
)
|
|
78
|
+
rfc2317_parent_zone_id = django_filters.ModelMultipleChoiceFilter(
|
|
79
|
+
queryset=Zone.objects.all(),
|
|
80
|
+
field_name="rfc2317_parent_zone",
|
|
81
|
+
to_field_name="id",
|
|
82
|
+
label="RFC2317 Parent Zone",
|
|
83
|
+
)
|
|
84
|
+
rfc2317_parent_zone = django_filters.ModelMultipleChoiceFilter(
|
|
85
|
+
queryset=Zone.objects.all(),
|
|
86
|
+
field_name="rfc2317_parent_zone__name",
|
|
87
|
+
to_field_name="name",
|
|
88
|
+
label="RFC2317 Parent Zone",
|
|
89
|
+
)
|
|
90
|
+
registrar_id = django_filters.ModelMultipleChoiceFilter(
|
|
91
|
+
queryset=Registrar.objects.all(),
|
|
92
|
+
label="Registrar ID",
|
|
93
|
+
)
|
|
94
|
+
registrar = django_filters.ModelMultipleChoiceFilter(
|
|
95
|
+
queryset=Registrar.objects.all(),
|
|
96
|
+
field_name="registrar__name",
|
|
97
|
+
to_field_name="name",
|
|
98
|
+
label="Registrar",
|
|
99
|
+
)
|
|
100
|
+
registrant_id = django_filters.ModelMultipleChoiceFilter(
|
|
101
|
+
queryset=Contact.objects.all(),
|
|
102
|
+
label="Registrant ID",
|
|
103
|
+
)
|
|
104
|
+
registrant = django_filters.ModelMultipleChoiceFilter(
|
|
105
|
+
queryset=Contact.objects.all(),
|
|
106
|
+
field_name="registrant__contact_id",
|
|
107
|
+
to_field_name="contact_id",
|
|
108
|
+
label="Registrant",
|
|
109
|
+
)
|
|
110
|
+
admin_c_id = django_filters.ModelMultipleChoiceFilter(
|
|
111
|
+
queryset=Contact.objects.all(),
|
|
112
|
+
label="Administrative Contact ID",
|
|
113
|
+
)
|
|
114
|
+
admin_c = django_filters.ModelMultipleChoiceFilter(
|
|
115
|
+
queryset=Contact.objects.all(),
|
|
116
|
+
field_name="admin_c__contact_id",
|
|
117
|
+
to_field_name="contact_id",
|
|
118
|
+
label="Administrative Contact",
|
|
119
|
+
)
|
|
120
|
+
tech_c_id = django_filters.ModelMultipleChoiceFilter(
|
|
121
|
+
queryset=Contact.objects.all(),
|
|
122
|
+
label="Technical Contact ID",
|
|
123
|
+
)
|
|
124
|
+
tech_c = django_filters.ModelMultipleChoiceFilter(
|
|
125
|
+
queryset=Contact.objects.all(),
|
|
126
|
+
field_name="tech_c__contact_id",
|
|
127
|
+
to_field_name="contact_id",
|
|
128
|
+
label="Technical Contact",
|
|
129
|
+
)
|
|
130
|
+
billing_c_id = django_filters.ModelMultipleChoiceFilter(
|
|
131
|
+
queryset=Contact.objects.all(),
|
|
132
|
+
label="Billing Contact ID",
|
|
133
|
+
)
|
|
134
|
+
billing_c = django_filters.ModelMultipleChoiceFilter(
|
|
135
|
+
queryset=Contact.objects.all(),
|
|
136
|
+
field_name="billing_c__contact_id",
|
|
137
|
+
to_field_name="contact_id",
|
|
138
|
+
label="Billing Contact",
|
|
139
|
+
)
|
|
140
|
+
active = django_filters.BooleanFilter(
|
|
141
|
+
label="Zone is active",
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
class Meta:
|
|
145
|
+
model = Zone
|
|
146
|
+
fields = (
|
|
147
|
+
"id",
|
|
148
|
+
"name",
|
|
149
|
+
"description",
|
|
150
|
+
"default_ttl",
|
|
151
|
+
"soa_ttl",
|
|
152
|
+
"soa_rname",
|
|
153
|
+
"soa_serial",
|
|
154
|
+
"soa_refresh",
|
|
155
|
+
"soa_retry",
|
|
156
|
+
"soa_expire",
|
|
157
|
+
"soa_minimum",
|
|
158
|
+
"soa_serial_auto",
|
|
159
|
+
"rfc2317_parent_managed",
|
|
160
|
+
"registry_domain_id",
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def filter_arpa_network(self, queryset, name, value):
|
|
164
|
+
if not value:
|
|
165
|
+
return queryset
|
|
166
|
+
try:
|
|
167
|
+
arpa_networks = [
|
|
168
|
+
str(netaddr.IPNetwork(item)) for item in value if item.strip()
|
|
169
|
+
]
|
|
170
|
+
if not arpa_networks:
|
|
171
|
+
return queryset
|
|
172
|
+
return queryset.filter(arpa_network__in=arpa_networks)
|
|
173
|
+
|
|
174
|
+
except (netaddr.AddrFormatError, ValueError):
|
|
175
|
+
return queryset.none()
|
|
176
|
+
|
|
177
|
+
def filter_rfc2317_prefix(self, queryset, name, value):
|
|
178
|
+
if not value:
|
|
179
|
+
return queryset
|
|
180
|
+
try:
|
|
181
|
+
rfc2317_prefixes = [
|
|
182
|
+
str(netaddr.IPNetwork(item)) for item in value if item.strip()
|
|
183
|
+
]
|
|
184
|
+
if not rfc2317_prefixes:
|
|
185
|
+
return queryset
|
|
186
|
+
return queryset.filter(rfc2317_prefix__in=rfc2317_prefixes)
|
|
187
|
+
|
|
188
|
+
except (netaddr.AddrFormatError, ValueError):
|
|
189
|
+
return queryset.none()
|
|
190
|
+
|
|
191
|
+
def search(self, queryset, name, value):
|
|
192
|
+
if not value.strip():
|
|
193
|
+
return queryset
|
|
194
|
+
qs_filter = (
|
|
195
|
+
Q(name__icontains=value)
|
|
196
|
+
| Q(status__icontains=value)
|
|
197
|
+
| Q(view__name__icontains=value)
|
|
198
|
+
| Q(registrar__name__icontains=value)
|
|
199
|
+
| Q(registry_domain_id__icontains=value)
|
|
200
|
+
| Q(registrant__name__icontains=value)
|
|
201
|
+
| Q(admin_c__name__icontains=value)
|
|
202
|
+
| Q(tech_c__name__icontains=value)
|
|
203
|
+
| Q(billing_c__name__icontains=value)
|
|
204
|
+
)
|
|
205
|
+
return queryset.filter(qs_filter)
|
netbox_dns/forms/contact.py
CHANGED
|
@@ -7,15 +7,38 @@ from netbox.forms import (
|
|
|
7
7
|
NetBoxModelForm,
|
|
8
8
|
)
|
|
9
9
|
from utilities.forms.fields import TagFilterField
|
|
10
|
+
from utilities.forms.rendering import FieldSet
|
|
10
11
|
|
|
11
12
|
from netbox_dns.models import Contact
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class ContactForm(NetBoxModelForm):
|
|
16
|
+
fieldsets = (
|
|
17
|
+
FieldSet(
|
|
18
|
+
"name",
|
|
19
|
+
"description",
|
|
20
|
+
"contact_id",
|
|
21
|
+
"organization",
|
|
22
|
+
"street",
|
|
23
|
+
"city",
|
|
24
|
+
"state_province",
|
|
25
|
+
"postal_code",
|
|
26
|
+
"country",
|
|
27
|
+
"phone",
|
|
28
|
+
"phone_ext",
|
|
29
|
+
"fax",
|
|
30
|
+
"fax_ext",
|
|
31
|
+
"email",
|
|
32
|
+
name="Contact",
|
|
33
|
+
),
|
|
34
|
+
FieldSet("tags", name="Tags"),
|
|
35
|
+
)
|
|
36
|
+
|
|
15
37
|
class Meta:
|
|
16
38
|
model = Contact
|
|
17
39
|
fields = (
|
|
18
40
|
"name",
|
|
41
|
+
"description",
|
|
19
42
|
"contact_id",
|
|
20
43
|
"organization",
|
|
21
44
|
"street",
|
|
@@ -34,25 +57,28 @@ class ContactForm(NetBoxModelForm):
|
|
|
34
57
|
|
|
35
58
|
class ContactFilterForm(NetBoxModelFilterSetForm):
|
|
36
59
|
model = Contact
|
|
60
|
+
|
|
37
61
|
fieldsets = (
|
|
38
|
-
(
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
),
|
|
62
|
+
FieldSet("q", "filter_id", "tag"),
|
|
63
|
+
FieldSet("name", "contact_id", "description", name="Attributes"),
|
|
64
|
+
FieldSet(
|
|
65
|
+
"organization",
|
|
66
|
+
"street",
|
|
67
|
+
"city",
|
|
68
|
+
"state_province",
|
|
69
|
+
"postal_code",
|
|
70
|
+
"country",
|
|
71
|
+
name="Address",
|
|
49
72
|
),
|
|
50
|
-
("
|
|
73
|
+
FieldSet("phone", "phone_ext", "fax", "fax_ext", "email", name="Communication"),
|
|
51
74
|
)
|
|
52
75
|
|
|
53
76
|
name = forms.CharField(
|
|
54
77
|
required=False,
|
|
55
78
|
)
|
|
79
|
+
description = forms.CharField(
|
|
80
|
+
required=False,
|
|
81
|
+
)
|
|
56
82
|
contact_id = forms.CharField(
|
|
57
83
|
required=False,
|
|
58
84
|
label="Contact ID",
|
|
@@ -94,7 +120,7 @@ class ContactFilterForm(NetBoxModelFilterSetForm):
|
|
|
94
120
|
email = forms.CharField(
|
|
95
121
|
required=False,
|
|
96
122
|
)
|
|
97
|
-
|
|
123
|
+
tag = TagFilterField(Contact)
|
|
98
124
|
|
|
99
125
|
|
|
100
126
|
class ContactImportForm(NetBoxModelImportForm):
|
|
@@ -102,6 +128,7 @@ class ContactImportForm(NetBoxModelImportForm):
|
|
|
102
128
|
model = Contact
|
|
103
129
|
fields = (
|
|
104
130
|
"name",
|
|
131
|
+
"description",
|
|
105
132
|
"contact_id",
|
|
106
133
|
"organization",
|
|
107
134
|
"street",
|
|
@@ -125,6 +152,10 @@ class ContactBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
125
152
|
required=False,
|
|
126
153
|
label="Name",
|
|
127
154
|
)
|
|
155
|
+
description = forms.CharField(
|
|
156
|
+
required=False,
|
|
157
|
+
label="Description",
|
|
158
|
+
)
|
|
128
159
|
organization = forms.CharField(
|
|
129
160
|
required=False,
|
|
130
161
|
label="Organization",
|
|
@@ -171,32 +202,29 @@ class ContactBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
171
202
|
)
|
|
172
203
|
|
|
173
204
|
fieldsets = (
|
|
174
|
-
(
|
|
175
|
-
(
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"country",
|
|
184
|
-
),
|
|
205
|
+
FieldSet("name", "description", name="Attributes"),
|
|
206
|
+
FieldSet(
|
|
207
|
+
"organization",
|
|
208
|
+
"street",
|
|
209
|
+
"city",
|
|
210
|
+
"state_province",
|
|
211
|
+
"postal_code",
|
|
212
|
+
"country",
|
|
213
|
+
name="Address",
|
|
185
214
|
),
|
|
186
|
-
(
|
|
187
|
-
"
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
"email",
|
|
194
|
-
),
|
|
215
|
+
FieldSet(
|
|
216
|
+
"phone",
|
|
217
|
+
"phone_ext",
|
|
218
|
+
"fax",
|
|
219
|
+
"fax_ext",
|
|
220
|
+
"email",
|
|
221
|
+
name="Communication",
|
|
195
222
|
),
|
|
196
223
|
)
|
|
197
224
|
|
|
198
225
|
nullable_fields = (
|
|
199
226
|
"name",
|
|
227
|
+
"description",
|
|
200
228
|
"organization",
|
|
201
229
|
"street",
|
|
202
230
|
"city",
|
netbox_dns/forms/nameserver.py
CHANGED
|
@@ -12,6 +12,7 @@ from utilities.forms.fields import (
|
|
|
12
12
|
CSVModelChoiceField,
|
|
13
13
|
DynamicModelChoiceField,
|
|
14
14
|
)
|
|
15
|
+
from utilities.forms.rendering import FieldSet
|
|
15
16
|
from tenancy.models import Tenant
|
|
16
17
|
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
17
18
|
|
|
@@ -28,8 +29,9 @@ class NameServerForm(TenancyForm, NetBoxModelForm):
|
|
|
28
29
|
self.initial["name"] = name_to_unicode(initial_name)
|
|
29
30
|
|
|
30
31
|
fieldsets = (
|
|
31
|
-
("
|
|
32
|
-
("
|
|
32
|
+
FieldSet("name", "description", name="Nameserver"),
|
|
33
|
+
FieldSet("tenant_group", "tenant", name="Tenancy"),
|
|
34
|
+
FieldSet("tags", name="Tags"),
|
|
33
35
|
)
|
|
34
36
|
|
|
35
37
|
class Meta:
|
|
@@ -42,14 +44,16 @@ class NameServerFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
42
44
|
|
|
43
45
|
name = forms.CharField(
|
|
44
46
|
required=False,
|
|
45
|
-
|
|
47
|
+
)
|
|
48
|
+
description = forms.CharField(
|
|
49
|
+
required=False,
|
|
46
50
|
)
|
|
47
51
|
tag = TagFilterField(NameServer)
|
|
48
52
|
|
|
49
53
|
fieldsets = (
|
|
50
|
-
(
|
|
51
|
-
("
|
|
52
|
-
("
|
|
54
|
+
FieldSet("q", "filter_id", "tag"),
|
|
55
|
+
FieldSet("name", "description", name="Attributes"),
|
|
56
|
+
FieldSet("tenant_group_id", "tenant_id", name="Tenancy"),
|
|
53
57
|
)
|
|
54
58
|
|
|
55
59
|
|
|
@@ -78,5 +82,14 @@ class NameServerBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
78
82
|
description = forms.CharField(max_length=200, required=False)
|
|
79
83
|
tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False)
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
fieldsets = (
|
|
86
|
+
FieldSet(
|
|
87
|
+
"name",
|
|
88
|
+
"description",
|
|
89
|
+
"tenant",
|
|
90
|
+
"tags",
|
|
91
|
+
name="Attributes",
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
nullable_fields = ("description", "tenant")
|
netbox_dns/forms/record.py
CHANGED
|
@@ -16,6 +16,7 @@ from utilities.forms.fields import (
|
|
|
16
16
|
)
|
|
17
17
|
from utilities.forms.widgets import BulkEditNullBooleanSelect, APISelect
|
|
18
18
|
from utilities.forms import add_blank_choice
|
|
19
|
+
from utilities.forms.rendering import FieldSet
|
|
19
20
|
from tenancy.models import Tenant
|
|
20
21
|
from tenancy.forms import TenancyForm, TenancyFilterForm
|
|
21
22
|
|
|
@@ -27,10 +28,30 @@ class RecordForm(TenancyForm, NetBoxModelForm):
|
|
|
27
28
|
def __init__(self, *args, **kwargs):
|
|
28
29
|
super().__init__(*args, **kwargs)
|
|
29
30
|
|
|
31
|
+
initial_zone_id = self.initial.get("zone")
|
|
32
|
+
if initial_zone_id is not None:
|
|
33
|
+
self.initial["view"] = Zone.objects.get(pk=initial_zone_id).view
|
|
34
|
+
else:
|
|
35
|
+
self.initial["view"] = View.get_default_view()
|
|
36
|
+
|
|
30
37
|
initial_name = self.initial.get("name")
|
|
31
38
|
if initial_name:
|
|
32
39
|
self.initial["name"] = name_to_unicode(initial_name)
|
|
33
40
|
|
|
41
|
+
view = DynamicModelChoiceField(
|
|
42
|
+
queryset=View.objects.all(),
|
|
43
|
+
required=False,
|
|
44
|
+
label="View",
|
|
45
|
+
)
|
|
46
|
+
zone = DynamicModelChoiceField(
|
|
47
|
+
queryset=Zone.objects.all(),
|
|
48
|
+
required=True,
|
|
49
|
+
query_params={
|
|
50
|
+
"view_id": "$view",
|
|
51
|
+
},
|
|
52
|
+
label="Zone",
|
|
53
|
+
)
|
|
54
|
+
|
|
34
55
|
disable_ptr = forms.BooleanField(
|
|
35
56
|
label="Disable PTR",
|
|
36
57
|
required=False,
|
|
@@ -41,21 +62,20 @@ class RecordForm(TenancyForm, NetBoxModelForm):
|
|
|
41
62
|
)
|
|
42
63
|
|
|
43
64
|
fieldsets = (
|
|
44
|
-
(
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"tags",
|
|
56
|
-
),
|
|
65
|
+
FieldSet(
|
|
66
|
+
"name",
|
|
67
|
+
"view",
|
|
68
|
+
"zone",
|
|
69
|
+
"type",
|
|
70
|
+
"value",
|
|
71
|
+
"status",
|
|
72
|
+
"ttl",
|
|
73
|
+
"disable_ptr",
|
|
74
|
+
"description",
|
|
75
|
+
name="Record",
|
|
57
76
|
),
|
|
58
|
-
("
|
|
77
|
+
FieldSet("tenant_group", "tenant", name="Tenancy"),
|
|
78
|
+
FieldSet("tags", name="Tags"),
|
|
59
79
|
)
|
|
60
80
|
|
|
61
81
|
class Meta:
|
|
@@ -78,12 +98,19 @@ class RecordForm(TenancyForm, NetBoxModelForm):
|
|
|
78
98
|
class RecordFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
79
99
|
model = Record
|
|
80
100
|
fieldsets = (
|
|
81
|
-
(
|
|
82
|
-
(
|
|
83
|
-
"
|
|
84
|
-
|
|
101
|
+
FieldSet("q", "filter_id", "tag"),
|
|
102
|
+
FieldSet(
|
|
103
|
+
"zone_id",
|
|
104
|
+
"name",
|
|
105
|
+
"fqdn",
|
|
106
|
+
"type",
|
|
107
|
+
"value",
|
|
108
|
+
"disable_ptr",
|
|
109
|
+
"status",
|
|
110
|
+
"description",
|
|
111
|
+
name="Attributes",
|
|
85
112
|
),
|
|
86
|
-
("
|
|
113
|
+
FieldSet("tenant_group_id", "tenant_id", name="Tenancy"),
|
|
87
114
|
)
|
|
88
115
|
|
|
89
116
|
type = forms.MultipleChoiceField(
|
|
@@ -92,7 +119,6 @@ class RecordFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
92
119
|
)
|
|
93
120
|
name = forms.CharField(
|
|
94
121
|
required=False,
|
|
95
|
-
label="Name",
|
|
96
122
|
)
|
|
97
123
|
fqdn = forms.CharField(
|
|
98
124
|
required=False,
|
|
@@ -100,7 +126,10 @@ class RecordFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
100
126
|
)
|
|
101
127
|
value = forms.CharField(
|
|
102
128
|
required=False,
|
|
103
|
-
|
|
129
|
+
)
|
|
130
|
+
disable_ptr = forms.NullBooleanField(
|
|
131
|
+
required=False,
|
|
132
|
+
label="Disable PTR",
|
|
104
133
|
)
|
|
105
134
|
status = forms.MultipleChoiceField(
|
|
106
135
|
choices=RecordStatusChoices,
|
|
@@ -111,10 +140,8 @@ class RecordFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
|
|
111
140
|
required=False,
|
|
112
141
|
label="Zone",
|
|
113
142
|
)
|
|
114
|
-
|
|
115
|
-
queryset=View.objects.all(),
|
|
143
|
+
description = forms.CharField(
|
|
116
144
|
required=False,
|
|
117
|
-
label="View",
|
|
118
145
|
)
|
|
119
146
|
tag = TagFilterField(Record)
|
|
120
147
|
|
|
@@ -130,10 +157,12 @@ class RecordImportForm(NetBoxModelImportForm):
|
|
|
130
157
|
except forms.ValidationError:
|
|
131
158
|
pass
|
|
132
159
|
|
|
133
|
-
if view:
|
|
160
|
+
if view is not None:
|
|
134
161
|
self.fields["zone"].queryset = Zone.objects.filter(view=view)
|
|
135
162
|
else:
|
|
136
|
-
self.fields["zone"].queryset = Zone.objects.filter(
|
|
163
|
+
self.fields["zone"].queryset = Zone.objects.filter(
|
|
164
|
+
view=View.get_default_view()
|
|
165
|
+
)
|
|
137
166
|
|
|
138
167
|
zone = CSVModelChoiceField(
|
|
139
168
|
queryset=Zone.objects.all(),
|
|
@@ -231,18 +260,16 @@ class RecordBulkEditForm(NetBoxModelBulkEditForm):
|
|
|
231
260
|
tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False)
|
|
232
261
|
|
|
233
262
|
fieldsets = (
|
|
234
|
-
(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
"description",
|
|
244
|
-
"tenant",
|
|
245
|
-
),
|
|
263
|
+
FieldSet(
|
|
264
|
+
"zone",
|
|
265
|
+
"type",
|
|
266
|
+
"value",
|
|
267
|
+
"status",
|
|
268
|
+
"ttl",
|
|
269
|
+
"disable_ptr",
|
|
270
|
+
"description",
|
|
271
|
+
name="Attributes",
|
|
246
272
|
),
|
|
273
|
+
FieldSet("tenant_group", "tenant", name="Tenancy"),
|
|
247
274
|
)
|
|
248
275
|
nullable_fields = ("description", "ttl", "tenant")
|