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

2714 custom fields #2757

Merged
merged 9 commits into from
Jul 18, 2022
Merged

2714 custom fields #2757

merged 9 commits into from
Jul 18, 2022

Conversation

iamleeg
Copy link
Contributor

@iamleeg iamleeg commented Jul 18, 2022

This is the first part of extending the model in the data service with additional fields: adding those fields and storing descriptions in the DB. Still to come:

  • replay the stored fields on launch
  • watch the DB for new fields being added (so multiple instances of data-service can stay in sync)
  • integration tests to ensure that the case controller works with the updated fields correctly
  • remove fields
  • add fields that are lists of values
  • number types
  • validation
  • fields that are enumerations (with optional "other" free text entry)
  • indicate that a field is required (with a default value for migrating existing documents)
  • can GET the data dictionary

@iamleeg iamleeg merged commit 47d1725 into main Jul 18, 2022
@iamleeg iamleeg deleted the 2714_custom_fields branch July 18, 2022 13:15
try:
req = request.get_json()
schema_controller.add_field(req["name"], req["type"], req["description"])
return "", 201
Copy link
Collaborator

Choose a reason for hiding this comment

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

except ConflictError returns 409, except PreconditionUnsatisfiedError returns 400,
and except KeyError returns 400?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so KeyError shouldn't happen: that will come from Field.model_type if you try to use a field type that isn't in the allowed list. So we turn it into PreconditionUnsatisfiedError which is the same as when we explicitly check that the type isn't found in the allowed list: i.e. both exception paths mean the same thing so they result in the same error (400 bad request: you've asked for something we aren't going to let you do).

ConflictError does indeed result in a 409 Conflict status.

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.

3 participants