add license/attribution info for episode images

This commit is contained in:
Trent Palmer 2021-03-16 14:43:22 -07:00
parent 4eabd16fa8
commit f83c931d19
3 changed files with 66 additions and 1 deletions

View File

@ -24,5 +24,8 @@ class EpisodeForm(forms.ModelForm):
model = Episode model = Episode
fields = [ fields = [
'title', 'author', 'pub_date', 'episode_number', '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'
] ]

View File

@ -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),
),
]

View File

@ -70,6 +70,25 @@ class Episode(UUIDAsIDModel):
storage=PublicImageStorage(), storage=PublicImageStorage(),
upload_to=slugify_file_name, upload_to=slugify_file_name,
null=True, blank=True) 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( mp3 = models.FileField(
storage=PublicMP3Storage(), storage=PublicMP3Storage(),
upload_to=slugify_file_name, upload_to=slugify_file_name,