From e2d4a80dba3195b79b3997bdd1686096cb89dff0 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 23 May 2020 14:23:39 +0200 Subject: [PATCH] Store RPM in vinyles --- media/management/commands/import_vinyles.py | 7 +++++++ media/models.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/media/management/commands/import_vinyles.py b/media/management/commands/import_vinyles.py index 8fc6722..2c189a4 100644 --- a/media/management/commands/import_vinyles.py +++ b/media/management/commands/import_vinyles.py @@ -13,7 +13,13 @@ class Command(BaseCommand): default=stdin, help="Vinyle to be imported.") + parser.add_argument('--rpm', + type=int, + default=45, + help="RPM of the imported vinyles.") + def handle(self, *args, **options): + rpm = options["rpm"] file = options["input"] vinyles = [] for line in file: @@ -35,6 +41,7 @@ class Command(BaseCommand): vinyle, created = Vinyle.objects.get_or_create( title=title, side_identifier=side, + rp=rpm, ) vinyle.authors.set(authors) vinyle.save() diff --git a/media/models.py b/media/models.py index 428e601..3517445 100644 --- a/media/models.py +++ b/media/models.py @@ -218,6 +218,14 @@ class Vinyle(models.Model): max_length=255, ) + rpm = models.PositiveIntegerField( + verbose_name=_('rounds per minute'), + choices=[ + (33, _('33 RPM')), + (45, _('45 RPM')), + ], + ) + authors = models.ManyToManyField( 'Auteur', verbose_name=_('authors'),