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

Set ISO date by parsing/converting free-form Expression publication date #25

Merged
merged 3 commits into from
Feb 14, 2024

Conversation

koeaw
Copy link
Collaborator

@koeaw koeaw commented Feb 12, 2024

Use dateparser library to update non-editable date field publication_date_iso whenever free-form publication_date field is changed:

  • override __init__ method for Expression entity to preserve current publication_date in variable
  • override save method – including when update_fields=... option is set to relevant fields – to parse/set the ISO date

Allowed date formats are set via Django's DATE_INPUT_FORMATS variable.

Set DATE_INPUT_FORMATS to formats likely to be used
by content creators (+ ISO date).
@koeaw koeaw changed the title Parse/convert publication date Set ISO date by parsing/converting free-form Expression publication date Feb 12, 2024
@koeaw
Copy link
Collaborator Author

koeaw commented Feb 12, 2024

@b1rger Could I ask you to look this over? Does this implementation make sense or is there a better way to do this?

As said elsewhere, we'll have two fields for storing dates:

  • one meant to be filled in by content creators, which isn't an actual date field but a char field; this is also where incoming dates from Zotero will be saved (... which are strings which don't have to follow any particular formatting),
  • a proper DateField for the same piece of data, converted to ISO, so we'll be able to query/sort by date later on etc.

In our import scripts, we get_or_create entities, and my understanding is that using the save() method to do the conversion should cover both that and manual inputs via forms.

Derive ISO date from free-form publication_date
on saving Expressions.
@koeaw koeaw force-pushed the kk/feat/date_conversion branch from 7e6f6cd to 667d2cf Compare February 12, 2024 11:31
@b1rger
Copy link
Contributor

b1rger commented Feb 13, 2024

did not test it, but lgtm!

@koeaw
Copy link
Collaborator Author

koeaw commented Feb 14, 2024

did not test it, but lgtm!

Thank you!

@koeaw koeaw merged commit 624ecb1 into deploy Feb 14, 2024
1 check passed
@koeaw koeaw deleted the kk/feat/date_conversion branch March 12, 2024 12:23
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