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

Create Response controller #43

Closed
avishkar58 opened this issue Feb 7, 2019 · 0 comments
Closed

Create Response controller #43

avishkar58 opened this issue Feb 7, 2019 · 0 comments
Assignees
Labels
back-end Back-end work enhancement New feature or request

Comments

@avishkar58
Copy link
Contributor

avishkar58 commented Feb 7, 2019

Create a controller to handle saving and submitting of Responses as documented in the application process spec.

The controller should contain

  • A GET method that retrieves a response for a given event_id for the logged-in user. A serialized JSON response is returned of the form illustrated below.
  • A POST method that accepts a JSON serialized response and saves the response to the database. This will make use of the data model created in Create data model for Response and Answer #21. If a response already exists (the response_id is populated in the JSON received), it should be updated, else a new response should be inserted and the new ID returned.
  • A DELETE method that accepts a response_id and sets the is_withdrawn flag and the withdrawn_timestamp on the Response object

Definition of Done
This task is done when

  • A new controller exists in api/app/response/api.py implementing methods described above which communicate using JSON of the form illustrated below
  • Unit tests exist for the response api
  • Checks exist in the API to ensure that a user can only retrieve/update/delete their own responses

An example of the JSON serialization of the Response/Answer model (NOTE: The response_id field should only be populated if the user is updating their response)
{
"response_id": 1,
"answers": [
{"question_id": 1, "value": "answer 1"},
{"question_id": 2, "value": "stuff"),
{"question_id": 3, "value": "hello world")
],
"is_submitted": false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Back-end work enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant