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

Add button to generate a side identifier

This commit is contained in:
Yohann D'ANELLO 2020-10-02 13:12:40 +02:00
parent 6f60de1838
commit 6985e39130
5 changed files with 162 additions and 46 deletions

View File

@ -40,7 +40,7 @@ def generate_side_identifier(title, authors, subtitle=None):
authors = authors.copy() authors = authors.copy()
def sort(author): def sort(author):
return str(-author.note) + author.name.split(" ")[-1] + ".{:05d}".format(author.pk) return "{:042d}".format(-author.note) + author.name.split(" ")[-1] + ".{:042d}".format(author.pk)
authors.sort(key=sort) authors.sort(key=sort)
primary_author = authors[0] primary_author = authors[0]
@ -76,6 +76,15 @@ class MediaAdminForm(ModelForm):
if isbn_field: if isbn_field:
isbn_field.widget.template_name = "media/isbn_button.html" isbn_field.widget.template_name = "media/isbn_button.html"
isbn_field.widget.attrs.update({'autofocus': 'autofocus'}) isbn_field.widget.attrs.update({'autofocus': 'autofocus'})
side_identifier_field = self.fields.get('side_identifier')
if side_identifier_field and self.instance and self.instance.pk:
instance = self.instance
title, authors, subtitle = instance.title, instance.authors.all(), None
if hasattr(instance, "subtitle"):
subtitle = instance.subtitle
side_identifier_field.widget.attrs.update(
{'data-generated-side-identifier': generate_side_identifier(title, authors, subtitle)})
side_identifier_field.widget.template_name = "media/generate_side_identifier.html"
def download_data_bedeteque(self, isbn): def download_data_bedeteque(self, isbn):
""" """

View File

@ -3,7 +3,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 17:42+0200\n" "POT-Creation-Date: 2020-10-02 13:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -13,19 +13,20 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: admin.py:32 models.py:29 models.py:62 #: admin.py:34 admin.py:89 admin.py:100 models.py:29 models.py:65 models.py:130
#: models.py:192 models.py:243 models.py:274
msgid "authors" msgid "authors"
msgstr "auteurs" msgstr "auteurs"
#: admin.py:42 #: admin.py:44
msgid "external url" msgid "external url"
msgstr "URL externe" msgstr "URL externe"
#: admin.py:98 #: admin.py:127
msgid "Turn back" msgid "Turn back"
msgstr "Rendre" msgstr "Rendre"
#: admin.py:101 models.py:135 #: admin.py:130 models.py:407
msgid "given back to" msgid "given back to"
msgstr "rendu à" msgstr "rendu à"
@ -33,11 +34,11 @@ msgstr "rendu à"
msgid "ISBN-10 or ISBN-13" msgid "ISBN-10 or ISBN-13"
msgstr "ISBN-10 ou ISBN-13" msgstr "ISBN-10 ou ISBN-13"
#: forms.py:178 #: forms.py:244
msgid "This ISBN is not found." msgid "This ISBN is not found."
msgstr "L'ISBN n'a pas été trouvé." msgstr "L'ISBN n'a pas été trouvé."
#: models.py:16 models.py:159 #: models.py:16 models.py:431
msgid "name" msgid "name"
msgstr "nom" msgstr "nom"
@ -49,123 +50,220 @@ msgstr "note"
msgid "author" msgid "author"
msgstr "auteur" msgstr "auteur"
#: models.py:35 models.py:89 #: models.py:35 models.py:100 models.py:162 models.py:345
msgid "ISBN" msgid "ISBN"
msgstr "ISBN" msgstr "ISBN"
#: models.py:36 models.py:90 #: models.py:36 models.py:101 models.py:163 models.py:346
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:42 #: models.py:43 models.py:108 models.py:170 models.py:224 models.py:263
#: models.py:294
msgid "title" msgid "title"
msgstr "titre" msgstr "titre"
#: models.py:46 #: models.py:48 models.py:113 models.py:175
msgid "subtitle" msgid "subtitle"
msgstr "sous-titre" msgstr "sous-titre"
#: models.py:52 #: models.py:54 models.py:119 models.py:181
msgid "external URL" msgid "external URL"
msgstr "URL externe" msgstr "URL externe"
#: models.py:57 #: models.py:59 models.py:124 models.py:186 models.py:229 models.py:268
msgid "side identifier" msgid "side identifier"
msgstr "côte" msgstr "côte"
#: models.py:65 #: models.py:69 models.py:134 models.py:196
msgid "number of pages" msgid "number of pages"
msgstr "nombre de pages" msgstr "nombre de pages"
#: models.py:70 #: models.py:75 models.py:140 models.py:202
msgid "publish date" msgid "publish date"
msgstr "date de publication" msgstr "date de publication"
#: models.py:82 #: models.py:81 models.py:146 models.py:208 models.py:247 models.py:278
msgid "medium" #: models.py:329 models.py:363
msgstr "medium" msgid "present"
msgstr "présent"
#: models.py:83 #: models.py:82 models.py:147 models.py:209 models.py:248 models.py:279
msgid "media" #: models.py:330 models.py:364
msgstr "media" msgid "Tell that the medium is present in the Mediatek."
msgstr "Indique que le medium est présent à la Mediatek."
#: models.py:97 #: models.py:93 models.py:355
msgid "BD"
msgstr "BD"
#: models.py:94
msgid "BDs"
msgstr "BDs"
#: models.py:155
msgid "manga"
msgstr "manga"
#: models.py:156
msgid "mangas"
msgstr "mangas"
#: models.py:217
msgid "roman"
msgstr "roman"
#: models.py:218
msgid "romans"
msgstr "romans"
#: models.py:234
msgid "rounds per minute"
msgstr "tours par minute"
#: models.py:236
msgid "33 RPM"
msgstr "33 TPM"
#: models.py:237
msgid "45 RPM"
msgstr "45 TPM"
#: models.py:256
msgid "vinyle"
msgstr "vinyle"
#: models.py:257
msgid "vinyles"
msgstr "vinyle"
#: models.py:287
msgid "CD"
msgstr "CD"
#: models.py:288
msgid "CDs"
msgstr "CDs"
#: models.py:299
msgid "number"
msgstr "nombre"
#: models.py:303
msgid "year"
msgstr "année"
#: models.py:310
msgid "month"
msgstr "mois"
#: models.py:317
msgid "day"
msgstr "jour"
#: models.py:324
msgid "double"
msgstr "double"
#: models.py:338
msgid "revue"
msgstr "revue"
#: models.py:339
msgid "revues"
msgstr "revues"
#: models.py:353
msgid "type"
msgstr "type"
#: models.py:356
msgid "Manga"
msgstr "Manga"
#: models.py:357
msgid "Roman"
msgstr "Roman"
#: models.py:369
msgid "future medium" msgid "future medium"
msgstr "medium à importer" msgstr "medium à importer"
#: models.py:98 #: models.py:370
msgid "future media" msgid "future media"
msgstr "medias à importer" msgstr "medias à importer"
#: models.py:112 #: models.py:384
msgid "borrower" msgid "borrower"
msgstr "emprunteur" msgstr "emprunteur"
#: models.py:115 #: models.py:387
msgid "borrowed on" msgid "borrowed on"
msgstr "emprunté le" msgstr "emprunté le"
#: models.py:120 #: models.py:392
msgid "given back on" msgid "given back on"
msgstr "rendu le" msgstr "rendu le"
#: models.py:126 #: models.py:398
msgid "borrowed with" msgid "borrowed with"
msgstr "emprunté avec" msgstr "emprunté avec"
#: models.py:127 #: models.py:399
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:136 #: models.py:408
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:143 #: models.py:415
msgid "borrowed item" msgid "borrowed item"
msgstr "emprunt" msgstr "emprunt"
#: models.py:144 #: models.py:416
msgid "borrowed items" msgid "borrowed items"
msgstr "emprunts" msgstr "emprunts"
#: models.py:164 #: models.py:436
msgid "owner" msgid "owner"
msgstr "propriétaire" msgstr "propriétaire"
#: models.py:169 #: models.py:441
msgid "duration" msgid "duration"
msgstr "durée" msgstr "durée"
#: models.py:173 #: models.py:445
msgid "minimum number of players" msgid "minimum number of players"
msgstr "nombre minimum de joueurs" msgstr "nombre minimum de joueurs"
#: models.py:177 #: models.py:449
msgid "maximum number of players" msgid "maximum number of players"
msgstr "nombre maximum de joueurs" msgstr "nombre maximum de joueurs"
#: models.py:183 #: models.py:454
msgid "comment" msgid "comment"
msgstr "commentaire" msgstr "commentaire"
#: models.py:190 #: models.py:461
msgid "game" msgid "game"
msgstr "jeu" msgstr "jeu"
#: models.py:191 #: models.py:462
msgid "games" msgid "games"
msgstr "jeux" msgstr "jeux"
#: templates/media/generate_side_identifier.html:3
msgid "Generate side identifier"
msgstr "Générer la cote"
#: templates/media/isbn_button.html:3 #: templates/media/isbn_button.html:3
msgid "Fetch data and add another" msgid "Fetch data and add another"
msgstr "Télécharger les données et ajouter un nouveau medium" msgstr "Télécharger les données et ajouter un nouveau medium"
#: templates/media/isbn_button.html:4 #: templates/media/isbn_button.html:4
#, fuzzy
#| msgid "Fetch data"
msgid "Fetch only" msgid "Fetch only"
msgstr "Télécharger uniquement les données" msgstr "Télécharger les données seulement"
#: validators.py:18 #: validators.py:18
msgid "Invalid ISBN: Not a string" msgid "Invalid ISBN: Not a string"
@ -179,6 +277,12 @@ msgstr "ISBN invalide : mauvaise longueur"
msgid "Invalid ISBN: Only upper case allowed" msgid "Invalid ISBN: Only upper case allowed"
msgstr "ISBN invalide : seulement les majuscules sont autorisées" msgstr "ISBN invalide : seulement les majuscules sont autorisées"
#: views.py:44 #: views.py:50
msgid "Welcome to the Mediatek database" msgid "Welcome to the Mediatek database"
msgstr "Bienvenue sur la base de données de la Mediatek" msgstr "Bienvenue sur la base de données de la Mediatek"
#~ msgid "medium"
#~ msgstr "medium"
#~ msgid "media"
#~ msgstr "media"

View File

@ -0,0 +1,3 @@
{% load i18n %}
{% include "django/forms/widgets/input.html" %}
<a href="#" class="button" onclick="document.getElementById('{{ widget.attrs.id }}').value = document.getElementById('{{ widget.attrs.id }}').getAttribute('data-generated-side-identifier')">{% trans "Generate side identifier" %}</a>

View File

@ -1,4 +1,4 @@
{% load i18n %} {% load i18n %}
{% include "django/forms/widgets/input.html" %} {% include "django/forms/widgets/input.html" %}
<input type="submit" value="{% trans "Fetch data and add another" %}" name="_isbn_addanother"> <input type="button" value="{% trans "Fetch data and add another" %}" name="_isbn_addanother" onclick="form.submit()">
<input type="submit" value="{% trans "Fetch only" %}" name="_isbn"> <input type="button" value="{% trans "Fetch only" %}" name="_isbn" onclick="form.submit()">

View File

@ -97,7 +97,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</form> </form>
<p> <p>
Mediatek 2017-2020 &mdash; Mediatek 2017-2020 &mdash;
<a href="mailto:club-med@crans.org">Nous contactez</a> &mdash; <a href="mailto:club-med@crans.org">Nous contacter</a> &mdash;
<a href="{% url "api-root" %}">Explorer l'API</a> <a href="{% url "api-root" %}">Explorer l'API</a>
</p> </p>
</div> </div>