From 61ddc9aa466c5580d7c3e7c9c6a9a31dd166f6dd Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Mon, 29 Apr 2024 11:55:11 +0400 Subject: [PATCH] Handle incorrect license "sa" as "by-sa". --- api/api/models/media.py | 4 ++++ api/api/serializers/media_serializers.py | 2 ++ api/api/utils/watermark.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/api/api/models/media.py b/api/api/models/media.py index d95cb1846d2..437a5a1d364 100644 --- a/api/api/models/media.py +++ b/api/api/models/media.py @@ -100,6 +100,8 @@ def license_url(self) -> str: lic = self.license.lower() if lic == "publicdomain": lic = "pdm" + elif lic == "sa": + lic = "by-sa" return License(lic).url(self.license_version) @property @@ -109,6 +111,8 @@ def attribution(self) -> str: lic = self.license.lower() if lic == "publicdomain": lic = "pdm" + elif lic == "sa": + lic = "by-sa" return get_attribution_text( lic, self.title, diff --git a/api/api/serializers/media_serializers.py b/api/api/serializers/media_serializers.py index 84ecddf83d7..12476f075a4 100644 --- a/api/api/serializers/media_serializers.py +++ b/api/api/serializers/media_serializers.py @@ -744,6 +744,8 @@ def to_representation(self, *args, **kwargs): lic = output["license"] if lic == "publicdomain": lic = "pdm" + elif lic == "sa": + lic = "by-sa" output["license_url"] = License(lic).url(output["license_version"]) # Ensure URLs have scheme diff --git a/api/api/utils/watermark.py b/api/api/utils/watermark.py index 27c99706a2f..1adc5c14931 100644 --- a/api/api/utils/watermark.py +++ b/api/api/utils/watermark.py @@ -193,6 +193,8 @@ def _print_attribution_on_image(img: Image.Image, image_info): lic = image_info["license"] if lic == "publicdomain": lic = "pdm" + elif lic == "sa": + lic = "by-sa" text = get_attribution_text( lic, image_info["title"],