1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2025-06-29 22:31:10 +02:00

Fixed publish date when there is only the year

This commit is contained in:
Yohann D'ANELLO
2020-02-10 19:33:34 +01:00
parent 92dc21f014
commit 343ab02874
2 changed files with 9 additions and 3 deletions

View File

@ -72,9 +72,12 @@ class MediaAdminForm(ModelForm):
"June", "July", "August", "September",
"October", "November", "December"]
split = data['publish_date'].replace(',', '').split(' ')
self.cleaned_data['publish_date'] = "{}-{:02d}-{:02d}" \
.format(split[2], months.index(split[0]) + 1,
int(split[1]), )
if len(split) == 1:
self.cleaned_data['publish_date'] = split[0] + "-01-01"
else:
self.cleaned_data['publish_date'] = "{}-{:02d}-{:02d}" \
.format(split[2], months.index(split[0]) + 1,
int(split[1]), )
if 'authors' in data:
if 'author' not in self.cleaned_data: