1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-11-26 21:27:11 +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()
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)
primary_author = authors[0]
@ -76,6 +76,15 @@ class MediaAdminForm(ModelForm):
if isbn_field:
isbn_field.widget.template_name = "media/isbn_button.html"
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):
"""

View File

@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -13,19 +13,20 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\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"
msgstr "auteurs"
#: admin.py:42
#: admin.py:44
msgid "external url"
msgstr "URL externe"
#: admin.py:98
#: admin.py:127
msgid "Turn back"
msgstr "Rendre"
#: admin.py:101 models.py:135
#: admin.py:130 models.py:407
msgid "given back to"
msgstr "rendu à"
@ -33,11 +34,11 @@ msgstr "rendu à"
msgid "ISBN-10 or ISBN-13"
msgstr "ISBN-10 ou ISBN-13"
#: forms.py:178
#: forms.py:244
msgid "This ISBN is not found."
msgstr "L'ISBN n'a pas été trouvé."
#: models.py:16 models.py:159
#: models.py:16 models.py:431
msgid "name"
msgstr "nom"
@ -49,123 +50,220 @@ msgstr "note"
msgid "author"
msgstr "auteur"
#: models.py:35 models.py:89
#: models.py:35 models.py:100 models.py:162 models.py:345
msgid "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."
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"
msgstr "titre"
#: models.py:46
#: models.py:48 models.py:113 models.py:175
msgid "subtitle"
msgstr "sous-titre"
#: models.py:52
#: models.py:54 models.py:119 models.py:181
msgid "external URL"
msgstr "URL externe"
#: models.py:57
#: models.py:59 models.py:124 models.py:186 models.py:229 models.py:268
msgid "side identifier"
msgstr "côte"
#: models.py:65
#: models.py:69 models.py:134 models.py:196
msgid "number of pages"
msgstr "nombre de pages"
#: models.py:70
#: models.py:75 models.py:140 models.py:202
msgid "publish date"
msgstr "date de publication"
#: models.py:82
msgid "medium"
msgstr "medium"
#: models.py:81 models.py:146 models.py:208 models.py:247 models.py:278
#: models.py:329 models.py:363
msgid "present"
msgstr "présent"
#: models.py:83
msgid "media"
msgstr "media"
#: models.py:82 models.py:147 models.py:209 models.py:248 models.py:279
#: models.py:330 models.py:364
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"
msgstr "medium à importer"
#: models.py:98
#: models.py:370
msgid "future media"
msgstr "medias à importer"
#: models.py:112
#: models.py:384
msgid "borrower"
msgstr "emprunteur"
#: models.py:115
#: models.py:387
msgid "borrowed on"
msgstr "emprunté le"
#: models.py:120
#: models.py:392
msgid "given back on"
msgstr "rendu le"
#: models.py:126
#: models.py:398
msgid "borrowed with"
msgstr "emprunté avec"
#: models.py:127
#: models.py:399
msgid "The keyholder that registered this borrowed item."
msgstr "Le permanencier qui enregistre cet emprunt."
#: models.py:136
#: models.py:408
msgid "The keyholder to whom this item was given back."
msgstr "Le permanencier à qui l'emprunt a été rendu."
#: models.py:143
#: models.py:415
msgid "borrowed item"
msgstr "emprunt"
#: models.py:144
#: models.py:416
msgid "borrowed items"
msgstr "emprunts"
#: models.py:164
#: models.py:436
msgid "owner"
msgstr "propriétaire"
#: models.py:169
#: models.py:441
msgid "duration"
msgstr "durée"
#: models.py:173
#: models.py:445
msgid "minimum number of players"
msgstr "nombre minimum de joueurs"
#: models.py:177
#: models.py:449
msgid "maximum number of players"
msgstr "nombre maximum de joueurs"
#: models.py:183
#: models.py:454
msgid "comment"
msgstr "commentaire"
#: models.py:190
#: models.py:461
msgid "game"
msgstr "jeu"
#: models.py:191
#: models.py:462
msgid "games"
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
msgid "Fetch data and add another"
msgstr "Télécharger les données et ajouter un nouveau medium"
#: templates/media/isbn_button.html:4
#, fuzzy
#| msgid "Fetch data"
msgid "Fetch only"
msgstr "Télécharger uniquement les données"
msgstr "Télécharger les données seulement"
#: validators.py:18
msgid "Invalid ISBN: Not a string"
@ -179,6 +277,12 @@ msgstr "ISBN invalide : mauvaise longueur"
msgid "Invalid ISBN: Only upper case allowed"
msgstr "ISBN invalide : seulement les majuscules sont autorisées"
#: views.py:44
#: views.py:50
msgid "Welcome to the Mediatek database"
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 %}
{% include "django/forms/widgets/input.html" %}
<input type="submit" value="{% trans "Fetch data and add another" %}" name="_isbn_addanother">
<input type="submit" value="{% trans "Fetch only" %}" name="_isbn">
<input type="button" value="{% trans "Fetch data and add another" %}" name="_isbn_addanother" onclick="form.submit()">
<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>
<p>
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>
</p>
</div>