Skip to content

Commit

Permalink
Fix #1876. Keep many to many on delete for states
Browse files Browse the repository at this point in the history
  • Loading branch information
bctcvai committed Nov 25, 2024
1 parent 6e0b6e6 commit e631224
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/main/rest/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,19 @@ def delete_qs(self, params, qs):
f"Pedantic mode is enabled. Can not edit prior object {state.pk}, must only edit latest mark on version."
f"Object is mark {state.mark} of {state.latest_mark} for {state.version.name}/{state.elemental_id}"
)
old_media = state.media.all()
old_localizations = state.localizations.all()
state.pk = None
state.variant_deleted = True
origin_datetime = state.created_datetime
state.save()
found_it = State.objects.get(pk=state.pk)
# Keep original creation time
found_it.created_datetime = origin_datetime
found_it.save()
found_it.media.set(old_media)
found_it.localizations.set(old_localizations)
found_it.save()
obj_id = state.pk
log_changes(state, state.model_dict, state.project, self.request.user)
qs = Localization.objects.filter(pk__in=delete_localizations)
Expand Down

0 comments on commit e631224

Please sign in to comment.