netbox-plugin-dns 1.1.0__py3-none-any.whl → 1.1.0b1__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 +6 -9
  2. netbox_dns/api/nested_serializers.py +16 -17
  3. netbox_dns/api/serializers.py +1 -1
  4. netbox_dns/api/serializers_/{registration_contact.py → contact.py} +5 -5
  5. netbox_dns/api/serializers_/record.py +0 -1
  6. netbox_dns/api/serializers_/zone.py +5 -5
  7. netbox_dns/api/serializers_/zone_template.py +5 -5
  8. netbox_dns/api/urls.py +2 -2
  9. netbox_dns/api/views.py +35 -9
  10. netbox_dns/fields/ipam.py +3 -0
  11. netbox_dns/filtersets/__init__.py +1 -1
  12. netbox_dns/filtersets/{registration_contact.py → contact.py} +4 -4
  13. netbox_dns/filtersets/record.py +1 -1
  14. netbox_dns/filtersets/zone.py +15 -15
  15. netbox_dns/filtersets/zone_template.py +15 -15
  16. netbox_dns/forms/__init__.py +1 -1
  17. netbox_dns/forms/{registration_contact.py → contact.py} +16 -16
  18. netbox_dns/forms/view.py +7 -95
  19. netbox_dns/forms/zone.py +17 -22
  20. netbox_dns/forms/zone_template.py +13 -13
  21. netbox_dns/graphql/__init__.py +2 -2
  22. netbox_dns/graphql/filters.py +5 -5
  23. netbox_dns/graphql/schema.py +44 -24
  24. netbox_dns/graphql/types.py +12 -40
  25. netbox_dns/management/commands/{setup_dnssync.py → setup_autodns.py} +28 -48
  26. netbox_dns/migrations/{0008_view_prefixes.py → 0007_view_prefixes.py} +1 -1
  27. netbox_dns/models/__init__.py +1 -1
  28. netbox_dns/models/{registration_contact.py → contact.py} +9 -15
  29. netbox_dns/models/nameserver.py +3 -8
  30. netbox_dns/models/record.py +28 -93
  31. netbox_dns/models/record_template.py +1 -4
  32. netbox_dns/models/registrar.py +1 -7
  33. netbox_dns/models/view.py +2 -9
  34. netbox_dns/models/zone.py +22 -59
  35. netbox_dns/models/zone_template.py +9 -12
  36. netbox_dns/navigation.py +7 -7
  37. netbox_dns/signals/ipam_autodns.py +138 -0
  38. netbox_dns/tables/__init__.py +1 -1
  39. netbox_dns/tables/{registration_contact.py → contact.py} +6 -5
  40. netbox_dns/tables/nameserver.py +7 -1
  41. netbox_dns/tables/record.py +30 -43
  42. netbox_dns/tables/record_template.py +17 -0
  43. netbox_dns/tables/registrar.py +2 -0
  44. netbox_dns/tables/view.py +8 -1
  45. netbox_dns/tables/zone.py +15 -0
  46. netbox_dns/tables/zone_template.py +16 -2
  47. netbox_dns/template_content.py +2 -14
  48. netbox_dns/templates/netbox_dns/{registrationcontact.html → contact.html} +1 -1
  49. netbox_dns/templates/netbox_dns/view.html +7 -3
  50. netbox_dns/urls/__init__.py +2 -2
  51. netbox_dns/urls/contact.py +51 -0
  52. netbox_dns/urls/nameserver.py +38 -14
  53. netbox_dns/urls/record.py +19 -7
  54. netbox_dns/urls/record_template.py +27 -18
  55. netbox_dns/urls/registrar.py +35 -11
  56. netbox_dns/urls/view.py +20 -12
  57. netbox_dns/urls/zone.py +46 -8
  58. netbox_dns/urls/zone_template.py +26 -16
  59. netbox_dns/utilities/__init__.py +1 -1
  60. netbox_dns/utilities/{ipam_dnssync.py → ipam_autodns.py} +32 -122
  61. netbox_dns/validators/dns_name.py +0 -9
  62. netbox_dns/views/__init__.py +1 -1
  63. netbox_dns/views/contact.py +95 -0
  64. netbox_dns/views/nameserver.py +3 -7
  65. netbox_dns/views/record.py +7 -12
  66. netbox_dns/views/record_template.py +1 -1
  67. netbox_dns/views/registrar.py +1 -0
  68. netbox_dns/views/view.py +2 -32
  69. netbox_dns/views/zone.py +6 -7
  70. netbox_dns/views/zone_template.py +2 -2
  71. {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b1.dist-info}/METADATA +2 -3
  72. netbox_plugin_dns-1.1.0b1.dist-info/RECORD +140 -0
  73. netbox_dns/management/commands/rebuild_dnssync.py +0 -18
  74. netbox_dns/migrations/0007_alter_ordering_options.py +0 -25
  75. netbox_dns/migrations/0009_rename_contact_registrationcontact.py +0 -27
  76. netbox_dns/signals/ipam_dnssync.py +0 -224
  77. netbox_dns/tables/ipam_dnssync.py +0 -11
  78. netbox_dns/templates/netbox_dns/view/button.html +0 -9
  79. netbox_dns/templates/netbox_dns/view/prefix.html +0 -41
  80. netbox_dns/urls/registration_contact.py +0 -60
  81. netbox_dns/views/registration_contact.py +0 -94
  82. netbox_plugin_dns-1.1.0.dist-info/RECORD +0 -146
  83. {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b1.dist-info}/LICENSE +0 -0
  84. {netbox_plugin_dns-1.1.0.dist-info → netbox_plugin_dns-1.1.0b1.dist-info}/WHEEL +0 -0
@@ -1,31 +1,21 @@
1
- from django.urls import include, path
1
+ from django.urls import path
2
2
 
3
- from utilities.urls import get_model_urls
3
+ from netbox.views.generic import ObjectChangeLogView, ObjectJournalView
4
4
 
5
+ from netbox_dns.models import ZoneTemplate
5
6
  from netbox_dns.views import (
6
- ZoneTemplateView,
7
7
  ZoneTemplateListView,
8
- ZoneTemplateEditView,
8
+ ZoneTemplateView,
9
9
  ZoneTemplateDeleteView,
10
+ ZoneTemplateEditView,
10
11
  ZoneTemplateBulkImportView,
11
12
  ZoneTemplateBulkEditView,
12
13
  ZoneTemplateBulkDeleteView,
13
14
  )
14
15
 
15
16
  zonetemplate_urlpatterns = [
16
- path("zonetemplates/<int:pk>/", ZoneTemplateView.as_view(), name="zonetemplate"),
17
17
  path("zonetemplates/", ZoneTemplateListView.as_view(), name="zonetemplate_list"),
18
18
  path("zonetemplates/add/", ZoneTemplateEditView.as_view(), name="zonetemplate_add"),
19
- path(
20
- "zonetemplates/<int:pk>/edit/",
21
- ZoneTemplateEditView.as_view(),
22
- name="zonetemplate_edit",
23
- ),
24
- path(
25
- "zonetemplates/<int:pk>/delete/",
26
- ZoneTemplateDeleteView.as_view(),
27
- name="zonetemplate_delete",
28
- ),
29
19
  path(
30
20
  "zonetemplates/import/",
31
21
  ZoneTemplateBulkImportView.as_view(),
@@ -41,7 +31,27 @@ zonetemplate_urlpatterns = [
41
31
  ZoneTemplateBulkDeleteView.as_view(),
42
32
  name="zonetemplate_bulk_delete",
43
33
  ),
34
+ path("zonetemplates/<int:pk>/", ZoneTemplateView.as_view(), name="zonetemplate"),
35
+ path(
36
+ "zonetemplates/<int:pk>/delete/",
37
+ ZoneTemplateDeleteView.as_view(),
38
+ name="zonetemplate_delete",
39
+ ),
40
+ path(
41
+ "zonetemplates/<int:pk>/edit/",
42
+ ZoneTemplateEditView.as_view(),
43
+ name="zonetemplate_edit",
44
+ ),
45
+ path(
46
+ "zonetemplates/<int:pk>/journal/",
47
+ ObjectJournalView.as_view(),
48
+ name="zonetemplate_journal",
49
+ kwargs={"model": ZoneTemplate},
50
+ ),
44
51
  path(
45
- "zonetemplates/<int:pk>/", include(get_model_urls("netbox_dns", "zonetemplate"))
52
+ "zonetemplates/<int:pk>/changelog/",
53
+ ObjectChangeLogView.as_view(),
54
+ name="zonetemplate_changelog",
55
+ kwargs={"model": ZoneTemplate},
46
56
  ),
47
57
  ]
@@ -1,2 +1,2 @@
1
1
  from .conversions import *
2
- from .ipam_dnssync import *
2
+ from .ipam_autodns import *
@@ -7,25 +7,21 @@ from dns import name as dns_name
7
7
  from django.conf import settings
8
8
  from django.db.models import Q
9
9
 
10
- from netbox.context import current_request
11
10
  from ipam.models import IPAddress, Prefix
12
11
 
13
12
  from netbox_dns.models import zone as _zone
14
13
  from netbox_dns.models import record as _record
15
14
  from netbox_dns.models import view as _view
16
- from netbox_dns.choices import RecordStatusChoices
17
15
 
18
16
 
19
17
  __all__ = (
20
18
  "get_zones",
21
- "check_dns_records",
22
19
  "update_dns_records",
23
20
  "delete_dns_records",
24
21
  "get_views_by_prefix",
25
22
  "get_ip_addresses_by_prefix",
26
23
  "get_ip_addresses_by_view",
27
24
  "get_ip_addresses_by_zone",
28
- "check_record_permission",
29
25
  )
30
26
 
31
27
 
@@ -44,36 +40,16 @@ def _get_assigned_views(ip_address):
44
40
 
45
41
  def _get_record_status(ip_address):
46
42
  return (
47
- RecordStatusChoices.STATUS_ACTIVE
43
+ RecordStatusChoices.STATE_ACTIVE
48
44
  if ip_address.status
49
45
  in settings.PLUGINS_CONFIG["netbox_dns"].get(
50
- "dnssync_ipaddress_active_status", []
46
+ "autodns_ipaddress_active_status", []
51
47
  )
52
48
  else RecordStatusChoices.STATUS_INACTIVE
53
49
  )
54
50
 
55
51
 
56
- def _valid_entry(ip_address, zone):
57
- return zone.view in _get_assigned_views(ip_address) and dns_name.from_text(
58
- ip_address.dns_name
59
- ).is_subdomain(dns_name.from_text(zone.name))
60
-
61
-
62
- def _match_data(ip_address, record):
63
- cf_disable_ptr = ip_address.custom_field_data.get(
64
- "ipaddress_dns_record_disable_ptr"
65
- )
66
-
67
- return (
68
- record.fqdn.rstrip(".") == ip_address.dns_name.rstrip(".")
69
- and record.value == str(ip_address.address.ip)
70
- and record.status == _get_record_status(ip_address)
71
- and record.ttl == ip_address.custom_field_data.get("ipaddress_dns_record_ttl")
72
- and (cf_disable_ptr is None or record.disable_ptr == cf_disable_ptr)
73
- )
74
-
75
-
76
- def get_zones(ip_address, view=None, old_zone=None):
52
+ def get_zones(ip_address, view=None):
77
53
  if view is None:
78
54
  views = _get_assigned_views(ip_address)
79
55
  if not views:
@@ -82,13 +58,9 @@ def get_zones(ip_address, view=None, old_zone=None):
82
58
  else:
83
59
  views = [view]
84
60
 
85
- min_labels = settings.PLUGINS_CONFIG["netbox_dns"].get(
86
- "dnssync_minimum_zone_labels", 2
87
- )
88
61
  fqdn = dns_name.from_text(ip_address.dns_name)
89
62
  zone_name_candidates = [
90
- fqdn.split(i)[1].to_text().rstrip(".")
91
- for i in range(min_labels + 1, len(fqdn.labels))
63
+ fqdn.split(i)[1].to_text().rstrip(".") for i in range(3, len(fqdn.labels))
92
64
  ]
93
65
 
94
66
  zones = _zone.Zone.objects.filter(
@@ -97,13 +69,10 @@ def get_zones(ip_address, view=None, old_zone=None):
97
69
  active=True,
98
70
  )
99
71
 
100
- zone_map = defaultdict(list)
101
-
102
- if old_zone is not None:
103
- zones = zones.exclude(pk=old_zone.pk)
104
- if _valid_entry(ip_address, old_zone):
105
- zone_map[old_zone.view].append(old_zone)
72
+ if not zones:
73
+ return []
106
74
 
75
+ zone_map = defaultdict(list)
107
76
  for zone in zones:
108
77
  zone_map[zone.view].append(zone)
109
78
 
@@ -113,77 +82,36 @@ def get_zones(ip_address, view=None, old_zone=None):
113
82
  ]
