From: Radek Czajka Date: Tue, 12 May 2020 07:26:57 +0000 (+0200) Subject: Add custom project description. X-Git-Url: https://git.mdrn.pl/audio.git/commitdiff_plain/643076d4e5abfd6b870be867fe4ba9965437d0ed?ds=sidebyside Add custom project description. --- diff --git a/src/archive/migrations/0007_project_description.py b/src/archive/migrations/0007_project_description.py new file mode 100644 index 0000000..dc846c7 --- /dev/null +++ b/src/archive/migrations/0007_project_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.4 on 2020-05-12 09:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('archive', '0006_piece'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='description', + field=models.TextField(blank=True, verbose_name='Opis'), + ), + ] diff --git a/src/archive/models.py b/src/archive/models.py index 51fc66c..34fc1f4 100644 --- a/src/archive/models.py +++ b/src/archive/models.py @@ -15,6 +15,7 @@ class Project(models.Model): name = models.CharField(max_length=128, unique=True, db_index=True, verbose_name="Nazwa") sponsors = models.TextField(blank=True, null=True, verbose_name="Sponsorzy") + description = models.TextField(blank=True, verbose_name="Opis") class Meta: verbose_name = _("project") @@ -24,6 +25,14 @@ class Project(models.Model): def __str__(self): return self.name + def get_description(self): + if self.description: + return self.description + return "Audiobook nagrany w ramach projektu %s%s." % ( + self.name, + " finansowanego przez %s" % self.sponsors if self.sponsors else "", + ) + class Piece(models.Model): name = models.CharField(max_length=255) @@ -116,10 +125,10 @@ class Audiobook(models.Model): copyright = "%s %s. Licensed to the public under %s verify at %s" % ( self.date, ORGANIZATION, LICENSE, self.url) - comment = "Audiobook nagrany w ramach projektu %s%s.\n%s" % ( - self.project.name, - " finansowanego przez %s" % self.project.sponsors if self.project.sponsors else "", - ADVERT) + comment = "\n".join(( + self.project.get_description(), + ADVERT + )) tags = { 'album': PROJECT, @@ -136,8 +145,10 @@ class Audiobook(models.Model): 'organization': ORGANIZATION, 'title': title, 'project': self.project.name, - 'funded_by': self.project.sponsors, } + if self.project.sponsors: + tags['funded_by'] = self.project.sponsors + if self.source_sha1: tags['flac_sha1'] = self.source_sha1 return tags