Skip to content

Commit

Permalink
Update MR
Browse files Browse the repository at this point in the history
  • Loading branch information
MaertHaekkinen committed Oct 22, 2024
1 parent 605b581 commit 4bfa0ff
Show file tree
Hide file tree
Showing 3 changed files with 307 additions and 192 deletions.
8 changes: 5 additions & 3 deletions ajapaik/ajapaik/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ def _make_fullscreen(photo):


def _get_pseudo_slug_for_photo(description, source_key, id):
if description is not None and description != '':
slug = None

if description:
slug = '-'.join(slugify(description).split('-')[:6])[:60]
elif source_key is not None and source_key != '':
elif source_key and not slug:
slug = slugify(source_key)
else:
elif not slug:
slug = slugify(id)

return slug
Expand Down
5 changes: 3 additions & 2 deletions ajapaik/ajapaik/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ def __init__(self, *args, **kwargs):
def get_url(self, instance):
return reverse(
'image_thumb',
args=(instance.id, 400, _get_pseudo_slug_for_photo(instance.get_display_text, None, instance.id))
args=(
instance.id, 400, _get_pseudo_slug_for_photo(instance.get_display_text, instance.source_key, instance.id))
)

def get_permalink(self, instance):
return reverse(
'photo',
args=(instance.id, _get_pseudo_slug_for_photo(instance.get_display_text, None, instance.id))
args=(instance.id, _get_pseudo_slug_for_photo(instance.get_display_text, instance.source_key, instance.id))
)

def get_width(self, instance):
Expand Down
Loading

0 comments on commit 4bfa0ff

Please sign in to comment.