Skip to content

Commit

Permalink
Merge pull request #1820 from cvisionai/dev/fix_1819_delete_modified_by
Browse files Browse the repository at this point in the history
Fix #1819, Resolve modified_by on delete calls
  • Loading branch information
bctcvai authored Sep 18, 2024
2 parents c06c62a + c2f719d commit 87c5ff5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/main/rest/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,15 @@ def _delete(self, params):
qs,
params["project"],
self.request.user,
update_kwargs={"variant_deleted": True},
update_kwargs={"modified_by": self.request.user, "variant_deleted": True},
new_attributes=None,
)
else:
objs = []
for original in qs.iterator():
original.pk = None
original.id = None
original.modified_by = self.request.user
original.variant_deleted = True
objs.append(original)
Localization.objects.bulk_create(objs)
Expand Down Expand Up @@ -543,6 +544,7 @@ def delete_qs(self, params, qs):
b = qs[0]
b.pk = None
b.variant_deleted = True
b.modified_by = self.request.user
b.save()
obj_id = b.id
log_changes(b, b.model_dict, b.project, self.request.user)
Expand Down
4 changes: 3 additions & 1 deletion api/main/rest/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def _delete(self, params):
qs,
params["project"],
self.request.user,
update_kwargs={"variant_deleted": True},
update_kwargs={"variant_deleted": True, "modifed_by": self.request.user},
new_attributes=None,
)
else:
Expand All @@ -383,6 +383,7 @@ def _delete(self, params):
original.pk = None
original.id = None
original.variant_deleted = True
original.modified_by = self.request.user
objs.append(original)
State.objects.bulk_create(objs)

Expand Down Expand Up @@ -630,6 +631,7 @@ def patch_qs(self, params, qs):
obj.id = None
obj.pk = None
origin_datetime = obj.created_datetime
obj.modified_by = self.request.user
obj.save()
found_it = State.objects.get(pk=obj.pk)
# Keep original creation time
Expand Down

0 comments on commit 87c5ff5

Please sign in to comment.