feat: Link adoption notices in list of them

This commit is contained in:
moanos [he/him] 2024-03-20 10:32:00 +01:00
parent c27c00c679
commit 29667c86b9
2 changed files with 5 additions and 1 deletions

View File

@ -81,6 +81,10 @@ class AdoptionNotice(models.Model):
def animals_list(self): def animals_list(self):
return self.animals.all() return self.animals.all()
def get_absolute_url(self):
"""Returns the url to access a detailed page for the animal."""
return reverse('adoption-notice-detail', args=[str(self.id)])
class Animal(models.Model): class Animal(models.Model):
MALE_NEUTERED = "M_N" MALE_NEUTERED = "M_N"

View File

@ -3,7 +3,7 @@
{% for adoption_notice in adoption_notices %} {% for adoption_notice in adoption_notices %}
<li> <li>
<div> <div>
<h1>{{ adoption_notice.name }}</h1> <h1><a href="{{ adoption_notice.get_absolute_url }}"> {{ adoption_notice.name }}</a></h1>
<p><b>Notfellchen:</b> {{ adoption_notice.animals.all|join_link:", " | safe }} <p><b>Notfellchen:</b> {{ adoption_notice.animals.all|join_link:", " | safe }}
<ul> <ul>
{% for animal in adoption_notice.animal_list %} {% for animal in adoption_notice.animal_list %}