Adds Timestamp Field#38
Merged
Merged
Conversation
Adds timestamp field to user form responses on generation. Signed-off-by: Hassan Abouelela <47495861+HassanAbouelela@users.noreply.github.com>
|
Thank you for contributing to Python Discord! Please check out the following documents:
|
ks129
suggested changes
Dec 17, 2020
Contributor
ks129
left a comment
There was a problem hiding this comment.
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>
ks129
reviewed
Dec 17, 2020
Co-authored-by: ks129 <45097959+ks129@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.