1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-25 18:22:24 +00:00

Translate models in english

This commit is contained in:
Yohann D'ANELLO 2021-10-23 18:31:03 +02:00
parent 2a17a32d4c
commit 52ecd59bf6
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
21 changed files with 210 additions and 155 deletions

View File

@ -13,16 +13,16 @@ from .admin import admin_site
# API router # API router
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register(r'authors', media.views.AuteurViewSet) router.register(r'authors', media.views.AuthorViewSet)
router.register(r'media/bd', media.views.BDViewSet) router.register(r'media/bd', media.views.ComicViewSet)
router.register(r'media/manga', media.views.MangaViewSet) router.register(r'media/manga', media.views.MangaViewSet)
router.register(r'media/cd', media.views.CDViewSet) router.register(r'media/cd', media.views.CDViewSet)
router.register(r'media/vinyle', media.views.VinyleViewSet) router.register(r'media/vinyle', media.views.VinylViewSet)
router.register(r'media/roman', media.views.RomanViewSet) router.register(r'media/novel', media.views.NovelViewSet)
router.register(r'media/revue', media.views.RevueViewSet) router.register(r'media/revue', media.views.ReviewViewSet)
router.register(r'media/future', media.views.FutureMediaViewSet) router.register(r'media/future', media.views.FutureMediumViewSet)
router.register(r'borrowed_items', media.views.EmpruntViewSet) router.register(r'borrowed_items', media.views.EmpruntViewSet)
router.register(r'games', media.views.JeuViewSet) router.register(r'games', media.views.GameViewSet)
router.register(r'users', users.views.UserViewSet) router.register(r'users', users.views.UserViewSet)
router.register(r'groups', users.views.GroupViewSet) router.register(r'groups', users.views.GroupViewSet)

View File

@ -9,8 +9,8 @@ from med.admin import admin_site
from reversion.admin import VersionAdmin from reversion.admin import VersionAdmin
from .forms import MediaAdminForm from .forms import MediaAdminForm
from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga,\ from .models import Author, CD, Comic, Emprunt, FutureMedium, Game, Manga,\
Revue, Roman, Vinyle Novel, Review, Vinyl
class AuteurAdmin(VersionAdmin): class AuteurAdmin(VersionAdmin):
@ -147,13 +147,13 @@ class JeuAdmin(VersionAdmin):
autocomplete_fields = ('proprietaire',) autocomplete_fields = ('proprietaire',)
admin_site.register(Auteur, AuteurAdmin) admin_site.register(Author, AuteurAdmin)
admin_site.register(BD, MediaAdmin) admin_site.register(Comic, MediaAdmin)
admin_site.register(Manga, MediaAdmin) admin_site.register(Manga, MediaAdmin)
admin_site.register(Roman, MediaAdmin) admin_site.register(Novel, MediaAdmin)
admin_site.register(CD, CDAdmin) admin_site.register(CD, CDAdmin)
admin_site.register(Vinyle, VinyleAdmin) admin_site.register(Vinyl, VinyleAdmin)
admin_site.register(Revue, RevueAdmin) admin_site.register(Review, RevueAdmin)
admin_site.register(FutureMedia, FutureMediaAdmin) admin_site.register(FutureMedium, FutureMediaAdmin)
admin_site.register(Emprunt, EmpruntAdmin) admin_site.register(Emprunt, EmpruntAdmin)
admin_site.register(Jeu, JeuAdmin) admin_site.register(Game, JeuAdmin)

View File

