diff --git a/audio/choices.py b/audio/choices.py new file mode 100644 index 0000000..2f4da23 --- /dev/null +++ b/audio/choices.py @@ -0,0 +1,6 @@ +LICENSE_CHOICES = [ + (1, 'Public Domain'), + (2, 'Unknown'), + (3, 'CC BY-SA 2.5'), + (4, 'CC BY-SA 3.0') +] diff --git a/audio/forms.py b/audio/forms.py index 1742ac3..81155b2 100644 --- a/audio/forms.py +++ b/audio/forms.py @@ -7,7 +7,10 @@ class FeedForm(forms.ModelForm): class Meta: model = Feed fields = [ - 'title', 'author', 'description', 'image' + 'title', 'author', 'description', + 'image_title', 'image_attribution', 'image_attribution_url', + 'original_image_url', 'image_license', + 'image_license_jurisdiction', 'image' ] @@ -20,5 +23,6 @@ class EpisodeForm(forms.ModelForm): class Meta: model = Episode fields = [ - 'title', 'author', 'pub_date', 'episode_number', 'description', 'image', 'mp3' + 'title', 'author', 'pub_date', 'episode_number', + 'description', 'image', 'mp3' ] diff --git a/audio/migrations/0011_feed_image_license.py b/audio/migrations/0011_feed_image_license.py new file mode 100644 index 0000000..4b55ae0 --- /dev/null +++ b/audio/migrations/0011_feed_image_license.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.7 on 2021-03-16 16:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('audio', '0010_episode_episode_number'), + ] + + operations = [ + migrations.AddField( + model_name='feed', + name='image_license', + field=models.SmallIntegerField(choices=[(1, 'Public Domain'), (2, 'Unknown'), (3, 'CC BY-SA 2.5'), (4, 'CC BY-SA 3.0')], default=2), + ), + ] diff --git a/audio/migrations/0012_auto_20210316_1053.py b/audio/migrations/0012_auto_20210316_1053.py new file mode 100644 index 0000000..cd827c3 --- /dev/null +++ b/audio/migrations/0012_auto_20210316_1053.py @@ -0,0 +1,33 @@ +# Generated by Django 3.1.7 on 2021-03-16 17:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('audio', '0011_feed_image_license'), + ] + + operations = [ + migrations.AddField( + model_name='feed', + name='image_attribution', + field=models.CharField(default='', max_length=255), + ), + migrations.AddField( + model_name='feed', + name='image_attribution_url', + field=models.URLField(blank=True, max_length=255), + ), + migrations.AddField( + model_name='feed', + name='image_title', + field=models.CharField(default='', max_length=255), + ), + migrations.AddField( + model_name='feed', + name='original_image_url', + field=models.URLField(default='', max_length=255), + ), + ] diff --git a/audio/migrations/0013_feed_image_license_jurisdiction.py b/audio/migrations/0013_feed_image_license_jurisdiction.py new file mode 100644 index 0000000..d5f9f3e --- /dev/null +++ b/audio/migrations/0013_feed_image_license_jurisdiction.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.7 on 2021-03-16 17:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('audio', '0012_auto_20210316_1053'), + ] + + operations = [ + migrations.AddField( + model_name='feed', + name='image_license_jurisdiction', + field=models.TextField(default=''), + ), + ] diff --git a/audio/models.py b/audio/models.py index 591face..3ecb397 100644 --- a/audio/models.py +++ b/audio/models.py @@ -3,6 +3,7 @@ from tp.models import UUIDAsIDModel from django.contrib.auth.models import User from django.utils.text import slugify from tp.storage_backends import PublicImageStorage, PublicMP3Storage +from .choices import LICENSE_CHOICES import string, random @@ -28,6 +29,16 @@ class Feed(UUIDAsIDModel): upload_to=slugify_file_name, null=True, blank=True) + image_license = models.SmallIntegerField( + choices=LICENSE_CHOICES, + default=2, + ) + image_title = models.CharField(max_length=255, default='') + image_attribution = models.CharField(max_length=255, default='') + image_attribution_url = models.URLField(max_length=255, blank=True) + original_image_url = models.URLField(max_length=255, default='') + image_license_jurisdiction = models.TextField(null=False, default='') + def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(rand_slug() + "-" + self.title)