Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement objectchange log excludes for object_data_v2 data as well #726

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions nautobot_golden_config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,18 @@ def to_objectchange(
self, action, *, related_object=None, object_data_extra=None, object_data_exclude=None
): # pylint: disable=arguments-differ
"""Remove actual and intended configuration from changelog."""
fields_to_exclude = ["actual", "intended"]
if not object_data_exclude:
object_data_exclude = ["actual", "intended"]
object_data_exclude = fields_to_exclude
data_v2 = serialize_object_v2(self)
for field in fields_to_exclude:
data_v2.pop(field)
return ObjectChange(
changed_object=self,
object_repr=str(self),
action=action,
object_data=serialize_object(self, extra=object_data_extra, exclude=object_data_exclude),
object_data_v2=serialize_object_v2(self),
object_data_v2=data_v2,
related_object=related_object,
)

Expand Down Expand Up @@ -413,14 +417,18 @@ def to_objectchange(
self, action, *, related_object=None, object_data_extra=None, object_data_exclude=None
): # pylint: disable=arguments-differ
"""Remove actual and intended configuration from changelog."""
fields_to_exclude = ["backup_config", "intended_config", "compliance_config"]
if not object_data_exclude:
object_data_exclude = ["backup_config", "intended_config", "compliance_config"]
object_data_exclude = fields_to_exclude
data_v2 = serialize_object_v2(self)
for field in fields_to_exclude:
data_v2.pop(field)
return ObjectChange(
changed_object=self,
object_repr=str(self),
action=action,
object_data=serialize_object(self, extra=object_data_extra, exclude=object_data_exclude),
object_data_v2=serialize_object_v2(self),
object_data_v2=data_v2,
related_object=related_object,
)

Expand Down
Loading