netbox-plugin-dns 1.1.2__py3-none-any.whl → 1.1.4__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.

Files changed (84) hide show
  1. netbox_dns/__init__.py +14 -6
  2. netbox_dns/api/nested_serializers.py +3 -2
  3. netbox_dns/api/serializers_/nameserver.py +2 -1
  4. netbox_dns/api/serializers_/record.py +5 -4
  5. netbox_dns/api/serializers_/record_template.py +2 -1
  6. netbox_dns/api/serializers_/view.py +2 -1
  7. netbox_dns/api/serializers_/zone.py +12 -11
  8. netbox_dns/api/serializers_/zone_template.py +8 -7
  9. netbox_dns/api/views.py +9 -4
  10. netbox_dns/choices/record.py +4 -2
  11. netbox_dns/choices/zone.py +8 -4
  12. netbox_dns/fields/address.py +5 -22
  13. netbox_dns/fields/network.py +2 -1
  14. netbox_dns/fields/rfc2317.py +7 -3
  15. netbox_dns/filtersets/nameserver.py +3 -2
  16. netbox_dns/filtersets/record.py +14 -9
  17. netbox_dns/filtersets/record_template.py +3 -2
  18. netbox_dns/filtersets/view.py +3 -2
  19. netbox_dns/filtersets/zone.py +24 -22
  20. netbox_dns/filtersets/zone_template.py +15 -14
  21. netbox_dns/forms/nameserver.py +41 -17
  22. netbox_dns/forms/record.py +61 -32
  23. netbox_dns/forms/record_template.py +49 -28
  24. netbox_dns/forms/registrar.py +21 -17
  25. netbox_dns/forms/registration_contact.py +37 -25
  26. netbox_dns/forms/view.py +49 -27
  27. netbox_dns/forms/zone.py +173 -120
  28. netbox_dns/forms/zone_template.py +53 -43
  29. netbox_dns/locale/de/LC_MESSAGES/django.mo +0 -0
  30. netbox_dns/locale/en/LC_MESSAGES/django.mo +0 -0
  31. netbox_dns/management/commands/rebuild_dnssync.py +14 -1
  32. netbox_dns/models/nameserver.py +6 -2
  33. netbox_dns/models/record.py +74 -40
  34. netbox_dns/models/record_template.py +17 -9
  35. netbox_dns/models/registrar.py +11 -7
  36. netbox_dns/models/registration_contact.py +23 -11
  37. netbox_dns/models/view.py +15 -6
  38. netbox_dns/models/zone.py +83 -50
  39. netbox_dns/models/zone_template.py +12 -10
  40. netbox_dns/navigation.py +30 -28
  41. netbox_dns/signals/ipam_dnssync.py +21 -14
  42. netbox_dns/tables/ipam_dnssync.py +2 -1
  43. netbox_dns/tables/nameserver.py +2 -0
  44. netbox_dns/tables/record.py +21 -11
  45. netbox_dns/tables/record_template.py +12 -5
  46. netbox_dns/tables/registrar.py +2 -0
  47. netbox_dns/tables/registration_contact.py +2 -0
  48. netbox_dns/tables/view.py +3 -1
  49. netbox_dns/tables/zone.py +15 -2
  50. netbox_dns/tables/zone_template.py +7 -0
  51. netbox_dns/templates/netbox_dns/nameserver.html +6 -5
  52. netbox_dns/templates/netbox_dns/record/managed.html +2 -1
  53. netbox_dns/templates/netbox_dns/record/related.html +26 -14
  54. netbox_dns/templates/netbox_dns/record.html +39 -20
  55. netbox_dns/templates/netbox_dns/recordtemplate.html +27 -15
  56. netbox_dns/templates/netbox_dns/registrar.html +11 -10
  57. netbox_dns/templates/netbox_dns/registrationcontact.html +16 -15
  58. netbox_dns/templates/netbox_dns/view/button.html +2 -1
  59. netbox_dns/templates/netbox_dns/view/prefix.html +7 -4
  60. netbox_dns/templates/netbox_dns/view/related.html +26 -10
  61. netbox_dns/templates/netbox_dns/view.html +11 -14
  62. netbox_dns/templates/netbox_dns/zone/base.html +2 -1
  63. netbox_dns/templates/netbox_dns/zone/child.html +3 -2
  64. netbox_dns/templates/netbox_dns/zone/record.html +3 -2
  65. netbox_dns/templates/netbox_dns/zone/registration.html +8 -7
  66. netbox_dns/templates/netbox_dns/zone.html +28 -30
  67. netbox_dns/templates/netbox_dns/zonetemplate.html +27 -17
  68. netbox_dns/utilities/ipam_dnssync.py +15 -4
  69. netbox_dns/validators/dns_name.py +11 -4
  70. netbox_dns/validators/dns_value.py +55 -9
  71. netbox_dns/validators/rfc2317.py +6 -3
  72. netbox_dns/views/nameserver.py +4 -2
  73. netbox_dns/views/record_template.py +4 -3
  74. netbox_dns/views/registrar.py +3 -1
  75. netbox_dns/views/registration_contact.py +2 -1
  76. netbox_dns/views/view.py +2 -1
  77. netbox_dns/views/zone.py +6 -4
  78. netbox_dns/views/zone_template.py +8 -7
  79. {netbox_plugin_dns-1.1.2.dist-info → netbox_plugin_dns-1.1.4.dist-info}/METADATA +2 -2
  80. netbox_plugin_dns-1.1.4.dist-info/RECORD +150 -0
  81. netbox_plugin_dns-1.1.2.dist-info/RECORD +0 -148
  82. {netbox_plugin_dns-1.1.2.dist-info → netbox_plugin_dns-1.1.4.dist-info}/LICENSE +0 -0
  83. {netbox_plugin_dns-1.1.2.dist-info → netbox_plugin_dns-1.1.4.dist-info}/WHEEL +0 -0
  84. {netbox_plugin_dns-1.1.2.dist-info → netbox_plugin_dns-1.1.4.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,5 @@
1
1
  from django import forms
2
+ from django.utils.translation import gettext_lazy as _
2
3
 
3
4
  from netbox.forms import (
4
5
  NetBoxModelBulkEditForm,
@@ -16,7 +17,7 @@ from utilities.forms.fields import (
16
17
  from utilities.forms.widgets import BulkEditNullBooleanSelect
17
18
  from utilities.forms import add_blank_choice
18
19
  from utilities.forms.rendering import FieldSet
19
- from tenancy.models import Tenant
20
+ from tenancy.models import Tenant, TenantGroup
20
21
  from tenancy.forms import TenancyForm, TenancyFilterForm
21
22
 
22
23
  from netbox_dns.models import RecordTemplate, ZoneTemplate
@@ -41,12 +42,12 @@ class RecordTemplateForm(TenancyForm, NetBoxModelForm):
41
42
  self.initial["record_name"] = name_to_unicode(initial_record_name)
42
43
 
43
44
  disable_ptr = forms.BooleanField(
44
- label="Disable PTR",
45
45
  required=False,
46
+ label=_("Disable PTR"),
46
47
  )
47
48
  ttl = forms.IntegerField(
48
49
  required=False,
49
- label="TTL",
50
+ label=_("TTL"),
50
51
  )
51
52
 
52
53
  fieldsets = (
@@ -59,10 +60,10 @@ class RecordTemplateForm(TenancyForm, NetBoxModelForm):
59
60
  "ttl",
60
61
  "disable_ptr",
61
62
  "description",
62
- name="Record Template",
63
+ name=_("Record Template"),
63
64
  ),
64
- FieldSet("tenant_group", "tenant", name="Tenancy"),
65
- FieldSet("tags", name="Tags"),
65
+ FieldSet("tenant_group", "tenant", name=_("Tenancy")),
66
+ FieldSet("tags", name=_("Tags")),
66
67
  )
67
68
 
68
69
  class Meta:
@@ -77,8 +78,9 @@ class RecordTemplateForm(TenancyForm, NetBoxModelForm):
77
78
  "ttl",
78
79
  "disable_ptr",
79
80
  "description",
80
- "tags",
81
+ "tenant_group",
81
82
  "tenant",
83
+ "tags",
82
84
  )
83
85
 
84
86
 
@@ -93,44 +95,47 @@ class RecordTemplateFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
93
95
  "value",
94
96
  "status",
95
97
  "disable_ptr",
96
- "status",
97
98
  "description",
98
- name="Attributes",
99
+ name=_("Attributes"),
99
100
  ),
100
- FieldSet("zone_template_id", name="Zone Templates"),
101
- FieldSet("tenant_group_id", "tenant_id", name="Tenancy"),
101
+ FieldSet("zone_template_id", name=_("Zone Templates")),
102
+ FieldSet("tenant_group_id", "tenant_id", name=_("Tenancy")),
102
103
  )
103
104
 
104
105
  type = forms.MultipleChoiceField(
105
106
  choices=RecordTypeChoices,
106
107
  required=False,
108
+ label=_("Type"),
107
109
  )
108
110
  name = forms.CharField(
109
111
  required=False,
110
- label="Template name",
112
+ label=_("Template Name"),
111
113
  )
112
114
  record_name = forms.CharField(
113
115
  required=False,
114
- label="Name",
116
+ label=_("Name"),
115
117
  )
116
118
  value = forms.CharField(
117
119
  required=False,
120
+ label=_("Value"),
118
121
  )
119
122
  status = forms.MultipleChoiceField(
120
123
  choices=RecordStatusChoices,
121
124
  required=False,
125
+ label=_("Status"),
122
126
  )
123
127
  disable_ptr = forms.NullBooleanField(
124
128
  required=False,
125
- label="Disable PTR",
129
+ label=_("Disable PTR"),
126
130
  )
127
131
  description = forms.CharField(
128
132
  required=False,
133
+ label=_("Description"),
129
134
  )
130
135
  zone_template_id = DynamicModelMultipleChoiceField(
131
136
  queryset=ZoneTemplate.objects.all(),
132
137
  required=False,
133
- label="Zone templates",
138
+ label=_("Zone Templates"),
134
139
  )
135
140
  tag = TagFilterField(RecordTemplate)
136
141
 
@@ -139,27 +144,26 @@ class RecordTemplateImportForm(NetBoxModelImportForm):
139
144
  type = CSVChoiceField(
140
145
  choices=RecordTypeChoices,
141
146
  required=True,
142
- help_text="Record Type",
147
+ label=_("Type"),
143
148
  )
144
149
  status = CSVChoiceField(
145
150
  choices=RecordStatusChoices,
146
151
  required=False,
147
- help_text="Record status",
152
+ label=_("Status"),
148
153
  )
149
154
  ttl = forms.IntegerField(
150
155
  required=False,
151
- help_text="TTL",
156
+ label=_("TTL"),
152
157
  )
153
158
  disable_ptr = forms.BooleanField(
154
159
  required=False,
155
- label="Disable PTR",
156
- help_text="Disable generation of a PTR record",
160
+ label=_("Disable PTR"),
157
161
  )
158
162
  tenant = CSVModelChoiceField(
159
163
  queryset=Tenant.objects.all(),
160
164
  to_field_name="name",
161
165
  required=False,
162
- help_text="Assigned tenant",
166
+ label=_("Tenant"),
163
167
  )
164
168
 
165
169
  class Meta:
@@ -185,24 +189,41 @@ class RecordTemplateBulkEditForm(NetBoxModelBulkEditForm):
185
189
  type = forms.ChoiceField(
186
190
  choices=add_blank_choice(RecordTypeChoices),
187
191
  required=False,
192
+ label=_("Type"),
188
193
  )
189
194
  value = forms.CharField(
190
195
  required=False,
191
- label="Value",
196
+ label=_("Value"),
192
197
  )
193
198
  status = forms.ChoiceField(
194
199
  choices=add_blank_choice(RecordStatusChoices),
195
200
  required=False,
201
+ label=_("Status"),
196
202
  )
