Skip to content

Commit

Permalink
fix event slug being empty
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Nov 3, 2023
1 parent 0d30854 commit 631d373
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ephios/core/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __str__(self):
return str(self.title)

def get_canonical_slug(self):
return slugify(self.title)
return slugify(self.title) or str(self.id)

def get_absolute_url(self):
from django.urls import reverse
Expand Down
12 changes: 12 additions & 0 deletions tests/core/test_event_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ def test_slug_redirect(django_app, volunteer, event):
assert response.location # is a redirect
response = response.follow()
assert event.title in response


def test_event_slug_with_empty_name(django_app, volunteer, event):
event.title = ""
event.save()
response = django_app.get(
reverse("core:event_detail", kwargs=dict(pk=event.pk, slug="nottheactualslug")),
user=volunteer,
)
assert response.location # is a redirect
response = response.follow()
assert event.description in response

0 comments on commit 631d373

Please sign in to comment.