From: Radek Czajka Date: Tue, 16 Mar 2021 13:06:40 +0000 (+0100) Subject: Add project icon, description. X-Git-Url: https://git.mdrn.pl/audio.git/commitdiff_plain/d34100c7ed69f83e552ec589fd0c353129165452?ds=sidebyside Add project icon, description. --- diff --git a/src/archive/admin.py b/src/archive/admin.py index d9b662b..10f1a33 100644 --- a/src/archive/admin.py +++ b/src/archive/admin.py @@ -1,4 +1,4 @@ -from archive.models import Project, Audiobook, Piece, License +from archive.models import Project, Audiobook, License from django.contrib import admin admin.site.register(Project) @@ -13,5 +13,4 @@ class AudiobookAdmin(admin.ModelAdmin): admin.site.register(Audiobook, AudiobookAdmin) -admin.site.register(Piece) admin.site.register(License) diff --git a/src/archive/migrations/0022_auto_20210316_1406.py b/src/archive/migrations/0022_auto_20210316_1406.py new file mode 100644 index 0000000..da9f59d --- /dev/null +++ b/src/archive/migrations/0022_auto_20210316_1406.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.2 on 2021-03-16 14:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('archive', '0021_merge_20210121_1251'), + ] + + operations = [ + migrations.DeleteModel( + name='Piece', + ), + migrations.AddField( + model_name='project', + name='icon', + field=models.FileField(blank=True, null=True, upload_to='archive/project'), + ), + ] diff --git a/src/archive/models.py b/src/archive/models.py index 03cd816..869641c 100644 --- a/src/archive/models.py +++ b/src/archive/models.py @@ -29,6 +29,7 @@ class Project(models.Model): sponsors = models.TextField(blank=True, null=True, verbose_name="Sponsorzy") description = models.TextField(blank=True, verbose_name="Opis") youtube = models.ForeignKey('youtube.YouTube', models.PROTECT) + icon = models.FileField(upload_to='archive/project', blank=True, null=True) class Meta: verbose_name = _("project") @@ -47,16 +48,6 @@ class Project(models.Model): ) -class Piece(models.Model): - name = models.CharField(max_length=255) - source_file = models.FileField(upload_to='piece') - is_outro = models.BooleanField(default=False) - min_audiobook_duration = models.IntegerField(default=0) - - def __str__(self): - return self.name - - def source_upload_to(intance, filename): return os.path.join(FILES_SAVE_PATH, filename) # FIXME: what about really long file names? diff --git a/src/archive/tasks.py b/src/archive/tasks.py index b5c64ce..17d98cc 100644 --- a/src/archive/tasks.py +++ b/src/archive/tasks.py @@ -80,6 +80,11 @@ class AudioFormatTask(Task): 'part_index': audiobook.index, 'parts_count': audiobook.parts_count, 'source_sha1': audiobook.source_sha1, + + 'project': { + 'description': audiobook.project.get_description(), + 'icon': audiobook.project.icon.url, + } } with open(path, 'rb') as f: api_call(user, UPLOAD_URL, data=data, files={