Add project icon, description.
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 16 Mar 2021 13:06:40 +0000 (14:06 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 16 Mar 2021 13:06:40 +0000 (14:06 +0100)
src/archive/admin.py
src/archive/migrations/0022_auto_20210316_1406.py [new file with mode: 0644]
src/archive/models.py
src/archive/tasks.py

index d9b662b..10f1a33 100644 (file)
@@ -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)
 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(Audiobook, AudiobookAdmin)
-admin.site.register(Piece)
 admin.site.register(License)
 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 (file)
index 0000000..da9f59d
--- /dev/null
@@ -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'),
+        ),
+    ]
index 03cd816..869641c 100644 (file)
@@ -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)
     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")
 
     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?
 
 def source_upload_to(intance, filename):
     return os.path.join(FILES_SAVE_PATH, filename) # FIXME: what about really long file names?
 
index b5c64ce..17d98cc 100644 (file)
@@ -80,6 +80,11 @@ class AudioFormatTask(Task):
             'part_index': audiobook.index,
             'parts_count': audiobook.parts_count,
             'source_sha1': audiobook.source_sha1,
             '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={
         }
         with open(path, 'rb') as f:
             api_call(user, UPLOAD_URL, data=data, files={