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

Add field to logger.Attachment that matches question response verbatim #803

Open
jnm opened this issue Mar 30, 2022 · 3 comments
Open

Add field to logger.Attachment that matches question response verbatim #803

jnm opened this issue Mar 30, 2022 · 3 comments
Assignees

Comments

@jnm
Copy link
Member

jnm commented Mar 30, 2022

From the OpenRosa Form Submission API specification:

Additional Parts

  • Content Type: arbitrary
  • Name: matches an appropriate element inside of the XForm Element's XML.

This means that if an XML submission contains:

<take_a_picture_of_your_shoes>Screenshot from 2022-03-30 12-12-56-12_13_3.png</take_a_picture_of_your_shoes>

…then the POST data should (eventually, because a single submission can be sent in multiple POSTs) contain a file with the identical name Screenshot from 2022-03-30 12-12-56-12_13_3.png. Great, all's well.

However, this file ends up being stored in the logger.Attachment model, where we and Django (see kobotoolbox/kpi#3659) do some transformations on the file name.

The result is that we do not have a good way to link the response to the take_a_picture_of_your_shoes question (as received in the XML but also stored in JSON), i.e. Screenshot from 2022-03-30 12-12-56-12_13_3.png, to its corresponding Attachment object and the media_file it contains.

We should add a new field on logger.Attachment that stores the verbatim question response. We could also take the opportunity to store the question XPath in the Attachment model as well (what do you think, @dorey?)

@jnm jnm self-assigned this Mar 30, 2022
@noliveleger
Copy link
Contributor

@jnm Or/and what about adding the question name in the _attachments list in Json response too?

@jnm jnm changed the title wip attachment model needs a field that verbatim matches the xml response Add field to logger.Attachment that matches question response verbatim Mar 30, 2022
@jnm
Copy link
Member Author

jnm commented Mar 30, 2022

@jnm Or/and what about adding the question name in the _attachments list in Json response too?

Aha, we were writing along the same lines 😄 I think perhaps we should use the XPath?

@Yann-J
Copy link

Yann-J commented Jun 15, 2022

Hello here... Interested in following up here, since currently using the API to retrieve attachments is ambiguous because of this.
Any idea of a timeline for adding this explicit attachment<>question linkage?
Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants