Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Vladimir
noc
Commits
b267f555
Verified
Commit
b267f555
authored
May 20, 2022
by
Dmitry Volodin
Browse files
datastream: get_changed_instance helper method
parent
dd99981d
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/change/decorator.py
View file @
b267f555
...
...
@@ -91,12 +91,18 @@ def _on_model_change(sender, instance, created=False, *args, **kwargs):
nv
=
nv
.
pk
return
str
(
ov
)
!=
str
(
nv
)
# Check for instance proxying
if
hasattr
(
instance
,
"get_changed_instance"
):
instance
=
instance
.
get_changed_instance
()
changed_fields
=
[]
else
:
changed_fields
=
[
f_name
for
f_name
in
getattr
(
instance
,
"initial_data"
,
[])
if
is_changed
(
f_name
)
]
# Register change
model_id
=
get_model_id
(
instance
)
op
=
"create"
if
created
else
"update"
logger
.
debug
(
"[%s|%s] Change detected: %s"
,
model_id
,
instance
.
id
,
op
)
changed_fields
=
[
f_name
for
f_name
in
getattr
(
instance
,
"initial_data"
,
[])
if
is_changed
(
f_name
)
]
change_tracker
.
register
(
op
=
op
,
model
=
model_id
,
...
...
dns/models/dnszonerecord.py
View file @
b267f555
...
...
@@ -56,9 +56,8 @@ class DNSZoneRecord(NOCModel):
return
dnszonerecord
[
0
]
return
None
def
iter_changed_datastream
(
self
,
changed_fields
=
None
):
for
ds
,
id
in
self
.
zone
.
iter_changed_datastream
(
changed_fields
=
changed_fields
):
yield
ds
,
id
def
get_changed_instance
(
self
):
return
self
.
zone
@
classmethod
def
can_set_label
(
cls
,
label
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment