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

Fixes #73: Ensure all relevant ChangeDiffs are updated when an object is modified in main #74

Merged
merged 1 commit into from
Sep 4, 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
12 changes: 8 additions & 4 deletions netbox_branching/signal_receivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ def record_change_diff(instance, **kwargs):
return

print(f"Updating change diff for global change to {instance.changed_object}")
if diff := ChangeDiff.objects.filter(object_type=object_type, object_id=object_id, branch__status=BranchStatusChoices.READY).first():
diff.last_updated = timezone.now()
diff.current = instance.postchange_data_clean
diff.save()
ChangeDiff.objects.filter(
object_type=object_type,
object_id=object_id,
branch__status=BranchStatusChoices.READY
).update(
last_updated=timezone.now(),
current=instance.postchange_data_clean
)

# If this is a branch-aware change, create or update ChangeDiff for this object.
else:
Expand Down
Loading