diff --git a/core/models/troggle.py b/core/models/troggle.py index 0977f84..9175eb6 100644 --- a/core/models/troggle.py +++ b/core/models/troggle.py @@ -95,6 +95,7 @@ class Person(TroggleModel): def get_absolute_url(self): # we do not use URL_ROOT any more. + return reverse("person", kwargs={"slug": self.slug}) return reverse("person", kwargs={"first_name": self.first_name, "last_name": self.last_name}) class Meta: diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 10a9bee..70fd89a 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -184,11 +184,14 @@ def better_person(request, name=""): def person( request, - first_name="", - last_name="", + slug="" ): - """Original code as it has been for years. Trying to replace with better_person() + """Original code as it has been for years. Trying to replace with better_person """ + + this_person = Person.objects.get(slug=slug) + return render(request, "person.html", {"person": this_person}) + try: this_person = Person.objects.get(first_name=first_name, last_name=last_name) except: diff --git a/templates/personexpedition.html b/templates/personexpedition.html index 2b035eb..af50b7c 100644 --- a/templates/personexpedition.html +++ b/templates/personexpedition.html @@ -20,7 +20,7 @@ {% endfor %}

Status of all wallets for -{{personexpedition.person.fullname}} +{{personexpedition.person.fullname}}

Table of all trips and surveys aligned by date

diff --git a/urls.py b/urls.py index 1ae6707..1611ef8 100644 --- a/urls.py +++ b/urls.py @@ -123,7 +123,8 @@ trogglepatterns = [ # Persons - nasty surname recognition logic fails for 19 people! See also Wallets by person below. # path('person/', person, name="person"), # This is much more complex than it looks.. - re_path(r'^person/(?P[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P[a-z\-\']*[^a-zA-Z]*[\-]*[A-Z]*[a-zA-Z\-&;]*)/?', person, name="person"), + path('person/', person, name="person"), + #re_path(r'^person/(?P[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P[a-z\-\']*[^a-zA-Z]*[\-]*[A-Z]*[a-zA-Z\-&;]*)/?', person, name="person"), #re_path(r'^personexpedition/(?P[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P[A-Z]*[a-zA-Z&;]*)/(?P\d+)/?$', personexpedition, name="personexpedition"), path('personexpedition//', personexpedition, name="personexpedition"),