197
203
  ttl = forms.IntegerField(
198
204
  required=False,
199
- label="TTL",
205
+ label=_("TTL"),
200
206
  )
201
207
  disable_ptr = forms.NullBooleanField(
202
- required=False, widget=BulkEditNullBooleanSelect(), label="Disable PTR"
208
+ required=False,
209
+ widget=BulkEditNullBooleanSelect(),
210
+ label=_("Disable PTR"),
211
+ )
212
+ description = forms.CharField(
213
+ max_length=200,
214
+ required=False,
215
+ label=_("Description"),
216
+ )
217
+ tenant_group = DynamicModelChoiceField(
218
+ queryset=TenantGroup.objects.all(),
219
+ required=False,
220
+ label=_("Tenant Group"),
221
+ )
222
+ tenant = DynamicModelChoiceField(
223
+ queryset=Tenant.objects.all(),
224
+ required=False,
225
+ label=_("Tenant"),
203
226
  )
204
- description = forms.CharField(max_length=200, required=False)
205
- tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False)
206
227
 
207
228
  fieldsets = (
208
229
  FieldSet(
@@ -213,8 +234,8 @@ class RecordTemplateBulkEditForm(NetBoxModelBulkEditForm):
213
234
  "ttl",
214
235
  "disable_ptr",
215
236
  "description",
216
- name="Attributes",
237
+ name=_("Attributes"),
217
238
  ),
218
- FieldSet("tenant_group", "tenant", name="Tenancy"),
239
+ FieldSet("tenant_group", "tenant", name=_("Tenancy")),
219
240
  )
220
241
  nullable_fields = ("description", "ttl", "tenant")
@@ -1,4 +1,5 @@
1
1
  from django import forms
2
+ from django.utils.translation import gettext_lazy as _
2
3
 
3
4
  from netbox.forms import (
4
5
  NetBoxModelBulkEditForm,
@@ -33,9 +34,9 @@ class RegistrarForm(NetBoxModelForm):
33
34
  "whois_server",
34
35
  "abuse_email",
35
36
  "abuse_phone",
36
- name="Registrar",
37
+ name=_("Registrar"),
37
38
  ),
38
- FieldSet("tags", name="Tags"),
39
+ FieldSet("tags", name=_("Tags")),
39
40
  )
40
41
  fields = (
41
42
  "name",
@@ -54,45 +55,48 @@ class RegistrarFilterForm(NetBoxModelFilterSetForm):
54
55
  model = Registrar
55
56
  fieldsets = (
56
57
  FieldSet("q", "filter_id", "tag"),
57
- FieldSet("name", "iana_id", "description", name="Attributes"),
58
+ FieldSet("name", "iana_id", "description", name=_("Attributes")),
58
59
  FieldSet(
59
60
  "address",
60
61
  "referral_url",
61
62
  "whois_server",
62
63
  "abuse_email",
63
64
  "abuse_phone",
64
- name="Contact",
65
+ name=_("Contact"),
65
66
  ),
66
67
  )
67
68
 
68
69
  name = forms.CharField(
69
70
  required=False,
71
+ label=_("Name"),
70
72
  )
71
73
  address = forms.CharField(
72
74
  required=False,
75
+ label=_("Address"),
73
76
  )
74
77
  description = forms.CharField(
75
78
  required=False,
79
+ label=_("Description"),
76
80
  )
77
81
  iana_id = forms.IntegerField(
78
82
  required=False,
79
- label="IANA ID",
83
+ label=_("IANA ID"),
80
84
  )
81
85
  referral_url = forms.CharField(
82
86
  required=False,
83
- label="Referral URL",
87
+ label=_("Referral URL"),
84
88
  )
85
89
  whois_server = forms.CharField(
86
90
  required=False,
87
- label="WHOIS Server",
91
+ label=_("WHOIS Server"),
88
92
  )
89
93
  abuse_email = forms.CharField(
90
94
  required=False,
91
- label="Abuse Email",
95
+ label=_("Abuse Email"),
92
96
  )
93
97
  abuse_phone = forms.CharField(
94
98
  required=False,
95
- label="Abuse Phone",
99
+ label=_("Abuse Phone"),
96
100
  )
97
101
  tag = TagFilterField(Registrar)
98
102
 
@@ -118,31 +122,31 @@ class RegistrarBulkEditForm(NetBoxModelBulkEditForm):
118
122
 
119
123
  iana_id = forms.IntegerField(
120
124
  required=False,
121
- label="IANA ID",
125
+ label=_("IANA ID"),
122
126
  )
123
127
  description = forms.CharField(
124
128
  required=False,
125
- label="Description",
129
+ label=_("Description"),
126
130
  )
127
131
  address = forms.CharField(
128
132
  required=False,
129
- label="Address",
133
+ label=_("Address"),
130
134
  )
131
135
  referral_url = forms.CharField(
132
136
  required=False,
133
- label="Referral URL",
137
+ label=_("Referral URL"),
134
138
  )
135
139
  whois_server = forms.CharField(
136
140
  required=False,
137
- label="WHOIS Server",
141
+ label=_("WHOIS Server"),
138
142
  )
139
143
  abuse_email = forms.CharField(
140
144
  required=False,
141
- label="Abuse Email",
145
+ label=_("Abuse Email"),
142
146
  )
143
147
  abuse_phone = forms.CharField(
144
148
  required=False,
145
- label="Abuse Phone",
149
+ label=_("Abuse Phone"),
146
150
  )
147
151
 
148
152
  fieldsets = (
@@ -154,7 +158,7 @@ class RegistrarBulkEditForm(NetBoxModelBulkEditForm):
154
158
  "whois_server",
155
159
  "abuse_email",
156
160
  "abuse_phone",
157
- name="Attributes",
161
+ name=_("Attributes"),
158
162
  ),
159
163
  )
