Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Method to download submission attachment (S3) urls from ODK Central#342

Merged
spwoodcock merged 9 commits intohotosm:mainfrom
Anuj-Gupta4:feat/submission-attachment-urls
Feb 12, 2025
Merged

Method to download submission attachment (S3) urls from ODK Central#342
spwoodcock merged 9 commits intohotosm:mainfrom
Anuj-Gupta4:feat/submission-attachment-urls

Conversation

@Anuj-Gupta4
Copy link
Copy Markdown
Contributor

Added and refactored submission related functionalities.

Test cases still need more work.

@github-actions github-actions Bot added enhancement New feature or request devops dependency Includes a dependency change labels Feb 7, 2025
@spwoodcock
Copy link
Copy Markdown
Member

I realised I made an error in the submission attachment URLs in my pyodk fork!

Original:

    _submission: str = "projects/{project_id}/forms/{form_id}/submissions/{{instance_id}}"
    list: str = f"{_submission}/attachments"
    get: str = f"{_submission}/attachments/{{fname}}"
    post: str = f"{_submission}/attachments/{{fname}}"
    delete: str = f"{_submission}/attachments/{{fname}}"

fixed:

    _submission: str = "projects/{project_id}/forms/{form_id}/submissions/{instance_id}"
    list: str = f"{_submission}/attachments"
    get: str = f"{_submission}/attachments/{{fname}}"
    post: str = f"{_submission}/attachments/{{fname}}"
    delete: str = f"{_submission}/attachments/{{fname}}"

The key here is that double curly braces are used in f-strings, but the _submission variable is not an f-string! I needed single braces for correct substitution. Without that fix, we always get 404 error when testing.

If you remove pyodk in this PR, then re-add it from source: https://github.com/hotosm/pyodk/tree/master-modified
then the functionality should all work 😄 (we can fix the pytest issues, and get this merged at some point 👍 )

@spwoodcock
Copy link
Copy Markdown
Member

The functionality works, but the tests are quite complex and have issues.

It was suggested we merge for now to get integrating this into FMTM, then retroactively fix the tests 👍

@spwoodcock spwoodcock marked this pull request as ready for review February 12, 2025 10:08
@spwoodcock
Copy link
Copy Markdown
Member

@Anuj-Gupta4 can I make a release based on this code do you think?

@Anuj-Gupta4
Copy link
Copy Markdown
Contributor Author

I think the functionality itself is good to go. 👍

@spwoodcock spwoodcock changed the title Submission attachment urls Method to download submission attachment (S3) urls from ODK Central Feb 12, 2025
@spwoodcock spwoodcock merged commit feddd88 into hotosm:main Feb 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dependency Includes a dependency change devops enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants