Merge branch 'cartons' of https://gitlab.crans.org/mediatek/med into cartons

This commit is contained in:
Alexandre Iooss 2020-08-13 08:18:30 +02:00
commit 4409911659
2 changed files with 16 additions and 4 deletions

View File

@ -88,6 +88,17 @@ class CDAdmin(VersionAdmin):
authors_list.short_description = _('authors') authors_list.short_description = _('authors')
class VinyleAdmin(VersionAdmin):
list_display = ('title', 'authors_list', 'side_identifier', 'rpm',)
search_fields = ('title', 'authors__name', 'side_identifier', 'rpm',)
autocomplete_fields = ('authors',)
def authors_list(self, obj):
return ", ".join([a.name for a in obj.authors.all()])
authors_list.short_description = _('authors')
class RevueAdmin(VersionAdmin): class RevueAdmin(VersionAdmin):
list_display = ('__str__', 'number', 'year', 'month', 'day', 'double',) list_display = ('__str__', 'number', 'year', 'month', 'day', 'double',)
search_fields = ('title', 'number', 'year',) search_fields = ('title', 'number', 'year',)
@ -141,7 +152,7 @@ admin_site.register(BD, MediaAdmin)
admin_site.register(Manga, MediaAdmin) 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, VinyleAdmin)
admin_site.register(Revue, RevueAdmin) 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)

View File

@ -34,14 +34,15 @@ class Command(BaseCommand):
continue continue
side = vinyle[0] side = vinyle[0]
title = vinyle[1] title = vinyle[1 if rpm == 33 else 2]
authors_str = vinyle[2].split('|') authors_str = vinyle[2 if rpm == 33 else 1]\
.split('|' if rpm == 33 else ';')
authors = [Auteur.objects.get_or_create(name=author)[0] authors = [Auteur.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 = Vinyle.objects.get_or_create(
title=title, title=title,
side_identifier=side, side_identifier=side,
rp=rpm, rpm=rpm,
) )
vinyle.authors.set(authors) vinyle.authors.set(authors)
vinyle.save() vinyle.save()