diff --git a/audio/choices.py b/audio/choices.py index 7362cdc..91bd1ac 100644 --- a/audio/choices.py +++ b/audio/choices.py @@ -5,3 +5,16 @@ LICENSE_CHOICES = [ (4, 'CC BY-SA 3.0'), (5, 'CC BY 3.0') ] + + +def get_image_license_info(x): + if x == 1: + return ('Public Domain', 'https://en.wikipedia.org/wiki/Public_domain') + if x == 2: + return ('Unknown', 'https://example.com') + if x == 3: + return ('CC BY-SA 2.5', 'https://creativecommons.org/licenses/by-sa/2.5') + if x == 4: + return ('CC BY-SA 3.0', 'https://creativecommons.org/licenses/by-sa/3.0') + if x == 5: + return ('CC BY 3.0', 'https://creativecommons.org/licenses/by/3.0') diff --git a/audio/models.py b/audio/models.py index 3ecb397..8d5833b 100644 --- a/audio/models.py +++ b/audio/models.py @@ -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 +from .choices import LICENSE_CHOICES, get_image_license_info import string, random @@ -39,6 +39,14 @@ class Feed(UUIDAsIDModel): 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] + def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(rand_slug() + "-" + self.title) diff --git a/audio/templates/audio/feeds.html b/audio/templates/audio/feeds.html index 15c0bb4..346e1c9 100644 --- a/audio/templates/audio/feeds.html +++ b/audio/templates/audio/feeds.html @@ -28,6 +28,17 @@

{{ i.description }}

+ license/attribution +
+ Photo {{ i.image_title }} by + {% if i.image_attribution_url == '' %} + {{ i.image_attribution }} + {% else %} + {{ i.image_attribution }} + {% endif %} + is licensed {{ i.image_license_name }} + {{ i.image_license_jurisdiction }}. +