Skip to content

Adds Timestamp Field#38

Merged
ks129 merged 3 commits into
mainfrom
submission-timestamp
Dec 17, 2020
Merged

Adds Timestamp Field#38
ks129 merged 3 commits into
mainfrom
submission-timestamp

Conversation

@HassanAbouelela
Copy link
Copy Markdown
Contributor

Closes this notion ticket.

Adds timestamp field to user form responses on model generation.

The model saves an ISO formatted time string to avoid serialization errors. The field is set by the program, even if a user passes the timestamp field.

Adds timestamp field to user form responses on generation.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
@HassanAbouelela HassanAbouelela added P1 High priority tasks. area: form submission Code relating to the response submission to forms backend. type: feature A new feature that should be added to the application. labels Dec 17, 2020
@ghost
Copy link
Copy Markdown

ghost commented Dec 17, 2020

Thank you for contributing to Python Discord!

Please check out the following documents:

@ghost ghost added the needs 1 approval label Dec 17, 2020
Copy link
Copy Markdown
Contributor

@ks129 ks129 left a comment

Choose a reason for hiding this comment

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

Current way doesn't work, because this overwrite datetime every time when model instance is created. Instance is also created when document is fetched:

https://github.com/python-discord/forms-backend/blob/main/backend/routes/forms/response.py#L27

Datetime must be provided by submit route. Parser should be @validator('timestamp', pre=True) and this should take datetime and return str.

As pointed out by @ks129, fetching the responses would cause an error in
 the timestamp, as the validation was returning the current time at
 fetching, instead of the stored value.

Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
Comment thread backend/models/form_response.py Outdated
Co-authored-by: ks129 <45097959+ks129@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@ks129 ks129 left a comment

Choose a reason for hiding this comment

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

Tested locally, works.

@ghost ghost removed the needs 1 approval label Dec 17, 2020
@ks129 ks129 merged commit 30af30b into main Dec 17, 2020
@ks129 ks129 deleted the submission-timestamp branch December 17, 2020 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: form submission Code relating to the response submission to forms backend. P1 High priority tasks. type: feature A new feature that should be added to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants