add license/attribution for ebooks to feeds

This commit is contained in:
Trent Palmer 2021-03-17 11:28:51 -07:00
parent 0929fbf171
commit 27893d3afa
9 changed files with 222 additions and 11 deletions

View File

@ -8,7 +8,7 @@ LICENSE_CHOICES = [
]
def get_image_license_info(x):
def get_license_info(x):
if x == 1:
return ('Public Domain', 'https://en.wikipedia.org/wiki/Public_domain')
if x == 2:

View File

@ -7,9 +7,11 @@ class FeedForm(forms.ModelForm):
class Meta:
model = Feed
fields = [
'title', 'author', 'description',
'image_title', 'image_attribution', 'image_attribution_url',
'original_image_url', 'image_license',
'title', 'author', 'ebook_title', 'ebook_url',
'author_url', 'translator', 'translator_url',
'intro_author', 'intro_author_url', 'license', 'license_jurisdiction',
'description', 'image_title', 'image_attribution',
'image_attribution_url', 'original_image_url', 'image_license',
'image_license_jurisdiction', 'image'
]

View File

@ -0,0 +1,53 @@
# Generated by Django 3.1.7 on 2021-03-17 17:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('audio', '0016_auto_20210316_1624'),
]
operations = [
migrations.AddField(
model_name='feed',
name='author_url',
field=models.URLField(default='', max_length=255),
),
migrations.AddField(
model_name='feed',
name='ebook_url',
field=models.URLField(default='', max_length=255),
),
migrations.AddField(
model_name='feed',
name='intro_author',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='feed',
name='intro_author_url',
field=models.URLField(blank=True, max_length=255),
),
migrations.AddField(
model_name='feed',
name='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'), (6, 'CC BY 1.0')], default=1),
),
migrations.AddField(
model_name='feed',
name='license_jurisdiction',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='feed',
name='translator',
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='feed',
name='translator_url',
field=models.URLField(blank=True, max_length=255),
),
]

View File

@ -0,0 +1,38 @@
# Generated by Django 3.1.7 on 2021-03-17 17:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('audio', '0017_auto_20210317_1036'),
]
operations = [
migrations.AlterField(
model_name='feed',
name='intro_author',
field=models.CharField(default=None, max_length=255),
),
migrations.AlterField(
model_name='feed',
name='intro_author_url',
field=models.URLField(default=None, max_length=255),
),
migrations.AlterField(
model_name='feed',
name='license_jurisdiction',
field=models.TextField(blank=True, default=None),
),
migrations.AlterField(
model_name='feed',
name='translator',
field=models.CharField(default=None, max_length=255),
),
migrations.AlterField(
model_name='feed',
name='translator_url',
field=models.URLField(default=None, max_length=255),
),
]

View File

@ -0,0 +1,28 @@
# Generated by Django 3.1.7 on 2021-03-17 17:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('audio', '0018_auto_20210317_1043'),
]
operations = [
migrations.AlterField(
model_name='episode',
name='image_license_jurisdiction',
field=models.TextField(default='(no jurisdiction specified)'),
),
migrations.AlterField(
model_name='feed',
name='image_license_jurisdiction',
field=models.TextField(default='(no jurisdiction specified)'),
),
migrations.AlterField(
model_name='feed',
name='license_jurisdiction',
field=models.TextField(blank=True, default='(no jurisdiction specified)'),
),
]

View File

@ -0,0 +1,33 @@
# Generated by Django 3.1.7 on 2021-03-17 17:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('audio', '0019_auto_20210317_1046'),
]
operations = [
migrations.AlterField(
model_name='feed',
name='intro_author',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='feed',
name='intro_author_url',
field=models.URLField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='feed',
name='translator',
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name='feed',
name='translator_url',
field=models.URLField(blank=True, max_length=255),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.7 on 2021-03-17 18:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('audio', '0020_auto_20210317_1048'),
]
operations = [
migrations.AddField(
model_name='feed',
name='ebook_title',
field=models.URLField(default='', max_length=255),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.7 on 2021-03-17 18:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('audio', '0021_feed_ebook_title'),
]
operations = [
migrations.AlterField(
model_name='feed',
name='ebook_title',
field=models.CharField(default='', max_length=255),
),
]

View File

@ -3,7 +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, get_image_license_info
from .choices import LICENSE_CHOICES, get_license_info
import string, random
@ -37,15 +37,36 @@ class Feed(UUIDAsIDModel):
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='')
image_license_jurisdiction = models.TextField(null=False, default='(no jurisdiction specified)')
@property
def image_license_name(self):
return(get_image_license_info(self.image_license))[0]
return(get_license_info(self.image_license))[0]
@property
def image_license_url(self):
return(get_image_license_info(self.image_license))[1]
return(get_license_info(self.image_license))[1]
author_url = models.URLField(max_length=255, default='')
ebook_title = models.CharField(max_length=255, default='')
ebook_url = models.URLField(max_length=255, default='')
translator = models.CharField(max_length=255, blank=True)
translator_url = models.URLField(max_length=255, blank=True)
intro_author = models.CharField(max_length=255, blank=True)
intro_author_url = models.URLField(max_length=255, blank=True)
license_jurisdiction = models.TextField(blank=True, default='(no jurisdiction specified)')
license = models.SmallIntegerField(
choices=LICENSE_CHOICES,
default=1,
)
@property
def license_name(self):
return(get_license_info(self.image_license))[0]
@property
def license_url(self):
return(get_license_info(self.image_license))[1]
def save(self, *args, **kwargs):
if not self.slug:
@ -79,15 +100,15 @@ class Episode(UUIDAsIDModel):
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='')
image_license_jurisdiction = models.TextField(null=False, default='(no jurisdiction specified)')
@property
def image_license_name(self):
return(get_image_license_info(self.image_license))[0]
return(get_license_info(self.image_license))[0]
@property
def image_license_url(self):
return(get_image_license_info(self.image_license))[1]
return(get_license_info(self.image_license))[1]
mp3 = models.FileField(
storage=PublicMP3Storage(),