114
83
 
115
84
 
116
- def check_dns_records(ip_address, zone=None, view=None):
117
- if ip_address.dns_name == "":
118
- return
119
-
120
- if zone is None:
121
- zones = get_zones(ip_address, view=view)
122
-
123
- if ip_address.pk is not None:
124
- for record in ip_address.netbox_dns_records.filter(zone__in=zones):
125
- if not _match_data(ip_address, record):
126
- record.update_from_ip_address(ip_address)
127
-
128
- if record is not None:
129
- record.clean()
130
-
131
- zones = _zone.Zone.objects.filter(
132
- pk__in=[zone.pk for zone in zones]
133
- ).exclude(
134
- pk__in=set(ip_address.netbox_dns_records.values_list("zone", flat=True))
135
- )
136
-
137
- for zone in zones:
138
- record = _record.Record.create_from_ip_address(
139
- ip_address,
140
- zone,
141
- )
142
-
143
- if record is not None:
144
- record.clean()
145
-
146
- if ip_address.pk is None:
147
- return
148
-
149
- try:
150
- new_zone = get_zones(ip_address, old_zone=zone)[0]
151
- except IndexError:
152
- return
153
-
154
- for record in ip_address.netbox_dns_records.filter(zone=zone):
155
- record.update_from_ip_address(ip_address, new_zone)
156
-
157
- if record is not None:
158
- record.clean(new_zone=new_zone)
159
-
160
-
161
- def update_dns_records(ip_address):
85
+ def update_dns_records(ip_address, commit=True, view=None):
162
86
  if ip_address.dns_name == "":
