1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-11-26 21:27:11 +00:00

Fix author sort

This commit is contained in:
Yohann D'ANELLO 2020-02-10 17:35:07 +01:00
parent 70045d4e2d
commit 71a8aa065b

View File

@ -100,8 +100,9 @@ class MediaAdminForm(ModelForm):
if self.cleaned_data['authors']: if self.cleaned_data['authors']:
authors = self.cleaned_data['authors'] authors = self.cleaned_data['authors']
old_authors = authors.copy()
def sort(author): def sort(author):
return str(-author.note) + "." + author.name return str(-author.note) + "." + str(old_authors.index(author)) + "." + author.name
authors.sort(key=sort) authors.sort(key=sort)
author_name = self.cleaned_data['authors'][0].name author_name = self.cleaned_data['authors'][0].name
if ',' not in author_name and ' ' in author_name: if ',' not in author_name and ' ' in author_name: