add license/attribution info for feed images

This commit is contained in:
Trent Palmer 2021-03-16 11:22:44 -07:00
parent ffa103e26c
commit 81281c1baf
6 changed files with 92 additions and 2 deletions

6
audio/choices.py Normal file
View File

@ -0,0 +1,6 @@
LICENSE_CHOICES = [
(1, 'Public Domain'),
(2, 'Unknown'),
(3, 'CC BY-SA 2.5'),
(4, 'CC BY-SA 3.0')
]

View File

@ -7,7 +7,10 @@ class FeedForm(forms.ModelForm):
class Meta: class Meta:
model = Feed model = Feed
fields = [ 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: class Meta:
model = Episode model = Episode
fields = [ fields = [
'title', 'author', 'pub_date', 'episode_number', 'description', 'image', 'mp3' 'title', 'author', 'pub_date', 'episode_number',
'description', 'image', 'mp3'
] ]

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ from tp.models import UUIDAsIDModel
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils.text import slugify from django.utils.text import slugify
from tp.storage_backends import PublicImageStorage, PublicMP3Storage from tp.storage_backends import PublicImageStorage, PublicMP3Storage
from .choices import LICENSE_CHOICES
import string, random import string, random
@ -28,6 +29,16 @@ class Feed(UUIDAsIDModel):
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='')
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.slug: if not self.slug:
self.slug = slugify(rand_slug() + "-" + self.title) self.slug = slugify(rand_slug() + "-" + self.title)