160
164
 
@@ -1,4 +1,5 @@
1
1
  from django import forms
2
+ from django.utils.translation import gettext_lazy as _
2
3
 
3
4
  from netbox.forms import (
4
5
  NetBoxModelBulkEditForm,
@@ -37,7 +38,7 @@ class RegistrationContactForm(NetBoxModelForm):
37
38
  "fax",
38
39
  "fax_ext",
39
40
  "email",
40
- name="RegistrationContact",
41
+ name=_("Contact"),
41
42
  ),
42
43
  FieldSet("tags", name="Tags"),
43
44
  )
@@ -68,7 +69,7 @@ class RegistrationContactFilterForm(NetBoxModelFilterSetForm):
68
69
 
69
70
  fieldsets = (
70
71
  FieldSet("q", "filter_id", "tag"),
71
- FieldSet("name", "contact_id", "description", name="Attributes"),
72
+ FieldSet("name", "contact_id", "description", name=_("Attributes")),
72
73
  FieldSet(
73
74
  "organization",
74
75
  "street",
@@ -76,57 +77,68 @@ class RegistrationContactFilterForm(NetBoxModelFilterSetForm):
76
77
  "state_province",
77
78
  "postal_code",
78
79
  "country",
79
- name="Address",
80
+ name=_("Address"),
81
+ ),
82
+ FieldSet(
83
+ "phone", "phone_ext", "fax", "fax_ext", "email", name=_("Communication")
80
84
  ),
81
- FieldSet("phone", "phone_ext", "fax", "fax_ext", "email", name="Communication"),
82
85
  )
83
86
 
84
87
  name = forms.CharField(
85
88
  required=False,
89
+ label=_("Name"),
86
90
  )
87
91
  description = forms.CharField(
88
92
  required=False,
93
+ label=_("Description"),
89
94
  )
90
95
  contact_id = forms.CharField(
91
96
  required=False,
92
- label="RegistrationContact ID",
97
+ label=_("Contact ID"),
93
98
  )
94
99
  organization = forms.CharField(
95
100
  required=False,
101
+ label=_("Organization"),
96
102
  )
97
103
  street = forms.CharField(
98
104
  required=False,
105
+ label=_("Street"),
99
106
  )
100
107
  city = forms.CharField(
101
108
  required=False,
109
+ label=_("City"),
102
110
  )