@ -13,7 +13,7 @@ from django.db.models import QuerySet
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from .models import Auteur, BD from .models import Author, Comic
from .scraper import BedetequeScraper from .scraper import BedetequeScraper
@ -123,7 +123,7 @@ class MediaAdminForm(ModelForm):
self.cleaned_data["publish_date"] += "-01" self.cleaned_data["publish_date"] += "-01"
self.cleaned_data["number_of_pages"] = data["pages"] self.cleaned_data["number_of_pages"] = data["pages"]
self.cleaned_data["authors"] = \ self.cleaned_data["authors"] = \
list(Auteur.objects.get_or_create(name=author_name)[0] list(Author.objects.get_or_create(name=author_name)[0]
for author_name in data["authors"]) for author_name in data["authors"])
self.cleaned_data["external_url"] = data["image"] self.cleaned_data["external_url"] = data["image"]
return True return True
@ -195,7 +195,7 @@ class MediaAdminForm(ModelForm):
if 'authors' in info: if 'authors' in info:
for author in info['authors']: for author in info['authors']:
author_obj = Auteur.objects.get_or_create( author_obj = Author.objects.get_or_create(
name=author)[0] name=author)[0]
self.cleaned_data['authors'].append(author_obj) self.cleaned_data['authors'].append(author_obj)
@ -269,7 +269,7 @@ class MediaAdminForm(ModelForm):
if 'authors' in data: if 'authors' in data:
for author in data['authors']: for author in data['authors']:
author_obj = Auteur.objects.get_or_create( author_obj = Author.objects.get_or_create(
name=author['name'])[0] name=author['name'])[0]
self.cleaned_data['authors'].append(author_obj) self.cleaned_data['authors'].append(author_obj)
@ -343,7 +343,7 @@ class MediaAdminForm(ModelForm):
self.add_error(name, e) self.add_error(name, e)
class Meta: class Meta:
model = BD model = Comic
fields = ('isbn', 'title', 'subtitle', 'external_url', fields = ('isbn', 'title', 'subtitle', 'external_url',
'side_identifier', 'authors', 'number_of_pages', 'side_identifier', 'authors', 'number_of_pages',
'publish_date', 'present', ) 'publish_date', 'present', )

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-10-02 13:02+0200\n" "POT-Creation-Date: 2021-10-23 18:27+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,20 +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:34 admin.py:89 admin.py:100 models.py:29 models.py:65 models.py:130 #: admin.py:33 admin.py:88 admin.py:99 models.py:29 models.py:65 models.py:130
#: models.py:192 models.py:243 models.py:274 #: models.py:192 models.py:243 models.py:274
msgid "authors" msgid "authors"
msgstr "auteurs" msgstr "auteurs"
#: admin.py:44 #: admin.py:43
msgid "external url" msgid "external url"
msgstr "URL externe" msgstr "URL externe"
#: admin.py:127 #: admin.py:126
msgid "Turn back" msgid "Turn back"
msgstr "Rendre" msgstr "Rendre"
#: admin.py:130 models.py:407 #: admin.py:129 models.py:407
msgid "given back to" msgid "given back to"
msgstr "rendu à" msgstr "rendu à"
@ -34,7 +34,7 @@ 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:244 #: forms.py:301
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é."
@ -94,11 +94,11 @@ msgid "Tell that the medium is present in the Mediatek."
msgstr "Indique que le medium est présent à la Mediatek." msgstr "Indique que le medium est présent à la Mediatek."
#: models.py:93 models.py:355 #: models.py:93 models.py:355
msgid "BD" msgid "Comic"
msgstr "BD" msgstr "BD"
#: models.py:94 #: models.py:94
msgid "BDs" msgid "Comics"
msgstr "BDs" msgstr "BDs"
#: models.py:155 #: models.py:155
@ -110,11 +110,11 @@ msgid "mangas"
msgstr "mangas" msgstr "mangas"
#: models.py:217 #: models.py:217
msgid "roman" msgid "novel"
msgstr "roman" msgstr "roman"
#: models.py:218 #: models.py:218
msgid "romans" msgid "novels"
msgstr "romans" msgstr "romans"
#: models.py:234 #: models.py:234
@ -130,12 +130,12 @@ msgid "45 RPM"
msgstr "45 TPM" msgstr "45 TPM"
#: models.py:256 #: models.py:256
msgid "vinyle" msgid "vinyl"
msgstr "vinyle" msgstr "vinyle"
#: models.py:257 #: models.py:257
msgid "vinyles" msgid "vinyls"
msgstr "vinyle" msgstr "vinyles"
#: models.py:287 #: models.py:287
msgid "CD" msgid "CD"
@ -166,11 +166,11 @@ msgid "double"
msgstr "double" msgstr "double"
#: models.py:338 #: models.py:338
msgid "revue" msgid "review"
msgstr "revue" msgstr "revue"
#: models.py:339 #: models.py:339
msgid "revues" msgid "reviews"
msgstr "revues" msgstr "revues"
#: models.py:353 #: models.py:353
@ -277,12 +277,6 @@ 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:50 #: views.py:51
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

