Commit 1b913361 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'cherry-pick-4717bfce' into 'release-22.1'

release-22.1:Backport!6286

See merge request !6307
parents e081f01b f5cf9b0d
# ----------------------------------------------------------------------
# @change decorator and worker
# ----------------------------------------------------------------------
# Copyright (C) 2007-2021 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
......@@ -79,6 +79,15 @@ def _on_document_delete(sender, document, *args, **kwargs):
id=str(document.id),
fields=None,
)
if not hasattr(document, "get_changed_instance"):
return
document = document.get_changed_instance()
change_tracker.register(
op="update",
model=get_model_id(document),
id=str(document.id),
fields=None,
)
def _on_model_change(sender, instance, created=False, *args, **kwargs):
......@@ -121,3 +130,12 @@ def _on_model_delete(sender, instance, *args, **kwargs):
id=str(instance.id),
fields=None,
)
if not hasattr(instance, "get_changed_instance"):
return
instance = instance.get_changed_instance()
change_tracker.register(
op="update",
model=get_model_id(instance),
id=str(instance.id),
fields=None,
)
# ---------------------------------------------------------------------
# DNSZoneRecord model
# ---------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from typing import Optional
# Third-party modules
from django.db import models
from django.contrib.postgres.fields import ArrayField
......@@ -32,7 +35,7 @@ class DNSZoneRecord(NOCModel):
db_table = "dns_dnszonerecord"
app_label = "dns"
zone = models.ForeignKey(DNSZone, verbose_name="Zone", on_delete=models.CASCADE)
zone: "DNSZone" = models.ForeignKey(DNSZone, verbose_name="Zone", on_delete=models.CASCADE)
name = models.CharField(_("Name"), max_length=64, blank=True, null=True)
ttl = models.IntegerField(_("TTL"), null=True, blank=True)
type = models.CharField(_("Type"), max_length=16)
......@@ -50,7 +53,7 @@ class DNSZoneRecord(NOCModel):
)
@classmethod
def get_by_id(cls, id):
def get_by_id(cls, id) -> Optional["DNSZoneRecord"]:
dnszonerecord = DNSZoneRecord.objects.filter(id=id)[:1]
if dnszonerecord:
return dnszonerecord[0]
......@@ -60,5 +63,5 @@ class DNSZoneRecord(NOCModel):
return self.zone
@classmethod
def can_set_label(cls, label):
def can_set_label(cls, label: str) -> bool:
return Label.get_effective_setting(label, setting="enable_dnszonerecord")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment