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

Could not find attachment fix with filenames which contain non-latin characters. #4811

Merged
merged 9 commits into from Jan 24, 2024

Conversation

noliveleger
Copy link
Contributor

@noliveleger noliveleger commented Jan 19, 2024

Notes

JS uses the new added property question_xpath from data endpoint response to retrieve the correct attachment (instead of the attachment filename).
Back-end should only try to add the property on the fly it is missing (see kobotoolbox/kobocat#915). It should cover existing data.

Related issues

Related to #3659
Related to kobotoolbox/kobocat#915

Copy link
Member

@jnm jnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python code is fine to merge as-is, although I left one comment about a simplification of the LazyObject subclass into an instance of SimpleLazyObject 👌

@@ -18,6 +19,14 @@ def get_kobocat_storage():
return KobocatFileSystemStorage()


class DefaultKobocatStorage(LazyObject):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that this is only quasi-documented by Django. Seems safe to use, though 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second glance, the docstring for LazyObject says:

    By subclassing, you have the opportunity to intercept and alter the
    instantiation. If you don't need to do that, use SimpleLazyObject.

https://github.com/django/django/blob/90eae45b3818f6c6e74c2fcb972e2a692ade4c1e/django/utils/functional.py#L256-L257

Would this suffice?

default_kobocat_storage = SimpleLazyObject(get_kobocat_storage)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I've replicated what Django is doing to instantiate default_storage.

But your solution is great. It's "Simple" and there is less code. 💯

@noliveleger noliveleger requested a review from jnm January 23, 2024 15:09
@jamesrkiger jamesrkiger marked this pull request as ready for review January 23, 2024 18:07
Copy link
Contributor

@LMNTL LMNTL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Requested one small change and left a general comment.

jsapp/js/components/submissions/submissionUtils.ts Outdated Show resolved Hide resolved
Comment on lines 549 to 550
v = self.latest_deployed_version if deployed else self.latest_version
survey = v.to_formpack_schema()['content']['survey']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can mostly tell what this function is doing right now, so I don't think it's a huge deal, but adding (brand new) one-letter variables is a little scary. 😅

@LMNTL LMNTL merged commit b38e778 into release/2.023.52 Jan 24, 2024
4 checks passed
@LMNTL LMNTL deleted the fix-could-not-find-attachment branch January 24, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants