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) self.download_data_openlibrary(isbn)
if self.cleaned_data['authors']: 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 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:
author_name = author_name.split(' ')[-1] author_name = author_name.split(' ')[-1]

View File

@ -41,103 +41,107 @@ msgstr "nom"
msgid "author" msgid "author"
msgstr "auteur" msgstr "auteur"
#: models.py:30 #: models.py:23
msgid "note"
msgstr "note"
#: models.py:35
msgid "ISBN" msgid "ISBN"
msgstr "ISBN" msgstr "ISBN"
#: models.py:31 #: models.py:36
msgid "You may be able to scan it from a bar code." msgid "You may be able to scan it from a bar code."
msgstr "Peut souvent être scanné à partir du code barre." msgstr "Peut souvent être scanné à partir du code barre."
#: models.py:36 #: models.py:41
msgid "title" msgid "title"
msgstr "titre" msgstr "titre"
#: models.py:40 #: models.py:45
msgid "subtitle" msgid "subtitle"
msgstr "sous-titre" msgstr "sous-titre"
#: models.py:46 #: models.py:51
msgid "external URL" msgid "external URL"
msgstr "URL externe" msgstr "URL externe"
#: models.py:51 #: models.py:56
msgid "side identifier" msgid "side identifier"
msgstr "côte" msgstr "côte"
#: models.py:59 #: models.py:64
msgid "number of pages" msgid "number of pages"
msgstr "nombre de pages" msgstr "nombre de pages"
#: models.py:64 #: models.py:69
msgid "publish date" msgid "publish date"
msgstr "date de publication" msgstr "date de publication"
#: models.py:76 #: models.py:81
msgid "medium" msgid "medium"
msgstr "medium" msgstr "medium"
#: models.py:77 #: models.py:82
msgid "media" msgid "media"
msgstr "media" msgstr "media"
#: models.py:89 #: models.py:94
msgid "borrower" msgid "borrower"
msgstr "emprunteur" msgstr "emprunteur"
#: models.py:92 #: models.py:97
msgid "borrowed on" msgid "borrowed on"
msgstr "emprunté le" msgstr "emprunté le"
#: models.py:97 #: models.py:102
msgid "given back on" msgid "given back on"
msgstr "rendu le" msgstr "rendu le"
#: models.py:103 #: models.py:108
msgid "borrowed with" msgid "borrowed with"
msgstr "emprunté avec" msgstr "emprunté avec"
#: models.py:104 #: models.py:109
msgid "The keyholder that registered this borrowed item." msgid "The keyholder that registered this borrowed item."
msgstr "Le permanencier qui enregistre cet emprunt." msgstr "Le permanencier qui enregistre cet emprunt."
#: models.py:113 #: models.py:118
msgid "The keyholder to whom this item was given back." msgid "The keyholder to whom this item was given back."
msgstr "Le permanencier à qui l'emprunt a été rendu." msgstr "Le permanencier à qui l'emprunt a été rendu."
#: models.py:120 #: models.py:125
msgid "borrowed item" msgid "borrowed item"
msgstr "emprunt" msgstr "emprunt"
#: models.py:121 #: models.py:126
msgid "borrowed items" msgid "borrowed items"
msgstr "emprunts" msgstr "emprunts"
#: models.py:141 #: models.py:146
msgid "owner" msgid "owner"
msgstr "propriétaire" msgstr "propriétaire"
#: models.py:146 #: models.py:151
msgid "duration" msgid "duration"
msgstr "durée" msgstr "durée"
#: models.py:150 #: models.py:155
msgid "minimum number of players" msgid "minimum number of players"
msgstr "nombre minimum de joueurs" msgstr "nombre minimum de joueurs"
#: models.py:154 #: models.py:159
msgid "maximum number of players" msgid "maximum number of players"
msgstr "nombre maximum de joueurs" msgstr "nombre maximum de joueurs"
#: models.py:160 #: models.py:165
msgid "comment" msgid "comment"
msgstr "commentaire" msgstr "commentaire"
#: models.py:167 #: models.py:172
msgid "game" msgid "game"
msgstr "jeu" msgstr "jeu"
#: models.py:168 #: models.py:173
msgid "games" msgid "games"
msgstr "jeux" msgstr "jeux"

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2020-02-10 16:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('media', '0024_auto_20190816_1356'),
]
operations = [
migrations.AddField(
model_name='auteur',
name='note',
field=models.IntegerField(default=0, verbose_name='note'),
),
]

View File

@ -16,6 +16,11 @@ class Auteur(models.Model):
verbose_name=_('name'), verbose_name=_('name'),
) )
note = models.IntegerField(
default=0,
verbose_name=_("note"),
)
def __str__(self): def __str__(self):
return self.name return self.name