From e1b56c9335e1b315fcce885d95a9d9d7a86fe566 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 21 May 2020 14:28:41 +0200 Subject: [PATCH 1/1] Set license constants. --- src/archive/settings.py | 16 ++++++++++++---- src/youtube/models.py | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/archive/settings.py b/src/archive/settings.py index 5c8e5f1..3e6f96f 100644 --- a/src/archive/settings.py +++ b/src/archive/settings.py @@ -55,10 +55,18 @@ try: except AttributeError: PROJECT = 'Wolne Lektury' -try: - LICENSE = settings.ARCHIVE_LICENSE -except AttributeError: - LICENSE = 'http://creativecommons.org/licenses/by-sa/3.0/deed.pl' + +LICENSE = getattr( + settings, + 'ARCHIVE_LICENSE', + 'http://artlibre.org/licence/lal/pl/' +) + +LICENSE_NAME = getattr( + settings, 'ARCHIVE_LICENSE_NAME', + 'Licencja Wolnej Sztuki 1.3' +) + try: ORGANIZATION = settings.ARCHIVE_ORGANIZATION diff --git a/src/youtube/models.py b/src/youtube/models.py index 576bf49..1a3fd01 100644 --- a/src/youtube/models.py +++ b/src/youtube/models.py @@ -1,6 +1,7 @@ import io from os import unlink from tempfile import NamedTemporaryFile +from django.conf import settings from django.db import models from django.utils.translation import gettext_lazy as _ from django.template import Template, Context @@ -42,7 +43,11 @@ class YouTube(models.Model): verbose_name_plural = _("YouTube configurations") def get_context(self, audiobook): - return Context(dict(audiobook=audiobook)) + return Context(dict( + audiobook=audiobook, + LICENSE=settings.LICENSE, + LICENSE_NAME=settings.LICENSE_NAME, + )) def get_description(self, audiobook): return Template(self.description_template).render(self.get_context(audiobook)) -- 2.20.1