Compare commits
No commits in common. "44abcaf20202c15ebd1b9bb3d6b725b9ee3435f9" and "3977ab9ec30a7908de1bafc1cba69bb69a92fda0" have entirely different histories.
44abcaf202
...
3977ab9ec3
|
@ -10,7 +10,7 @@ from reversion.admin import VersionAdmin
|
||||||
from med.admin import admin_site
|
from med.admin import admin_site
|
||||||
from .forms import MediaAdminForm
|
from .forms import MediaAdminForm
|
||||||
from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga,\
|
from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga,\
|
||||||
Revue, Roman, Vinyle
|
Roman, Vinyle
|
||||||
|
|
||||||
|
|
||||||
class AuteurAdmin(VersionAdmin):
|
class AuteurAdmin(VersionAdmin):
|
||||||
|
@ -88,11 +88,6 @@ class CDAdmin(VersionAdmin):
|
||||||
authors_list.short_description = _('authors')
|
authors_list.short_description = _('authors')
|
||||||
|
|
||||||
|
|
||||||
class RevueAdmin(VersionAdmin):
|
|
||||||
list_display = ('__str__', 'number', 'year', 'month', 'day', 'double',)
|
|
||||||
search_fields = ('title', 'number', 'year',)
|
|
||||||
|
|
||||||
|
|
||||||
class EmpruntAdmin(VersionAdmin):
|
class EmpruntAdmin(VersionAdmin):
|
||||||
list_display = ('media', 'user', 'date_emprunt', 'date_rendu',
|
list_display = ('media', 'user', 'date_emprunt', 'date_rendu',
|
||||||
'permanencier_emprunt', 'permanencier_rendu_custom')
|
'permanencier_emprunt', 'permanencier_rendu_custom')
|
||||||
|
@ -142,7 +137,6 @@ admin_site.register(Manga, MediaAdmin)
|
||||||
admin_site.register(Roman, MediaAdmin)
|
admin_site.register(Roman, MediaAdmin)
|
||||||
admin_site.register(CD, CDAdmin)
|
admin_site.register(CD, CDAdmin)
|
||||||
admin_site.register(Vinyle, CDAdmin)
|
admin_site.register(Vinyle, CDAdmin)
|
||||||
admin_site.register(Revue, RevueAdmin)
|
|
||||||
admin_site.register(FutureMedia, FutureMediaAdmin)
|
admin_site.register(FutureMedia, FutureMediaAdmin)
|
||||||
admin_site.register(Emprunt, EmpruntAdmin)
|
admin_site.register(Emprunt, EmpruntAdmin)
|
||||||
admin_site.register(Jeu, JeuAdmin)
|
admin_site.register(Jeu, JeuAdmin)
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
from argparse import FileType
|
|
||||||
from sys import stdin
|
|
||||||
|
|
||||||
from django.core.management import BaseCommand
|
|
||||||
from media.models import Auteur, BD
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
|
||||||
def add_arguments(self, parser):
|
|
||||||
parser.add_argument('input', nargs='?',
|
|
||||||
type=FileType('r'),
|
|
||||||
default=stdin,
|
|
||||||
help="Marvel comic to be imported.")
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
file = options["input"]
|
|
||||||
revues = []
|
|
||||||
for line in file:
|
|
||||||
revues.append(line[:-1].split('|', 2))
|
|
||||||
|
|
||||||
print("Registering", len(revues), "Marvel comics")
|
|
||||||
|
|
||||||
imported = 0
|
|
||||||
|
|
||||||
for revue in revues:
|
|
||||||
if len(revue) != 3:
|
|
||||||
continue
|
|
||||||
|
|
||||||
title = revue[0]
|
|
||||||
number = revue[1]
|
|
||||||
authors = [Auteur.objects.get_or_create(name=n)[0]
|
|
||||||
for n in revue[2].split('|')]
|
|
||||||
bd = BD.objects.create(
|
|
||||||
title=title,
|
|
||||||
subtitle=number,
|
|
||||||
side_identifier="{:.3} {:.3} {:0>2}"
|
|
||||||
.format(authors[0].name.upper(),
|
|
||||||
title.upper(),
|
|
||||||
number),
|
|
||||||
)
|
|
||||||
|
|
||||||
bd.authors.set(authors)
|
|
||||||
bd.save()
|
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS(
|
|
||||||
"Comic imported"))
|
|
||||||
imported += 1
|
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS(
|
|
||||||
"{count} comics imported".format(count=imported)))
|
|
|
@ -1,65 +0,0 @@
|
||||||
import re
|
|
||||||
import unicodedata
|
|
||||||
from argparse import FileType
|
|
||||||
from sys import stdin
|
|
||||||
|
|
||||||
from django.core.management import BaseCommand
|
|
||||||
|
|
||||||
from media.models import Auteur, Roman
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
|
||||||
def add_arguments(self, parser):
|
|
||||||
parser.add_argument('input', nargs='?',
|
|
||||||
type=FileType('r'),
|
|
||||||
default=stdin,
|
|
||||||
help="Revues to be imported.")
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
file = options["input"]
|
|
||||||
romans = []
|
|
||||||
for line in file:
|
|
||||||
romans.append(line[:-1].split('|'))
|
|
||||||
|
|
||||||
print("Registering", len(romans), "romans")
|
|
||||||
|
|
||||||
imported = 0
|
|
||||||
|
|
||||||
for book in romans:
|
|
||||||
if len(book) != 2:
|
|
||||||
continue
|
|
||||||
|
|
||||||
title = book[1]
|
|
||||||
title_normalized = title.upper()
|
|
||||||
title_normalized = title_normalized.replace('’', '\'')
|
|
||||||
title_normalized = ''.join(
|
|
||||||
char
|
|
||||||
for char in unicodedata.normalize(
|
|
||||||
'NFKD', title_normalized.casefold())
|
|
||||||
if all(not unicodedata.category(char).startswith(cat)
|
|
||||||
for cat in {'M', 'P', 'Z', 'C'}) or char == ' '
|
|
||||||
).casefold().upper()
|
|
||||||
title_normalized = re.sub(r'^LE ', '', title_normalized)
|
|
||||||
title_normalized = re.sub(r'^LA ', '', title_normalized)
|
|
||||||
title_normalized = re.sub(r'^LES ', '', title_normalized)
|
|
||||||
title_normalized = re.sub(r'^L\'', '', title_normalized)
|
|
||||||
title_normalized = re.sub(r'^THE ', '', title_normalized)
|
|
||||||
title_normalized = re.sub(r'Œ', 'OE', title_normalized)
|
|
||||||
title_normalized = title_normalized.replace(' ', '')
|
|
||||||
authors = [Auteur.objects.get_or_create(name=n)[0]
|
|
||||||
for n in book[0].split(';')]
|
|
||||||
side_identifier = "{:.3} {:.3}" \
|
|
||||||
.format(authors[0].name.upper(), title_normalized, )
|
|
||||||
roman = Roman.objects.create(
|
|
||||||
title=title,
|
|
||||||
side_identifier=side_identifier,
|
|
||||||
)
|
|
||||||
roman.authors.set(authors)
|
|
||||||
roman.save()
|
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS(
|
|
||||||
"Roman imported"))
|
|
||||||
imported += 1
|
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS(
|
|
||||||
"{count} romans imported".format(count=imported)))
|
|
|
@ -1,58 +0,0 @@
|
||||||
from argparse import FileType
|
|
||||||
from sys import stdin
|
|
||||||
|
|
||||||
from django.core.management import BaseCommand
|
|
||||||
from media.models import Revue
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
|
||||||
def add_arguments(self, parser):
|
|
||||||
parser.add_argument('input', nargs='?',
|
|
||||||
type=FileType('r'),
|
|
||||||
default=stdin,
|
|
||||||
help="Revues to be imported.")
|
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
|
||||||
file = options["input"]
|
|
||||||
revues = []
|
|
||||||
for line in file:
|
|
||||||
revues.append(line[:-1].split('|'))
|
|
||||||
|
|
||||||
print("Registering", len(revues), "revues")
|
|
||||||
|
|
||||||
imported = 0
|
|
||||||
|
|
||||||
for revue in revues:
|
|
||||||
if len(revue) != 5:
|
|
||||||
continue
|
|
||||||
|
|
||||||
title = revue[0]
|
|
||||||
number = revue[1]
|
|
||||||
day = revue[2]
|
|
||||||
if not day:
|
|
||||||
day = None
|
|
||||||
month = revue[3]
|
|
||||||
if not month:
|
|
||||||
month = None
|
|
||||||
year = revue[4]
|
|
||||||
if not year:
|
|
||||||
year = None
|
|
||||||
revue, created = Revue.objects.get_or_create(
|
|
||||||
title=title,
|
|
||||||
number=number.replace('*', ''),
|
|
||||||
year=year,
|
|
||||||
month=month,
|
|
||||||
day=day,
|
|
||||||
double=number.endswith('*'),
|
|
||||||
)
|
|
||||||
|
|
||||||
if not created:
|
|
||||||
self.stderr.write(self.style.WARNING(
|
|
||||||
"One revue was already imported. Skipping..."))
|
|
||||||
else:
|
|
||||||
self.stdout.write(self.style.SUCCESS(
|
|
||||||
"Revue imported"))
|
|
||||||
imported += 1
|
|
||||||
|
|
||||||
self.stdout.write(self.style.SUCCESS(
|
|
||||||
"{count} revues imported".format(count=imported)))
|
|
|
@ -1,29 +0,0 @@
|
||||||
# Generated by Django 2.2.10 on 2020-05-24 12:34
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('media', '0034_vinyle_rpm'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Revue',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('title', models.CharField(max_length=255, verbose_name='title')),
|
|
||||||
('number', models.PositiveIntegerField(verbose_name='number')),
|
|
||||||
('year', models.PositiveIntegerField(verbose_name='year')),
|
|
||||||
('month', models.PositiveIntegerField(blank=True, default=None, null=True, verbose_name='month')),
|
|
||||||
('day', models.PositiveIntegerField(blank=True, default=None, null=True, verbose_name='day')),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
'verbose_name': 'revue',
|
|
||||||
'verbose_name_plural': 'revues',
|
|
||||||
'ordering': ['title', 'number'],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 2.2.10 on 2020-05-24 13:00
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('media', '0035_revue'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='revue',
|
|
||||||
name='year',
|
|
||||||
field=models.PositiveIntegerField(blank=True, default=None, null=True, verbose_name='year'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 2.2.10 on 2020-05-24 13:36
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('media', '0036_auto_20200524_1500'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='revue',
|
|
||||||
name='double',
|
|
||||||
field=models.BooleanField(default=False, verbose_name='double'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -265,51 +265,6 @@ class CD(models.Model):
|
||||||
ordering = ['title']
|
ordering = ['title']
|
||||||
|
|
||||||
|
|
||||||
class Revue(models.Model):
|
|
||||||
title = models.CharField(
|
|
||||||
verbose_name=_('title'),
|
|
||||||
max_length=255,
|
|
||||||
)
|
|
||||||
|
|
||||||
number = models.PositiveIntegerField(
|
|
||||||
verbose_name=_('number'),
|
|
||||||
)
|
|
||||||
|
|
||||||
year = models.PositiveIntegerField(
|
|
||||||
verbose_name=_('year'),
|
|
||||||
null=True,
|
|
||||||
blank=True,
|
|
||||||
default=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
month = models.PositiveIntegerField(
|
|
||||||
verbose_name=_('month'),
|
|
||||||
null=True,
|
|
||||||
blank=True,
|
|
||||||
default=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
day = models.PositiveIntegerField(
|
|
||||||
verbose_name=_('day'),
|
|
||||||
null=True,
|
|
||||||
blank=True,
|
|
||||||
default=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
double = models.BooleanField(
|
|
||||||
verbose_name=_('double'),
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.title + " n°" + str(self.number)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _("revue")
|
|
||||||
verbose_name_plural = _("revues")
|
|
||||||
ordering = ['title', 'number']
|
|
||||||
|
|
||||||
|
|
||||||
class FutureMedia(models.Model):
|
class FutureMedia(models.Model):
|
||||||
isbn = ISBNField(
|
isbn = ISBNField(
|
||||||
_('ISBN'),
|
_('ISBN'),
|
||||||
|
|
Loading…
Reference in New Issue