1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2025-07-07 09:44:01 +02:00

Add author note

This commit is contained in:
Yohann D'ANELLO
2020-02-10 17:27:30 +01:00
parent 11f0eff4d4
commit ea821483d0
4 changed files with 56 additions and 25 deletions

View File

@ -99,6 +99,10 @@ class MediaAdminForm(ModelForm):
self.download_data_openlibrary(isbn)
if self.cleaned_data['authors']:
authors: list = self.cleaned_data['authors']
def sort(author):
return str(-author.note) + "." + author.name
authors.sort(key=sort)
author_name = self.cleaned_data['authors'][0].name
if ',' not in author_name and ' ' in author_name:
author_name = author_name.split(' ')[-1]