@ -1,5 +1,5 @@
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.models import BD, CD, Manga, Revue, Roman, Vinyle, Jeu from media.models import Comic, CD, Manga, Review, Novel, Vinyl, Game
class Command(BaseCommand): class Command(BaseCommand):
@ -18,9 +18,9 @@ class Command(BaseCommand):
f.write("Ce site répertorie l'intégralité des media présents " f.write("Ce site répertorie l'intégralité des media présents "
"à la Mediatek de l'ENS Paris-Saclay.\n") "à la Mediatek de l'ENS Paris-Saclay.\n")
for model_class, file_name in [(BD, "bd.md"), (Manga, "mangas.md"), for model_class, file_name in [(Comic, "bd.md"), (Manga, "mangas.md"),
(Roman, "romans.md"), (Novel, "romans.md"),
(CD, "cd.md"), (Vinyle, "vinyles.md")]: (CD, "cd.md"), (Vinyl, "vinyles.md")]:
self.process_model_class(model_class, file_name, f, directory) self.process_model_class(model_class, file_name, f, directory)
# Traitement différent pour les revues # Traitement différent pour les revues
@ -28,13 +28,13 @@ class Command(BaseCommand):
f.write("# Revues\n\n\n") f.write("# Revues\n\n\n")
titles = list(set(obj["title"] for obj in titles = list(set(obj["title"] for obj in
Revue.objects.values("title").distinct().all())) Review.objects.values("title").distinct().all()))
titles.sort() titles.sort()
for title in titles: for title in titles:
f.write(f"## {title}\n\n\n") f.write(f"## {title}\n\n\n")
for medium in Revue.objects.filter(title=title)\ for medium in Review.objects.filter(title=title)\
.order_by("number").all(): .order_by("number").all():
f.write(f"### Numéro {medium.number}\n\n\n") f.write(f"### Numéro {medium.number}\n\n\n")
if medium.double: if medium.double:
@ -51,7 +51,7 @@ class Command(BaseCommand):
with open(directory + "/docs/jeux.md", "w") as f: with open(directory + "/docs/jeux.md", "w") as f:
f.write("# Jeux\n\n\n") f.write("# Jeux\n\n\n")
for game in Jeu.objects.order_by("name").all(): for game in Game.objects.order_by("name").all():
f.write(f"## {game.name}\n\n\n") f.write(f"## {game.name}\n\n\n")
f.write(f"Durée : {game.duree}\n\n") f.write(f"Durée : {game.duree}\n\n")
f.write(f"Nombre de joueurs : {game.nombre_joueurs_min} " f.write(f"Nombre de joueurs : {game.nombre_joueurs_min} "

View File

@ -2,7 +2,7 @@ from argparse import FileType
from sys import stdin from sys import stdin
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.models import Auteur, CD from media.models import Author, CD
class Command(BaseCommand): class Command(BaseCommand):
@ -29,7 +29,7 @@ class Command(BaseCommand):
title = cd[0] title = cd[0]
side = cd[1] side = cd[1]
authors_str = cd[2].split('|') authors_str = cd[2].split('|')
authors = [Auteur.objects.get_or_create(name=author)[0] authors = [Author.objects.get_or_create(name=author)[0]
for author in authors_str] for author in authors_str]
cd, created = CD.objects.get_or_create( cd, created = CD.objects.get_or_create(
title=title, title=title,

View File

@ -3,20 +3,20 @@ from time import sleep
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.forms import MediaAdminForm from media.forms import MediaAdminForm
from media.models import BD, FutureMedia, Manga, Roman from media.models import Comic, FutureMedium, Manga, Novel
class Command(BaseCommand): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
for future_medium in FutureMedia.objects.all(): for future_medium in FutureMedium.objects.all():
isbn = future_medium.isbn isbn = future_medium.isbn
type_str = future_medium.type type_str = future_medium.type
if type_str == 'bd': if type_str == 'bd':
cl = BD cl = Comic
elif type_str == 'manga': elif type_str == 'manga':
cl = Manga cl = Manga
elif type_str == 'roman': elif type_str == 'roman':
cl = Roman cl = Novel
else: else:
self.stderr.write(self.style.WARNING( self.stderr.write(self.style.WARNING(
"Unknown medium type: {type}. Ignoring..." "Unknown medium type: {type}. Ignoring..."

View File

@ -3,7 +3,7 @@ from sys import stdin
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.models import BD, FutureMedia, Manga, Roman from media.models import Comic, FutureMedium, Manga, Novel
from media.validators import isbn_validator from media.validators import isbn_validator
@ -27,7 +27,7 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
type_str = options["media_type"] type_str = options["media_type"]
media_classes = [BD, Manga, Roman, FutureMedia] media_classes = [Comic, Manga, Novel, FutureMedium]
file = options["input"] file = options["input"]
isbns = [] isbns = []
@ -70,7 +70,7 @@ class Command(BaseCommand):
if isbn_exists: if isbn_exists:
continue continue
FutureMedia.objects.create(isbn=isbn, type=type_str) FutureMedium.objects.create(isbn=isbn, type=type_str)
self.stdout.write(self.style.SUCCESS("ISBN {isbn} imported" self.stdout.write(self.style.SUCCESS("ISBN {isbn} imported"
.format(isbn=isbn))) .format(isbn=isbn)))
imported += 1 imported += 1

View File

@ -2,7 +2,7 @@ from argparse import FileType
from sys import stdin from sys import stdin
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.models import Auteur, BD from media.models import Author, Comic
class Command(BaseCommand): class Command(BaseCommand):
@ -28,9 +28,9 @@ class Command(BaseCommand):
title = revue[0] title = revue[0]
number = revue[1] number = revue[1]
authors = [Auteur.objects.get_or_create(name=n)[0] authors = [Author.objects.get_or_create(name=n)[0]
for n in revue[2].split('|')] for n in revue[2].split('|')]
bd = BD.objects.create( bd = Comic.objects.create(
title=title, title=title,
subtitle=number, subtitle=number,
side_identifier="{:.3} {:.3} {:0>2}" side_identifier="{:.3} {:.3} {:0>2}"

View File

@ -3,7 +3,7 @@ from sys import stdin
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.forms import generate_side_identifier from media.forms import generate_side_identifier
from media.models import Roman, Auteur from media.models import Novel, Author
class Command(BaseCommand): class Command(BaseCommand):
@ -28,10 +28,10 @@ class Command(BaseCommand):
continue continue
title = book[1] title = book[1]
authors = [Auteur.objects.get_or_create(name=n)[0] authors = [Author.objects.get_or_create(name=n)[0]
for n in book[0].split(';')] for n in book[0].split(';')]
side_identifier = generate_side_identifier(title, authors) side_identifier = generate_side_identifier(title, authors)
roman = Roman.objects.create( roman = Novel.objects.create(
title=title, title=title,
side_identifier=side_identifier, side_identifier=side_identifier,
) )

View File

@ -2,7 +2,7 @@ from argparse import FileType
from sys import stdin from sys import stdin
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.models import Revue from media.models import Review
class Command(BaseCommand): class Command(BaseCommand):
@ -37,7 +37,7 @@ class Command(BaseCommand):
year = revue[4] year = revue[4]
if not year: if not year:
year = None year = None
revue, created = Revue.objects.get_or_create( revue, created = Review.objects.get_or_create(
title=title, title=title,
number=number.replace('*', ''), number=number.replace('*', ''),
year=year, year=year,

View File

@ -2,7 +2,7 @@ from argparse import FileType
from sys import stdin from sys import stdin
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.models import Auteur, Vinyle from media.models import Author, Vinyl
class Command(BaseCommand): class Command(BaseCommand):
@ -36,9 +36,9 @@ class Command(BaseCommand):
title = vinyle[1 if rpm == 33 else 2] title = vinyle[1 if rpm == 33 else 2]
authors_str = vinyle[2 if rpm == 33 else 1]\ authors_str = vinyle[2 if rpm == 33 else 1]\
.split('|' if rpm == 33 else ';') .split('|' if rpm == 33 else ';')
authors = [Auteur.objects.get_or_create(name=author)[0] authors = [Author.objects.get_or_create(name=author)[0]
for author in authors_str] for author in authors_str]
vinyle, created = Vinyle.objects.get_or_create( vinyle, created = Vinyl.objects.get_or_create(
title=title, title=title,
side_identifier=side, side_identifier=side,
rpm=rpm, rpm=rpm,

View File

@ -1,7 +1,7 @@
from django.core.management import BaseCommand from django.core.management import BaseCommand
from django.db import transaction from django.db import transaction
from media.forms import generate_side_identifier from media.forms import generate_side_identifier
from media.models import BD, Manga, Roman from media.models import Comic, Manga, Novel
class Command(BaseCommand): class Command(BaseCommand):
@ -24,11 +24,11 @@ class Command(BaseCommand):
t = options["type"] t = options["type"]
medium_class = None medium_class = None
if t == "bd": if t == "bd":
medium_class = BD medium_class = Comic
elif t == "manga": elif t == "manga":
medium_class = Manga medium_class = Manga
elif t == "roman": elif t == "roman":
medium_class = Roman medium_class = Novel
interactive_mode = not options["noninteractivemode"] interactive_mode = not options["noninteractivemode"]

View File

@ -2,7 +2,7 @@ from time import sleep
from django.core.management import BaseCommand from django.core.management import BaseCommand
from media.forms import MediaAdminForm from media.forms import MediaAdminForm
from media.models import BD, Manga from media.models import Comic, Manga
class Command(BaseCommand): class Command(BaseCommand):
@ -14,7 +14,7 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
converted = 0 converted = 0
for media in BD.objects.all(): for media in Comic.objects.all():
if media.pk < 3400: if media.pk < 3400:
continue continue
# We sleep 5 seconds to avoid a ban from Bedetheque # We sleep 5 seconds to avoid a ban from Bedetheque

View File

@ -0,0 +1,61 @@
# Generated by Django 2.2.17 on 2021-10-23 16:30
from django.conf import settings
from django.db import migrations, models
import media.fields
import media.validators
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('media', '0039_mark_media_present'),
]
operations = [
migrations.RenameModel(
old_name='Auteur',
new_name='Author',
),
migrations.RenameModel(
old_name='Roman',
new_name='Comic',
),
migrations.RenameModel(
old_name='Jeu',
new_name='Game',
),
migrations.RenameModel(
old_name='BD',
new_name='Novel',
),
migrations.RenameModel(
old_name='Revue',
new_name='Review',
),
migrations.RenameModel(
old_name='Vinyle',
new_name='Vinyl',
),
migrations.RenameModel(
old_name='FutureMedia',
new_name='FutureMedium',
),
migrations.AlterModelOptions(
name='comic',
options={'ordering': ['title', 'subtitle'], 'verbose_name': 'comic', 'verbose_name_plural': 'comics'},
),
migrations.AlterModelOptions(
name='novel',
options={'ordering': ['title', 'subtitle'], 'verbose_name': 'novel', 'verbose_name_plural': 'novels'},
),
migrations.AlterModelOptions(
name='review',
options={'ordering': ['title', 'number'], 'verbose_name': 'review', 'verbose_name_plural': 'reviews'},
),
migrations.AlterModelOptions(
name='vinyl',
options={'ordering': ['title'], 'verbose_name': 'vinyl', 'verbose_name_plural': 'vinyls'},
),
]

View File

@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _
from .fields import ISBNField from .fields import ISBNField
class Auteur(models.Model): class Author(models.Model):
name = models.CharField( name = models.CharField(
max_length=255, max_length=255,
unique=True, unique=True,
@ -30,7 +30,7 @@ class Auteur(models.Model):
ordering = ['name'] ordering = ['name']
class BD(models.Model): class Comic(models.Model):
isbn = ISBNField( isbn = ISBNField(
_('ISBN'), _('ISBN'),
help_text=_('You may be able to scan it from a bar code.'), help_text=_('You may be able to scan it from a bar code.'),
@ -61,7 +61,7 @@ class BD(models.Model):
) )
authors = models.ManyToManyField( authors = models.ManyToManyField(
'Auteur', 'Author',
verbose_name=_('authors'), verbose_name=_('authors'),
) )
@ -90,8 +90,8 @@ class BD(models.Model):
return self.title return self.title
class Meta: class Meta:
verbose_name = _("BD") verbose_name = _("comic")
verbose_name_plural = _("BDs") verbose_name_plural = _("comics")
ordering = ['title', 'subtitle'] ordering = ['title', 'subtitle']
@ -126,7 +126,7 @@ class Manga(models.Model):
) )
authors = models.ManyToManyField( authors = models.ManyToManyField(
'Auteur', 'Author',
verbose_name=_('authors'), verbose_name=_('authors'),
) )
@ -157,7 +157,7 @@ class Manga(models.Model):
ordering = ['title'] ordering = ['title']
class Roman(models.Model): class Novel(models.Model):
isbn = ISBNField( isbn = ISBNField(
_('ISBN'), _('ISBN'),
help_text=_('You may be able to scan it from a bar code.'), help_text=_('You may be able to scan it from a bar code.'),
@ -188,7 +188,7 @@ class Roman(models.Model):
) )
authors = models.ManyToManyField( authors = models.ManyToManyField(
'Auteur', 'Author',
verbose_name=_('authors'), verbose_name=_('authors'),
) )
@ -214,12 +214,12 @@ class Roman(models.Model):
return self.title return self.title
class Meta: class Meta:
verbose_name = _("roman") verbose_name = _("novel")
verbose_name_plural = _("romans") verbose_name_plural = _("novels")
ordering = ['title', 'subtitle'] ordering = ['title', 'subtitle']
class Vinyle(models.Model): class Vinyl(models.Model):
title = models.CharField( title = models.CharField(
verbose_name=_('title'), verbose_name=_('title'),
max_length=255, max_length=255,
@ -239,7 +239,7 @@ class Vinyle(models.Model):
) )
authors = models.ManyToManyField( authors = models.ManyToManyField(
'Auteur', 'Author',
verbose_name=_('authors'), verbose_name=_('authors'),
) )
@ -253,8 +253,8 @@ class Vinyle(models.Model):
return self.title return self.title
class Meta: class Meta:
verbose_name = _("vinyle") verbose_name = _("vinyl")
verbose_name_plural = _("vinyles") verbose_name_plural = _("vinyls")
ordering = ['title'] ordering = ['title']
@ -270,7 +270,7 @@ class CD(models.Model):
) )
authors = models.ManyToManyField( authors = models.ManyToManyField(
'Auteur', 'Author',
verbose_name=_('authors'), verbose_name=_('authors'),
) )
@ -289,7 +289,7 @@ class CD(models.Model):
ordering = ['title'] ordering = ['title']
class Revue(models.Model): class Review(models.Model):
title = models.CharField( title = models.CharField(
verbose_name=_('title'), verbose_name=_('title'),
max_length=255, max_length=255,
@ -335,12 +335,12 @@ class Revue(models.Model):
return self.title + "" + str(self.number) return self.title + "" + str(self.number)
class Meta: class Meta:
verbose_name = _("revue") verbose_name = _("review")
verbose_name_plural = _("revues") verbose_name_plural = _("reviews")
ordering = ['title', 'number'] ordering = ['title', 'number']
class FutureMedia(models.Model): class FutureMedium(models.Model):
isbn = ISBNField( isbn = ISBNField(
_('ISBN'), _('ISBN'),
help_text=_('You may be able to scan it from a bar code.'), help_text=_('You may be able to scan it from a bar code.'),
@ -352,7 +352,7 @@ class FutureMedia(models.Model):
type = models.CharField( type = models.CharField(
_('type'), _('type'),
choices=[ choices=[
('bd', _('BD')), ('bd', _('Comic')),
('manga', _('Manga')), ('manga', _('Manga')),
('roman', _('Roman')), ('roman', _('Roman')),
], ],
@ -375,7 +375,7 @@ class FutureMedia(models.Model):
class Emprunt(models.Model): class Emprunt(models.Model):
media = models.ForeignKey( media = models.ForeignKey(
'BD', 'Comic',
on_delete=models.PROTECT, on_delete=models.PROTECT,
) )
user = models.ForeignKey( user = models.ForeignKey(
@ -417,7 +417,7 @@ class Emprunt(models.Model):
ordering = ['-date_emprunt'] ordering = ['-date_emprunt']
class Jeu(models.Model): class Game(models.Model):
DUREE = ( DUREE = (
('-1h', '-1h'), ('-1h', '-1h'),
('1-2h', '1-2h'), ('1-2h', '1-2h'),

View File

@ -4,7 +4,7 @@
import re import re
import requests import requests
from media.models import Auteur from media.models import Author
class BedetequeScraper: class BedetequeScraper:
@ -99,12 +99,12 @@ class BedetequeScraper:
if 'author' not in data: if 'author' not in data:
data['authors'] = list() data['authors'] = list()
if author: if author:
author_obj = Auteur.objects.get_or_create( author_obj = Author.objects.get_or_create(
name=author.group(1))[0] name=author.group(1))[0]
data['authors'].append(author_obj) data['authors'].append(author_obj)
illustrator = re.search(regex_illustrator, content) illustrator = re.search(regex_illustrator, content)
if illustrator: if illustrator:
author_obj = Auteur.objects.get_or_create( author_obj = Author.objects.get_or_create(
name=illustrator.group(1))[0] name=illustrator.group(1))[0]
data['authors'].append(author_obj) data['authors'].append(author_obj)

View File

@ -1,18 +1,18 @@
from rest_framework import serializers from rest_framework import serializers
from .models import Auteur, BD, CD, FutureMedia, Manga, Emprunt, Jeu, Revue,\ from .models import Author, CD, Comic, FutureMedium, Manga, Emprunt, Game, \
Roman, Vinyle Novel, Review, Vinyl
class AuteurSerializer(serializers.ModelSerializer): class AuthorSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Auteur model = Author
fields = ['url', 'name'] fields = ['url', 'name']
class BDSerializer(serializers.ModelSerializer): class ComicSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = BD model = Comic
fields = '__all__' fields = '__all__'
@ -28,27 +28,27 @@ class CDSerializer(serializers.ModelSerializer):
fields = '__all__' fields = '__all__'
class VinyleSerializer(serializers.ModelSerializer): class VinylSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Vinyle model = Vinyl
fields = '__all__' fields = '__all__'
class RomanSerializer(serializers.ModelSerializer): class NovelSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Roman model = Novel
fields = '__all__' fields = '__all__'
class RevueSerializer(serializers.ModelSerializer): class ReviewSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Revue model = Review
fields = '__all__' fields = '__all__'
class FutureMediaSerializer(serializers.ModelSerializer): class FutureMediumSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = FutureMedia model = FutureMedium
fields = '__all__' fields = '__all__'
@ -59,8 +59,8 @@ class EmpruntSerializer(serializers.HyperlinkedModelSerializer):
'permanencier_emprunt', 'permanencier_rendu'] 'permanencier_emprunt', 'permanencier_rendu']
class JeuSerializer(serializers.HyperlinkedModelSerializer): class GameSerializer(serializers.HyperlinkedModelSerializer):
class Meta: class Meta:
model = Jeu model = Game
fields = ['url', 'name', 'proprietaire', 'duree', 'nombre_joueurs_min', fields = ['url', 'name', 'proprietaire', 'duree', 'nombre_joueurs_min',
'nombre_joueurs_max', 'comment'] 'nombre_joueurs_max', 'comment']

View File

@ -3,7 +3,7 @@
from django.test import TestCase from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from media.models import Auteur, BD from media.models import Author, Comic
from users.models import User from users.models import User
""" """
@ -21,15 +21,15 @@ class TemplateTests(TestCase):
self.client.force_login(self.user) self.client.force_login(self.user)
# Create an author # Create an author
self.dummy_author = Auteur.objects.create(name="Test author") self.dummy_author = Author.objects.create(name="Test author")
# Create media # Create media
self.dummy_bd1 = BD.objects.create( self.dummy_bd1 = Comic.objects.create(
title="Test media", title="Test media",
side_identifier="T M", side_identifier="T M",
) )
self.dummy_bd1.authors.add(self.dummy_author) self.dummy_bd1.authors.add(self.dummy_author)
self.dummy_bd2 = BD.objects.create( self.dummy_bd2 = Comic.objects.create(
title="Test media bis", title="Test media bis",
side_identifier="T M 2", side_identifier="T M 2",
external_url="https://example.com/", external_url="https://example.com/",

View File

@ -13,7 +13,7 @@ urlpatterns = [
name='retour-emprunt'), name='retour-emprunt'),
path('find/', views.FindMediumView.as_view(), name="find"), path('find/', views.FindMediumView.as_view(), name="find"),
path('mark-as-present/bd/<int:pk>/', path('mark-as-present/bd/<int:pk>/',
views.MarkBDAsPresent.as_view(), views.MarkComicAsPresent.as_view(),
name="mark_bd_as_present"), name="mark_bd_as_present"),
path('mark-as-present/manga/<int:pk>/', path('mark-as-present/manga/<int:pk>/',
views.MarkMangaAsPresent.as_view(), views.MarkMangaAsPresent.as_view(),
@ -22,7 +22,7 @@ urlpatterns = [
views.MarkCDAsPresent.as_view(), views.MarkCDAsPresent.as_view(),
name="mark_cd_as_present"), name="mark_cd_as_present"),
path('mark-as-present/vinyle/<int:pk>/', path('mark-as-present/vinyle/<int:pk>/',
views.MarkVinyleAsPresent.as_view(), views.MarkVinylAsPresent.as_view(),
name="mark_vinyle_as_present"), name="mark_vinyle_as_present"),
path('mark-as-present/roman/<int:pk>/', path('mark-as-present/roman/<int:pk>/',
views.MarkRomanAsPresent.as_view(), views.MarkRomanAsPresent.as_view(),

View File

@ -16,11 +16,11 @@ from rest_framework import viewsets
from rest_framework.filters import SearchFilter from rest_framework.filters import SearchFilter
from reversion import revisions as reversion from reversion import revisions as reversion
from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga, Revue,\ from .models import Author, CD, Comic, Emprunt, FutureMedium, Game, Manga,\
Roman, Vinyle Novel, Review, Vinyl
from .serializers import AuteurSerializer, BDSerializer, CDSerializer,\ from .serializers import AuthorSerializer, ComicSerializer, CDSerializer,\
EmpruntSerializer, FutureMediaSerializer, JeuSerializer, MangaSerializer,\ EmpruntSerializer, FutureMediumSerializer, GameSerializer, \
RevueSerializer, RomanSerializer, VinyleSerializer MangaSerializer, NovelSerializer, ReviewSerializer, VinylSerializer
@login_required @login_required
@ -64,8 +64,8 @@ class MarkMediumAsPresent(LoginRequiredMixin, DetailView):
return HttpResponse("", content_type=204) return HttpResponse("", content_type=204)
class MarkBDAsPresent(MarkMediumAsPresent): class MarkComicAsPresent(MarkMediumAsPresent):
model = BD model = Comic
class MarkMangaAsPresent(MarkMediumAsPresent): class MarkMangaAsPresent(MarkMediumAsPresent):
@ -76,36 +76,36 @@ class MarkCDAsPresent(MarkMediumAsPresent):
model = CD model = CD
class MarkVinyleAsPresent(MarkMediumAsPresent): class MarkVinylAsPresent(MarkMediumAsPresent):
model = Vinyle model = Vinyl
class MarkRomanAsPresent(MarkMediumAsPresent): class MarkRomanAsPresent(MarkMediumAsPresent):
model = Roman model = Novel
class MarkRevueAsPresent(MarkMediumAsPresent): class MarkRevueAsPresent(MarkMediumAsPresent):
model = Revue model = Review
class MarkFutureAsPresent(MarkMediumAsPresent): class MarkFutureAsPresent(MarkMediumAsPresent):
model = FutureMedia model = FutureMedium
class AuteurViewSet(viewsets.ModelViewSet): class AuthorViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows authors to be viewed or edited. API endpoint that allows authors to be viewed or edited.
""" """
queryset = Auteur.objects.all() queryset = Author.objects.all()
serializer_class = AuteurSerializer serializer_class = AuthorSerializer
class BDViewSet(viewsets.ModelViewSet): class ComicViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows media to be viewed or edited. API endpoint that allows media to be viewed or edited.
""" """
queryset = BD.objects.all() queryset = Comic.objects.all()
serializer_class = BDSerializer serializer_class = ComicSerializer
filter_backends = [DjangoFilterBackend, SearchFilter] filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ["isbn", "side_identifier"] filterset_fields = ["isbn", "side_identifier"]
search_fields = ["=isbn", "title", "subtitle", "side_identifier", search_fields = ["=isbn", "title", "subtitle", "side_identifier",
@ -135,46 +135,46 @@ class CDViewSet(viewsets.ModelViewSet):
search_fields = ["title", "side_identifier", "authors__name"] search_fields = ["title", "side_identifier", "authors__name"]
class VinyleViewSet(viewsets.ModelViewSet): class VinylViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows media to be viewed or edited. API endpoint that allows media to be viewed or edited.
""" """
queryset = Vinyle.objects.all() queryset = Vinyl.objects.all()
serializer_class = VinyleSerializer serializer_class = VinylSerializer
filter_backends = [DjangoFilterBackend, SearchFilter] filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ["side_identifier", "rpm"] filterset_fields = ["side_identifier", "rpm"]
search_fields = ["title", "side_identifier", "authors__name"] search_fields = ["title", "side_identifier", "authors__name"]
class RomanViewSet(viewsets.ModelViewSet): class NovelViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows media to be viewed or edited. API endpoint that allows media to be viewed or edited.
""" """
queryset = Roman.objects.all() queryset = Novel.objects.all()
serializer_class = RomanSerializer serializer_class = NovelSerializer
filter_backends = [DjangoFilterBackend, SearchFilter] filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ["isbn", "side_identifier", "number_of_pages"] filterset_fields = ["isbn", "side_identifier", "number_of_pages"]
search_fields = ["=isbn", "title", "subtitle", "side_identifier", search_fields = ["=isbn", "title", "subtitle", "side_identifier",
"authors__name"] "authors__name"]
class RevueViewSet(viewsets.ModelViewSet): class ReviewViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows media to be viewed or edited. API endpoint that allows media to be viewed or edited.
""" """
queryset = Revue.objects.all() queryset = Review.objects.all()
serializer_class = RevueSerializer serializer_class = ReviewSerializer
filter_backends = [DjangoFilterBackend, SearchFilter] filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ["number", "year", "month", "day", "double"] filterset_fields = ["number", "year", "month", "day", "double"]
search_fields = ["title"] search_fields = ["title"]
class FutureMediaViewSet(viewsets.ModelViewSet): class FutureMediumViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows media to be viewed or edited. API endpoint that allows media to be viewed or edited.
""" """
queryset = FutureMedia.objects.all() queryset = FutureMedium.objects.all()
serializer_class = FutureMediaSerializer serializer_class = FutureMediumSerializer
filter_backends = [DjangoFilterBackend, SearchFilter] filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ["isbn"] filterset_fields = ["isbn"]
search_fields = ["=isbn"] search_fields = ["=isbn"]
@ -188,9 +188,9 @@ class EmpruntViewSet(viewsets.ModelViewSet):
serializer_class = EmpruntSerializer serializer_class = EmpruntSerializer
class JeuViewSet(viewsets.ModelViewSet): class GameViewSet(viewsets.ModelViewSet):
""" """
API endpoint that allows games to be viewed or edited. API endpoint that allows games to be viewed or edited.
""" """
queryset = Jeu.objects.all() queryset = Game.objects.all()
serializer_class = JeuSerializer serializer_class = GameSerializer