163
- delete_dns_records(ip_address)
87
+ if commit:
88
+ delete_dns_records(ip_address)
164
89
  return
165
90
 
166
- zones = get_zones(ip_address)
91
+ zones = get_zones(ip_address, view=view)
167
92
 
168
93
  if ip_address.pk is not None:
169
94
  for record in ip_address.netbox_dns_records.all():
170
- if record.zone not in zones or ip_address.custom_field_data.get(
171
- "ipaddress_dns_disabled"
172
- ):
173
- record.delete()
95
+ if record.zone not in zones:
96
+ if commit:
97
+ record.delete()
174
98
  continue
175
99
 
176
- record.update_fqdn()
177
- if not _match_data(ip_address, record):
100
+ if (
101
+ record.fqdn != ip_address.dns_name
102
+ or record.value != ip_address.address.ip
103
+ or record.status != _get_record_status(ip_address)
104
+ ):
178
105
  record.update_from_ip_address(ip_address)
179
106
 
180
107
  if record is not None:
181
- record.save()
108
+ if commit:
109
+ record.save()
110
+ else:
111
+ record.clean()
182
112
 
183
- zones = _zone.Zone.objects.filter(pk__in=[zone.pk for zone in zones]).exclude(
184
- pk__in=set(
185
- ip_address.netbox_dns_records.all().values_list("zone", flat=True)
186
- )
113
+ zones = set(zones).difference(
114
+ {record.zone for record in ip_address.netbox_dns_records.all()}
187
115
  )
188
116
 
189
117
  for zone in zones:
@@ -193,7 +121,10 @@ def update_dns_records(ip_address):
193
121
  )
194
122
 
195
123
  if record is not None:
