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

feat(form): multiple files in file questions #1809

Merged
merged 3 commits into from
Jul 5, 2022

Conversation

winged
Copy link
Contributor

@winged winged commented Jul 1, 2022

Change the model to allow multiple files per answer to be stored. Migrate
the existing questions to the new question type, and migrate the existing
answers to the new schema.

Updated the GraphQL schema to allow saving and updating multiple files
on an answer. The answer's value is a list of dicts, each containing
a file name, and optionally an ID. When you're creating new files,
add an entry without ID to the value. Caluma will then save the file,
and return it back WITH and ID.

BREAKING CHANGE: This renames the question type constant for file questions,
and changes the semantics of the answer value for file questions as well:
It is now a list of dicts instead of a single string. The response type
for querying file(s) answers now also is a list instead of a single dict.

For details / RFC see #1780

@winged winged force-pushed the feat_multi_file_question branch from acab7b1 to 0abb110 Compare July 4, 2022 07:23
winged added 2 commits July 4, 2022 10:14
The original Graphene API allows adding an `Input` (or, without Relay, a
`Arguments`) class to be added on mutation classes. Caluma derives it's
inputs solely from the attached serializer.

This fails if the required data type is more complex than what can
be represented on the serializer, whose most complex type is a list
of strings.

However, we need a list of well-defined objects, so we check on the
mutation class to see if a more specific field type is declared, and
use that one in the schema.
The reopen case mutation had a "required" ID in the schema, but when
regenerating, the requiredness was removed. Thus, adding an explicit
`required=True` to keep the semantics as has been.

Implicitly, the schema takes on the docstring of the `workItems` parameter
as well
@winged winged force-pushed the feat_multi_file_question branch 3 times, most recently from 3882d1c to 4552538 Compare July 4, 2022 08:27
@winged winged requested review from open-dynaMIX and fugal-dy July 4, 2022 08:28
@winged winged marked this pull request as ready for review July 4, 2022 08:28
@winged winged force-pushed the feat_multi_file_question branch 8 times, most recently from 99e6a2e to 48400b6 Compare July 4, 2022 12:48
Copy link
Contributor

@fugal-dy fugal-dy left a comment

Choose a reason for hiding this comment

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

LGTM as far as I can tell. relly just nitpickery

caluma/caluma_form/domain_logic.py Outdated Show resolved Hide resolved
caluma/caluma_form/tests/test_validators.py Outdated Show resolved Hide resolved
@winged winged force-pushed the feat_multi_file_question branch 3 times, most recently from 88e51e8 to 0ab8917 Compare July 4, 2022 17:14
Change the model to allow multiple files per answer to be stored. Migrate
the existing questions to the new question type, and migrate the existing
answers to the new schema.

Updated the GraphQL schema to allow saving and updating multiple files
on an answer. The answer's value is a list of dicts, each containing
a file name, and optionally an ID. When you're creating new files,
add an entry without ID to the value. Caluma will then save the file,
and return it back WITH and ID.

BREAKING CHANGE: This renames the question type constant for file questions,
and changes the semantics of the answer value for file questions as well:
It is now a list of dicts instead of a single string. The response type
for querying file(s) answers now also is a list instead of a single dict.
@winged winged force-pushed the feat_multi_file_question branch from 0ab8917 to 89ce59b Compare July 5, 2022 08:38
@winged winged enabled auto-merge July 5, 2022 08:39
@winged
Copy link
Contributor Author

winged commented Jul 5, 2022

Merging, as @open-dynaMIX approved off-github

@winged winged merged commit dc3a224 into projectcaluma:main Jul 5, 2022
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

Successfully merging this pull request may close these issues.

2 participants