diff --git a/audio/forms.py b/audio/forms.py index 81155b2..4c26409 100644 --- a/audio/forms.py +++ b/audio/forms.py @@ -24,5 +24,8 @@ class EpisodeForm(forms.ModelForm): model = Episode fields = [ 'title', 'author', 'pub_date', 'episode_number', - 'description', 'image', 'mp3' + 'description', 'mp3', + 'image_title', 'image_attribution', 'image_attribution_url', + 'original_image_url', 'image_license', + 'image_license_jurisdiction', 'image' ] diff --git a/audio/migrations/0015_auto_20210316_1440.py b/audio/migrations/0015_auto_20210316_1440.py new file mode 100644 index 0000000..e0749bf --- /dev/null +++ b/audio/migrations/0015_auto_20210316_1440.py @@ -0,0 +1,43 @@ +# Generated by Django 3.1.7 on 2021-03-16 21:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('audio', '0014_auto_20210316_1230'), + ] + + operations = [ + migrations.AddField( + model_name='episode', + name='image_attribution', + field=models.CharField(default='', max_length=255), + ), + migrations.AddField( + model_name='episode', + name='image_attribution_url', + field=models.URLField(blank=True, max_length=255), + ), + migrations.AddField( + model_name='episode', + name='image_license', + field=models.SmallIntegerField(choices=[(1, 'Public Domain'), (2, 'Unknown'), (3, 'CC BY-SA 2.5'), (4, 'CC BY-SA 3.0'), (5, 'CC BY 3.0')], default=2), + ), + migrations.AddField( + model_name='episode', + name='image_license_jurisdiction', + field=models.TextField(default=''), + ), + migrations.AddField( + model_name='episode', + name='image_title', + field=models.CharField(default='', max_length=255), + ), + migrations.AddField( + model_name='episode', + name='original_image_url', + field=models.URLField(default='', max_length=255), + ), + ] diff --git a/audio/models.py b/audio/models.py index 8d5833b..f3a3d86 100644 --- a/audio/models.py +++ b/audio/models.py @@ -70,6 +70,25 @@ class Episode(UUIDAsIDModel): storage=PublicImageStorage(), 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='') + + @property + def image_license_name(self): + return(get_image_license_info(self.image_license))[0] + + @property + def image_license_url(self): + return(get_image_license_info(self.image_license))[1] + mp3 = models.FileField( storage=PublicMP3Storage(), upload_to=slugify_file_name,