103
111
  state_province = forms.CharField(
104
112
  required=False,
105
- label="State/Province",
113
+ label=_("State/Province"),
106
114
  )
107
115
  postal_code = forms.CharField(
108
116
  required=False,
109
- label="Postal Code",
117
+ label=_("Postal Code"),
110
118
  )
111
119
  country = forms.CharField(
112
120
  required=False,
121
+ label=_("Country"),
113
122
  )
114
123
  phone = forms.CharField(
115
124
  required=False,
125
+ label=_("Phone"),
116
126
  )
117
127
  phone_ext = forms.CharField(
118
128
  required=False,
119
- label="Phone Extension",
129
+ label=_("Phone Extension"),
120
130
  )
121
131
  fax = forms.CharField(
122
132
  required=False,
133
+ label=_("Fax"),
123
134
  )
124
135
  fax_ext = forms.CharField(
125
136
  required=False,
126
- label="Fax Extension",
137
+ label=_("Fax Extension"),
127
138
  )
128
139
  email = forms.CharField(
129
140
  required=False,
141
+ label=_("Email Address"),
130
142
  )
131
143
  tag = TagFilterField(RegistrationContact)
132
144
 
@@ -158,59 +170,59 @@ class RegistrationContactBulkEditForm(NetBoxModelBulkEditForm):
158
170
 
159
171
  name = forms.CharField(
160
172
  required=False,
161
- label="Name",
173
+ label=_("Name"),
162
174
  )
163
175
  description = forms.CharField(
164
176
  required=False,
165
- label="Description",
177
+ label=_("Description"),
166
178
  )
167
179
  organization = forms.CharField(
168
180
  required=False,
169
- label="Organization",
181
+ label=_("Organization"),
170
182
  )
171
183
  street = forms.CharField(
172
184
  required=False,
173
- label="Street",
185
+ label=_("Street"),
174
186
  )
175
187
  city = forms.CharField(
176
188
  required=False,
177
- label="City",
189
+ label=_("City"),
178
190
  )
179
191
  state_province = forms.CharField(
180
192
  required=False,
181
- label="State/Province",
193
+ label=_("State/Province"),
182
194
  )
183
195
  postal_code = forms.CharField(
184
196
  required=False,
185
- label="Postal Code",
197
+ label=_("Postal Code"),
186
198
  )
187
199
  country = forms.CharField(
188
200
  required=False,
189
- label="Country",
201
+ label=_("Country"),
190
202
  )
191
203
  phone = forms.CharField(
192
204
  required=False,
193
- label="Phone",
205
+ label=_("Phone"),
194
206
  )
195
207
  phone_ext = forms.CharField(
196
208
  required=False,
197
- label="Phone Extension",
209
+ label=_("Phone Extension"),
198
210
  )
199
211
  fax = forms.CharField(
200
212
  required=False,
201
- label="Fax",
213
+ label=_("Fax"),
202
214
  )
203
215
  fax_ext = forms.CharField(
204
216
  required=False,
205
- label="Fax Extension",
217
+ label=_("Fax Extension"),
206
218
  )
207
219
  email = forms.CharField(
208
220
  required=False,
209
- label="Email Address",
221
+ label=_("Email Address"),
210
222
  )
211
223
 
212
224
  fieldsets = (
213
- FieldSet("name", "description", name="Attributes"),
225
+ FieldSet("name", "description", name=_("Attributes")),
214
226
  FieldSet(
215
227
  "organization",
216
228
  "street",
@@ -218,7 +230,7 @@ class RegistrationContactBulkEditForm(NetBoxModelBulkEditForm):
218
230
  "state_province",
219
231
  "postal_code",
220
232
  "country",
221
- name="Address",
233
+ name=_("Address"),
222
234
  ),
223
235
  FieldSet(
224
236
  "phone",
@@ -226,7 +238,7 @@ class RegistrationContactBulkEditForm(NetBoxModelBulkEditForm):
226
238
  "fax",
227
239
  "fax_ext",
228
240
  "email",
229
- name="Communication",
241
+ name=_("Communication"),
230
242
  ),
231
243
  )