196
- record.save()
124
+ if commit:
125
+ record.save()
126
+ else:
127
+ record.clean()
197
128
 
198
129
 
199
130
  def delete_dns_records(ip_address):
@@ -228,9 +159,7 @@ def get_ip_addresses_by_prefix(prefix, check_view=True):
228
159
  vrf=prefix.vrf, address__net_host_contained=prefix.prefix
229
160
  )
230
161
 
231
- for exclude_child in (
232
- prefix.get_children().filter(netbox_dns_views__isnull=False).distinct()
233
- ):
162
+ for exclude_child in prefix.get_children().filter(netbox_dns_views__isnull=False):
234
163
  queryset = queryset.exclude(
235
164
  vrf=exclude_child.vrf,
236
165
  address__net_host_contained=exclude_child.prefix,
@@ -271,25 +200,6 @@ def get_ip_addresses_by_zone(zone):
271
200
  are the IPAddress objects in prefixes assigned to the same view, if the
272
201
  'dns_name' attribute of the IPAddress object ends in the zone's name.
273
202
  """
274
- queryset = get_ip_addresses_by_view(zone.view).filter(
275
- dns_name__regex=rf"\.{re.escape(zone.name)}\.?$"
276
- )
277
-
278
- return queryset
203
+ queryset = get_ip_addresses_by_view(zone.view)
279
204
 
280
-
281
- def check_record_permission(add=True, change=True, delete=True):
282
- checks = locals().copy()
283
-
284
- request = current_request.get()
285
-
286
- if request is None:
287
- return True
288
-
289
- return all(
290
- (
291
- request.user.has_perm(f"netbox_dns.{perm}_record")
292
- for perm, check in checks.items()
293
- if check
294
- )
295
- )
205
+ return queryset.filter(dns_name__regex=rf"\.{re.escape(zone.name)}\.?$")
@@ -7,7 +7,6 @@ from netbox.plugins.utils import get_plugin_config
7
7
 
8
8
  __all__ = (
9
9
  "validate_fqdn",
10
- "validate_rname",
11
10
  "validate_generic_name",
12
11
  "validate_domain_name",
13
12
  )
@@ -58,14 +57,6 @@ def validate_fqdn(name, always_tolerant=False):
58
57
  raise ValidationError(f"{name} is not a valid fully qualified DNS host name")
59
58
 
60
59
 
61
- def validate_rname(name, always_tolerant=False):
62
- label, zone_label = _get_label(always_tolerant=always_tolerant)
63
- regex = rf"^(\*|{label})(\\\.{label})*(\.{zone_label}){{2,}}\.?$"
64
-
65
- if not re.match(regex, name, flags=re.IGNORECASE) or _has_invalid_double_dash(name):
66
- raise ValidationError(f"{name} is not a valid RNAME")
67
-
68
-
69
60
  def validate_generic_name(
70
61
  name, tolerate_leading_underscores=False, always_tolerant=False
71
62
  ):
@@ -2,7 +2,7 @@ from .view import *
2
2
  from .zone import *
3
3
  from .nameserver import *
4
4
  from .record import *
5
- from .registration_contact import *
5
+ from .contact import *
6
6
  from .registrar import *
7
7
  from .zone_template import *
8
8
  from .record_template import *
@@ -0,0 +1,95 @@
1
+ from django.db.models import Q
2
+
3
+ from netbox.views import generic
4
+
5
+ from utilities.views import ViewTab, register_model_view
6
+
7
+ from netbox_dns.models import Contact, Zone
8
+ from netbox_dns.filtersets import ContactFilterSet, ZoneFilterSet
9
+ from netbox_dns.forms import (
10
+ ContactForm,
11
+ ContactFilterForm,
12
+ ContactImportForm,
13
+ ContactBulkEditForm,
14
+ )
15
+ from netbox_dns.tables import ContactTable, ZoneTable
16
+
17
+
18
+ __all__ = (
19
+ "ContactView",
20
+ "ContactEditView",
21
+ "ContactListView",
22
+ "ContactDeleteView",
23
+ "ContactBulkImportView",
24
+ "ContactBulkEditView",
25
+ "ContactBulkDeleteView",
26
+ "ContactZoneListView",
27
+ )
28
+
29
+
30
+ class ContactView(generic.ObjectView):
31
+ queryset = Contact.objects.all()
32
+
33
+
34
+ class ContactListView(generic.ObjectListView):
35
+ queryset = Contact.objects.all()
36
+ table = ContactTable
37
+ filterset = ContactFilterSet
38
+ filterset_form = ContactFilterForm
39
+
40
+
41
+ class ContactEditView(generic.ObjectEditView):
42
+ queryset = Contact.objects.all()
43
+ form = ContactForm
44
+ default_return_url = "plugins:netbox_dns:contact_list"
45
+
46
+
47
+ class ContactDeleteView(generic.ObjectDeleteView):
48
+ queryset = Contact.objects.all()
49
+ default_return_url = "plugins:netbox_dns:contact_list"
50
+
51
+
52
+ class ContactBulkImportView(generic.BulkImportView):
53
+ queryset = Contact.objects.all()
54
+ model_form = ContactImportForm
55
+ table = ContactTable
56
+ default_return_url = "plugins:netbox_dns:contact_list"
57
+
58
+
59
+ class ContactBulkEditView(generic.BulkEditView):
60
+ queryset = Contact.objects.all()
61
+ filterset = ContactFilterSet
62
+ table = ContactTable
63
+ form = ContactBulkEditForm
64
+
65
+
66
+ class ContactBulkDeleteView(generic.BulkDeleteView):
67
+ queryset = Contact.objects.all()
68
+ table = ContactTable
69
+
70
+
71
+ @register_model_view(Contact, "zones")
72
+ class ContactZoneListView(generic.ObjectChildrenView):
73
+ queryset = Contact.objects.all().prefetch_related(
74
+ "zone_set", "admin_c_zones", "tech_c_zones", "billing_c_zones"
75
+ )
76
+ child_model = Zone
77
+ table = ZoneTable
78
+ filterset = ZoneFilterSet
79
+ template_name = "netbox_dns/zone/child.html"
80
+ hide_if_empty = True
81
+
82
+ tab = ViewTab(
83
+ label="Zones",
84
+ permission="netbox_dns.view_zone",
85
+ badge=lambda obj: len(obj.zones),
86
+ hide_if_empty=True,
87
+ )
88
+
89
+ def get_children(self, request, parent):
90
+ return Zone.objects.filter(
91
+ Q(registrant=parent)
92
+ | Q(admin_c=parent)
93
+ | Q(tech_c=parent)
94
+ | Q(billing_c=parent)
95
+ )
@@ -2,7 +2,6 @@ from dns import name as dns_name
2
2
 
3
3
  from netbox.views import generic
4
4
  from utilities.views import ViewTab, register_model_view
5
- from tenancy.views import ObjectContactsView
6
5
 
7
6
  from netbox_dns.filtersets import NameServerFilterSet, ZoneFilterSet
8
7
  from netbox_dns.forms import (
@@ -16,13 +15,15 @@ from netbox_dns.tables import NameServerTable, ZoneTable
16
15
 
17
16
 
18
17
  __all__ = (
19
- "NameServerView",
20
18
  "NameServerListView",
19
+ "NameServerView",
21
20
  "NameServerEditView",
22
21
  "NameServerDeleteView",
23
22
  "NameServerBulkEditView",
24
23
  "NameServerBulkImportView",
25
24
  "NameServerBulkDeleteView",
25
+ "NameServerZoneListView",
26
+ "NameServerSOAZoneListView",
26
27
  )
27
28
 
28
29
 
@@ -76,11 +77,6 @@ class NameServerBulkDeleteView(generic.BulkDeleteView):
76
77
  table = NameServerTable
77
78
 
78
79
 
79
- @register_model_view(NameServer, "contacts")
80
- class NameServerContactsView(ObjectContactsView):
81
- queryset = NameServer.objects.all()
82
-
83
-
84
80
  @register_model_view(NameServer, "zones")
85
81
  class NameServerZoneListView(generic.ObjectChildrenView):
86
82
  queryset = NameServer.objects.all().prefetch_related("zones")
@@ -1,8 +1,6 @@
1
1
  from dns import name as dns_name
2
2
 
3
3
  from netbox.views import generic
4
- from utilities.views import register_model_view
5
- from tenancy.views import ObjectContactsView
6
4
 
7
5
  from netbox_dns.filtersets import RecordFilterSet
8
6
  from netbox_dns.forms import (
@@ -18,14 +16,14 @@ from netbox_dns.utilities import value_to_unicode
18
16
 
19
17
 
20
18
  __all__ = (
21
- "RecordView",
22
19
  "RecordListView",
20
+ "ManagedRecordListView",
21
+ "RecordView",
23
22
  "RecordEditView",
24
23
  "RecordDeleteView",
25
24
  "RecordBulkImportView",
26
25
  "RecordBulkEditView",
27
26
  "RecordBulkDeleteView",
28
- "ManagedRecordListView",
29
27
  )
30
28
 
31
29
 
@@ -39,7 +37,9 @@ class RecordListView(generic.ObjectListView):
39
37
 
40
38
 
41
39
  class ManagedRecordListView(generic.ObjectListView):
42
- queryset = Record.objects.prefetch_related("ipam_ip_address", "address_record")
40
+ queryset = Record.objects.filter(managed=True).prefetch_related(
41
+ "zone", "address_record"
42
+ )
43
43
  filterset = RecordFilterSet
44
44
  filterset_form = RecordFilterForm
45
45
  table = ManagedRecordTable
@@ -90,11 +90,11 @@ class RecordView(generic.ObjectView):
90
90
  zone=parent_zone,
91
91
  )
92
92
  cname_records = cname_records.union(
93
- {
93
+ set(
94
94
  record
95
95
  for record in parent_cname_records
96
96
  if record.value_fqdn == instance.fqdn
97
- }
97
+ )
98
98
  )
99
99
 
100
100
  if cname_records:
@@ -155,8 +155,3 @@ class RecordBulkEditView(generic.BulkEditView):
155
155
  class RecordBulkDeleteView(generic.BulkDeleteView):
156
156
  queryset = Record.objects.filter(managed=False)
157
157
  table = RecordTable
158
-
159
-
160
- @register_model_view(Record, "contacts")
161
- class RecordContactsView(ObjectContactsView):
162
- queryset = Record.objects.all()
@@ -15,8 +15,8 @@ from netbox_dns.utilities import value_to_unicode
15
15
 
16
16
 
17
17
  __all__ = (
18
- "RecordTemplateView",
19
18
  "RecordTemplateListView",
19
+ "RecordTemplateView",
20
20
  "RecordTemplateEditView",
21
21
  "RecordTemplateDeleteView",
22
22
  "RecordTemplateBulkImportView",
@@ -21,6 +21,7 @@ __all__ = (
21
21
  "RegistrarBulkImportView",
22
22
  "RegistrarBulkEditView",
23
23
  "RegistrarBulkDeleteView",
24
+ "RegistrarZoneListView",
24
25
  )
25
26
 
26
27
 
netbox_dns/views/view.py CHANGED
@@ -1,20 +1,11 @@
1
1
  from utilities.views import ViewTab, register_model_view
2
2
 
3
3
  from netbox.views import generic
4
- from tenancy.views import ObjectContactsView
5
- from ipam.models import Prefix
6
4
 
7
5
  from netbox_dns.models import View, Zone
8
6
  from netbox_dns.filtersets import ViewFilterSet, ZoneFilterSet
9
- from netbox_dns.forms import (
10
- ViewForm,
11
- ViewFilterForm,
12
- ViewImportForm,
13
- ViewBulkEditForm,
14
- ViewPrefixEditForm,
15
- )
7
+ from netbox_dns.forms import ViewForm, ViewFilterForm, ViewImportForm, ViewBulkEditForm
16
8
  from netbox_dns.tables import ViewTable, ZoneTable
17
- from netbox_dns.utilities import get_views_by_prefix
18
9
 
19
10
 
20
11
  __all__ = (
@@ -25,7 +16,7 @@ __all__ = (
25
16
  "ViewBulkImportView",
26
17
  "ViewBulkEditView",
27
18
  "ViewBulkDeleteView",
28
- "ViewPrefixEditView",
19
+ "ViewZoneListView",
29
20
  )
30
21
 
31
22
 
@@ -70,22 +61,6 @@ class ViewBulkDeleteView(generic.BulkDeleteView):
70
61
  table = ViewTable
71
62
 
72
63
 
73
- class ViewPrefixEditView(generic.ObjectEditView):
74
- queryset = Prefix.objects.all()
75
- form = ViewPrefixEditForm
76
- template_name = "netbox_dns/view/prefix.html"
77
-
78
- def get_extra_context(self, request, instance):
79
- parents = instance.get_parents()
80
- if parents:
81
- return {
82
- "inherited_views": get_views_by_prefix(parents.last()),
83
- "inherited_from": parents.filter(netbox_dns_views__isnull=False).last(),
84
- }
85
-
86
- return {}
87
-
88
-
89
64
  @register_model_view(View, "zones")
90
65
  class ViewZoneListView(generic.ObjectChildrenView):
91
66
  queryset = View.objects.all().prefetch_related("zone_set")
@@ -104,8 +79,3 @@ class ViewZoneListView(generic.ObjectChildrenView):
104
79
 
105
80
  def get_children(self, request, parent):
106
81
  return parent.zone_set
107
-
108
-
109
- @register_model_view(View, "contacts")
110
- class ViewContactsView(ObjectContactsView):
111
- queryset = View.objects.all()
netbox_dns/views/zone.py CHANGED
@@ -2,7 +2,6 @@ from dns import name as dns_name
2
2
 
3
3
  from netbox.views import generic
4
4
  from utilities.views import ViewTab, register_model_view
5
- from tenancy.views import ObjectContactsView
6
5
 
7
6
  from netbox_dns.filtersets import ZoneFilterSet, RecordFilterSet
8
7
  from netbox_dns.forms import (
@@ -20,13 +19,18 @@ from netbox_dns.tables import (
20
19
 
21
20
 
22
21
  __all__ = (
23
- "ZoneView",
24
22
  "ZoneListView",
23
+ "ZoneView",
25
24
  "ZoneEditView",
26
25
  "ZoneDeleteView",
27
26
  "ZoneBulkImportView",
28
27
  "ZoneBulkEditView",
29
28
  "ZoneBulkDeleteView",
29
+ "ZoneRegistrationView",
30
+ "ZoneRecordListView",
31
+ "ZoneManagedRecordListView",
32
+ "ZoneRFC2317ChildZoneListView",
33
+ "ZoneChildZoneListView",
30
34
  )
31
35
 
32
36
 
@@ -197,8 +201,3 @@ class ZoneChildZoneListView(generic.ObjectChildrenView):
197
201
 
198
202
  def get_children(self, request, parent):
199
203
  return parent.child_zones
200
-
201
-
202
- @register_model_view(Zone, "contacts")
203
- class ZoneContactsView(ObjectContactsView):
204
- queryset = Zone.objects.all()
@@ -1,6 +1,5 @@
1
1
  from netbox.views import generic
2
2
 
3
- from netbox_dns.models import ZoneTemplate
4
3
  from netbox_dns.filtersets import ZoneTemplateFilterSet
5
4
  from netbox_dns.forms import (
6
5
  ZoneTemplateImportForm,
@@ -8,12 +7,13 @@ from netbox_dns.forms import (
8
7
  ZoneTemplateFilterForm,
9
8
  ZoneTemplateBulkEditForm,
10
9
  )
10
+ from netbox_dns.models import ZoneTemplate
11
11
  from netbox_dns.tables import ZoneTemplateTable, RecordTemplateDisplayTable
12
12
 
13
13
 
14
14
  __all__ = (
15
- "ZoneTemplateView",
16
15
  "ZoneTemplateListView",
16
+ "ZoneTemplateView",
17
17
  "ZoneTemplateEditView",
18
18
  "ZoneTemplateDeleteView",
19
19
  "ZoneTemplateBulkImportView",