1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-25 06:22:23 +00:00

Better publish date

This commit is contained in:
Yohann D'ANELLO 2020-10-03 15:55:56 +02:00
parent dcba832549
commit 9dd2a142b7

View File

@ -108,7 +108,9 @@ class MediaAdminForm(ModelForm):
data.setdefault("authors", [])
data.setdefault("image", "")
self.cleaned_data["title"] = data["title"]
self.cleaned_data["published_date"] = data["date_published"][:10]
self.cleaned_data["publish_date"] = data["date_published"][:10]
while len(self.cleaned_data["publish_date"]) == 4 or len(self.cleaned_data["publish_date"]) == 7:
self.cleaned_data["publish_date"] += "-01"
self.cleaned_data["number_of_pages"] = data["pages"]
self.cleaned_data["authors"] = \
list(Auteur.objects.get_or_create(name=author_name)[0] for author_name in data["authors"])