232
244
 
netbox_dns/forms/view.py CHANGED
@@ -2,6 +2,8 @@ from django import forms
2
2
  from django.conf import settings
3
3
  from django.core.exceptions import ValidationError, FieldError
4
4
  from django.db.models import Q, Count
5
+ from django.utils.translation import gettext_lazy as _
6
+ from django.utils.translation import pgettext_lazy as _p
5
7
 
6
8
  from netbox.forms import (
7
9
  NetBoxModelBulkEditForm,
@@ -19,7 +21,7 @@ from utilities.forms.fields import (
19
21
  from utilities.forms import BOOLEAN_WITH_BLANK_CHOICES
20
22
  from utilities.forms.rendering import FieldSet
21
23
  from utilities.forms.fields import JSONField
22
- from tenancy.models import Tenant
24
+ from tenancy.models import Tenant, TenantGroup
23
25
  from tenancy.forms import TenancyForm, TenancyFilterForm
24
26
  from ipam.models import Prefix, IPAddress
25
27
  from netbox.context import current_request
@@ -106,28 +108,29 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
106
108
  self._saved_prefixes = self.initial["prefixes"]
107
109
  self.initial["prefixes"] = []
108
110
  self.fields["prefixes"].disabled = True
109
- self.fields["prefixes"].widget.attrs[
110
- "placeholder"
111
- ] = "You do not have permission to modify assigned prefixes"
111
+ self.fields["prefixes"].widget.attrs["placeholder"] = _(
112
+ "You do not have permission to modify assigned prefixes"
113
+ )
112
114
 
113
115
  prefixes = PrefixDynamicModelMultipleChoiceField(
114
116
  queryset=Prefix.objects.all(),
115
117
  required=False,
116
- label="IPAM Prefixes",
117
118
  context={
118
119
  "depth": None,
119
120
  },
121
+ label=_("IPAM Prefixes"),
120
122
  )
121
123
  ip_address_filter = JSONField(
122
- label="IP Address Filter",
123
124
  required=False,
124
- help_text="Specify criteria for address record creation in JSON form",
125
+ help_text=_("Specify criteria for address record creation in JSON form"),
126
+ label=_("IP Address Filter"),
125
127
  )
126
128
 
127
129
  fieldsets = (
128
- FieldSet("name", "default_view", "description", "tags", name="View"),
130
+ FieldSet("name", "default_view", "description", name=_p("DNS", "View")),
129
131
  FieldSet("prefixes", "ip_address_filter"),
130
- FieldSet("tenant_group", "tenant", name="Tenancy"),
132
+ FieldSet("tenant_group", "tenant", name=_("Tenancy")),
133
+ FieldSet("tags", name=_("Tags")),
131
134
  )
132
135
 
133
136
  class Meta:
@@ -136,10 +139,11 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
136
139
  "name",
137
140
  "default_view",
138
141
  "description",
139
- "tags",
140
- "tenant",
141
142
  "prefixes",
142
143
  "ip_address_filter",
144
+ "tenant_group",
145
+ "tenant",
146
+ "tags",
143
147
  )
144
148
 
145
149
  def clean_prefixes(self):
@@ -154,7 +158,10 @@ class ViewForm(ViewPrefixUpdateMixin, TenancyForm, NetBoxModelForm):
154
158
  try:
155
159
  IPAddress.objects.filter(get_query_from_filter(ip_address_filter)).exists()
156
160
  except (FieldError, ValueError) as exc:
157
- self.add_error("ip_address_filter", f"Invalid filter for IPAddress: {exc}")
161
+ self.add_error(
162
+ "ip_address_filter",
163
+ _("Invalid filter for IPAddress: {error}").format(error=exc),
164
+ )
158
165
 
159
166
  return ip_address_filter
160
167
 
@@ -169,9 +176,9 @@ class ViewFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
169
176
  model = View
170
177
  fieldsets = (
171
178
  FieldSet("q", "filter_id", "tag"),
172
- FieldSet("name", "default_view", "description", name="Attributes"),
179
+ FieldSet("name", "default_view", "description", name=_("Attributes")),
173
180
  FieldSet("prefix_id"),
174
- FieldSet("tenant_group_id", "tenant_id", name="Tenancy"),
181
+ FieldSet("tenant_group_id", "tenant_id", name=_("Tenancy")),
175
182
  )
176
183
 
177
184
  name = forms.CharField(
@@ -187,10 +194,10 @@ class ViewFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
187
194
  prefix_id = PrefixDynamicModelMultipleChoiceField(
188
195
  queryset=Prefix.objects.all(),
189
196
  required=False,
190
- label="Prefix",
191
197
  context={
192
198
  "depth": None,
193
199
  },
200
+ label=_("Prefix"),
194
201
  )
195
202
  tag = TagFilterField(View)
196
203
 
@@ -206,13 +213,14 @@ class ViewImportForm(ViewPrefixUpdateMixin, NetBoxModelImportForm):
206
213
  queryset=Prefix.objects.all(),
207
214
  to_field_name="id",
208
215
  required=False,
209
- help_text="Prefix IDs assigned to the view",
216
+ help_text=_("Prefix IDs assigned to the view"),
217
+ label=_("Prefixes"),
210
218
  )
211
219
  tenant = CSVModelChoiceField(
212
220
  queryset=Tenant.objects.all(),
213
221
  to_field_name="name",
214
222
  required=False,
215
- help_text="Assigned tenant",
223
+ label=_("Tenant"),
216
224
  )
217
225
 
218
226
  class Meta:
@@ -223,16 +231,28 @@ class ViewImportForm(ViewPrefixUpdateMixin, NetBoxModelImportForm):
223
231
  class ViewBulkEditForm(NetBoxModelBulkEditForm):
224
232
  model = View
225
233
 
226
- description = forms.CharField(max_length=200, required=False)
227
- tenant = DynamicModelChoiceField(queryset=Tenant.objects.all(), required=False)
234
+ description = forms.CharField(
235
+ max_length=200,
236
+ required=False,
237
+ label=_("Description"),
238
+ )
239
+ tenant_group = DynamicModelChoiceField(
240
+ queryset=TenantGroup.objects.all(),
241
+ required=False,
242
+ label=_("Tenant Group"),
243
+ )
244
+ tenant = DynamicModelChoiceField(
245
+ queryset=Tenant.objects.all(),
246
+ required=False,
247
+ label=_("Tenant"),
248
+ )
228
249
 
229
250
  fieldsets = (
230
251
  FieldSet(
231
- "name",
232
252
  "description",
233
- name="Attributes",
253
+ name=_("Attributes"),
234
254
  ),
235
- FieldSet("tenant", name="Tenancy"),
255
+ FieldSet("tenant_group", "tenant", name=_("Tenancy")),
236
256
  )
237
257
 
238
258
  nullable_fields = ("description", "tenant")
@@ -242,8 +262,10 @@ class ViewPrefixEditForm(forms.ModelForm):
242
262
  views = DynamicModelMultipleChoiceField(
243
263
  queryset=View.objects.all(),
244
264
  required=False,
245
- label="Assigned DNS Views",
246
- help_text="Explicitly assigning DNS views overrides all inherited views for this prefix",
265
+ help_text=_(
266
+ "Explicitly assigning DNS views overrides all inherited views for this prefix"
267
+ ),
268
+ label=_("Assigned DNS Views"),
247
269
  )
248
270
 
249
271
  class Meta:
@@ -261,9 +283,9 @@ class ViewPrefixEditForm(forms.ModelForm):
261
283
  self._permission_denied = True
262
284
  self.initial["views"] = []
263
285
  self.fields["views"].disabled = True
264
- self.fields["views"].widget.attrs[
265
- "placeholder"
266
- ] = "You do not have permission to modify assigned views"
286
+ self.fields["views"].widget.attrs["placeholder"] = _(
287
+ "You do not have permission to modify assigned views"
288
+ )
267
289
 
268
290
  def clean(self, *args, **kwargs):
269
291
  if self._permission_denied: