mirror of
https://github.com/TrentSPalmer/trentpalmerdotorg.git
synced 2024-11-22 01:21:30 -08:00
add license/attribution for photos to feeds
This commit is contained in:
parent
389fb2729a
commit
4eabd16fa8
@ -5,3 +5,16 @@ LICENSE_CHOICES = [
|
|||||||
(4, 'CC BY-SA 3.0'),
|
(4, 'CC BY-SA 3.0'),
|
||||||
(5, 'CC BY 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')
|
||||||
|
@ -3,7 +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
|
from .choices import LICENSE_CHOICES, get_image_license_info
|
||||||
import string, random
|
import string, random
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +39,14 @@ class Feed(UUIDAsIDModel):
|
|||||||
original_image_url = models.URLField(max_length=255, default='')
|
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='')
|
||||||
|
|
||||||
|
@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):
|
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)
|
||||||
|
@ -28,6 +28,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-justify mt-2 mb-0">{{ i.description }}</p>
|
<p class="text-justify mt-2 mb-0">{{ i.description }}</p>
|
||||||
|
<a href="#{{ i.slug }}-attributions" data-toggle="collapse">license/attribution</a>
|
||||||
|
<div id="{{ i.slug }}-attributions" class="collapse">
|
||||||
|
Photo <a href="{{ i.original_image_url }}">{{ i.image_title }}</a> by
|
||||||
|
{% if i.image_attribution_url == '' %}
|
||||||
|
{{ i.image_attribution }}
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ i.image_attribution_url }}">{{ i.image_attribution }}</a>
|
||||||
|
{% endif %}
|
||||||
|
is licensed <a href="{{ i.image_license_url }}">{{ i.image_license_name }}</a>
|
||||||
|
{{ i.image_license_jurisdiction }}.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user