Skip to content

Commit

Permalink
Handle incorrect license "sa" as "by-sa".
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Apr 29, 2024
1 parent a1252b3 commit 61ddc9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/api/models/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions api/api/serializers/media_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions api/api/utils/watermark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 61ddc9a

Please sign in to comment.