Skip to content

Commit

Permalink
Fix Flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
WinnyTroy committed Feb 19, 2020
1 parent f98d2c7 commit c3af830
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion onadata/apps/logger/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def soft_delete(self, instance, user=None):
Soft deletes an attachment by adding a deleted_at timestamp.
"""
if instance:
queryset = self.__class__.objects.filter(name__in=self.get_expexted_media())
queryset = self.__class__.objects.filter(
name__in=self.get_expexted_media())
kwargs = {'deleted_at': timezone.now()}
if user:
kwargs.update({'deleted_by': user})
Expand Down
12 changes: 10 additions & 2 deletions onadata/libs/utils/logger_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ def create_instance(username,
(new_uuid or existing_instance.xform.has_start_time):
# ensure we have saved the extra attachments
with transaction.atomic():
save_attachments(xform, existing_instance, media_files, remove_deleted_media=True)
save_attachments(
xform,
existing_instance,
media_files,
remove_deleted_media=True)
existing_instance.save(update_fields=['json', 'date_modified'])

# Ignore submission as a duplicate IFF
Expand All @@ -338,7 +342,11 @@ def create_instance(username,
duplicate_instance = history.xform_instance
# ensure we have saved the extra attachments
with transaction.atomic():
save_attachments(xform, duplicate_instance, media_files, remove_deleted_media=True)
save_attachments(
xform,
duplicate_instance,
media_files,
remove_deleted_media=True)
duplicate_instance.save()

return DuplicateInstance()
Expand Down

0 comments on commit c3af830

Please sign in to comment.