diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 139c9ea..eda873a 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -84,6 +84,37 @@ class AdoptionNotice(models.Model): """Returns the url to access a detailed page for the animal.""" return reverse('adoption-notice-detail', args=[str(self.id)]) + def get_photos(self): + """ + First trys to get group photos that are attached to the adoption notice if there is none it trys to fetch + them from the animals + """ + group_photos = self.photos.all() + if len(group_photos) > 0: + return group_photos + else: + photos = [] + for animal in self.animals: + photos.extend(animal.photos.all()) + if len(photos) > 0: + return photos + + def get_photo(self): + """ + Returns the first photo it finds. + First trys to get group photos that are attached to the adoption notice if there is none it trys to fetch + them from the animals + """ + group_photos = self.photos.all() + if len(group_photos) > 0: + return group_photos[0] + else: + photos = [] + for animal in self.animals: + photos.extend(animal.photos.all()) + if len(photos) > 0: + return photos[0] + class Animal(models.Model): MALE_NEUTERED = "M_N" diff --git a/src/fellchensammlung/static/fellchensammlung/css/styles.css b/src/fellchensammlung/static/fellchensammlung/css/styles.css index f7a22cc..602b6f8 100644 --- a/src/fellchensammlung/static/fellchensammlung/css/styles.css +++ b/src/fellchensammlung/static/fellchensammlung/css/styles.css @@ -341,4 +341,23 @@ h1 { .card-photo img { max-width: 100%; border-radius: 10%; +} + +.adoption-notices { + display: flex; + flex-wrap: wrap; + list-style-type:none; +} + +.card-adoption-notice { + flex: 1 16%; + margin: 10px; + border-radius: 3%; + border: 4px grey solid; + padding: 5px; +} + +.card-adoption-notice img { + max-width: 100%; + border-radius: 10%; } \ No newline at end of file diff --git a/src/fellchensammlung/templates/fellchensammlung/list-adoption-notices.html b/src/fellchensammlung/templates/fellchensammlung/list-adoption-notices.html index a933222..5e97af0 100644 --- a/src/fellchensammlung/templates/fellchensammlung/list-adoption-notices.html +++ b/src/fellchensammlung/templates/fellchensammlung/list-adoption-notices.html @@ -1,12 +1,35 @@ {% load custom_tags %} -