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

[ TASK-164 ] Do not use soft deleted attachments #4681

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions kpi/deployment_backends/kc_access/shadow_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@ class Meta(ShadowModel.Meta):
abstract = True


class ReadOnlyKobocatAttachmentManager(models.Manager):

def get_queryset(self):
return super().get_queryset().exclude(deleted_at__isnull=False)


class ReadOnlyKobocatAttachment(ReadOnlyModel, AudioTranscodingMixin):

class Meta(ReadOnlyModel.Meta):
Expand All @@ -541,9 +547,8 @@ class Meta(ReadOnlyModel.Meta):
mimetype = models.CharField(
max_length=100, null=False, blank=True, default=''
)
# TODO: hide attachments that were deleted or replaced; see
# kobotoolbox/kobocat#792
# replaced_at = models.DateTimeField(blank=True, null=True)
deleted_at = models.DateTimeField(blank=True, null=True, db_index=True)
objects = ReadOnlyKobocatAttachmentManager()

@property
def absolute_mp3_path(self):
Expand Down
8 changes: 1 addition & 7 deletions kpi/deployment_backends/kobocat_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,12 @@ def bulk_update_submissions(
)

# If `submission_ids` is not empty, user has partial permissions.
# Otherwise, they have have full access.
# Otherwise, they have full access.
if submission_ids:
partial_perms = True
# Reset query, because all the submission ids have been already
# retrieve
data['query'] = {}
else:
partial_perms = False
submission_ids = data['submission_ids']

submissions = self.get_submissions(
Expand Down Expand Up @@ -694,14 +692,10 @@ def get_attachment(
raise XPathNotFoundException

filters = {
# TODO: hide attachments that were deleted or replaced; see
# kobotoolbox/kobocat#792
# 'replaced_at': None,
'media_file_basename': attachment_filename,
}
else:
filters = {
# 'replaced_at': None,
'pk': attachment_id,
}

Expand Down
Loading