feat: Show short description for ANs with one picture
This commit is contained in:
		@@ -6,6 +6,7 @@ from django.utils import timezone
 | 
			
		||||
from django.contrib.auth.models import Group
 | 
			
		||||
from django.contrib.auth.models import AbstractUser
 | 
			
		||||
from django.core.exceptions import ValidationError
 | 
			
		||||
from docutils.nodes import description
 | 
			
		||||
 | 
			
		||||
from .tools import misc, geo
 | 
			
		||||
from notfellchen.settings import MEDIA_URL, base_url
 | 
			
		||||
@@ -444,12 +445,22 @@ class AdoptionNotice(models.Model):
 | 
			
		||||
        else:
 | 
			
		||||
            return self.location.latitude, self.location.longitude
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def description_short(self):
 | 
			
		||||
    def _get_short_description(self, length: int) -> str:
 | 
			
		||||
        if self.description is None:
 | 
			
		||||
            return ""
 | 
			
		||||
        if len(self.description) > 200:
 | 
			
		||||
            return self.description[:200] + f" ... [weiterlesen]({self.get_absolute_url()})"
 | 
			
		||||
        elif len(self.description) > length:
 | 
			
		||||
            return self.description[:length] + f" ... [weiterlesen]({self.get_absolute_url()})"
 | 
			
		||||
        else:
 | 
			
		||||
            return self.description
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def description_short(self):
 | 
			
		||||
        return self._get_short_description(200)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def description_100_short(self):
 | 
			
		||||
        return self._get_short_description(90)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def get_absolute_url(self):
 | 
			
		||||
        """Returns the url to access a detailed page for the adoption notice."""
 | 
			
		||||
 
 | 
			
		||||
@@ -234,7 +234,7 @@ IMAGES
 | 
			
		||||
 | 
			
		||||
.thumbnail img {
 | 
			
		||||
  width: 100%;
 | 
			
		||||
  height: 50px;
 | 
			
		||||
  height: 70px;
 | 
			
		||||
  object-fit: cover; /* Crops the images */
 | 
			
		||||
  border-radius: 4px;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -54,20 +54,27 @@
 | 
			
		||||
                        </a>
 | 
			
		||||
                    </div>
 | 
			
		||||
                {% endwith %}
 | 
			
		||||
 | 
			
		||||
                <div class="thumbnail-row minimal">
 | 
			
		||||
                    {% for photo in adoption_notice.get_photos|slice:"1:4" %}
 | 
			
		||||
                        <div class="thumbnail">
 | 
			
		||||
                            <a href="{{ MEDIA_URL }}{{ photo.image }}"
 | 
			
		||||
                               data-pswp-width="{{ photo.image.width }}"
 | 
			
		||||
                               data-pswp-height="{{ photo.image.height }}"
 | 
			
		||||
                               target="_blank">
 | 
			
		||||
                                <img src="{{ MEDIA_URL }}{{ photo.image }}"
 | 
			
		||||
                                     alt="{{ photo.alt_text }}">
 | 
			
		||||
                            </a>
 | 
			
		||||
                {% if adoption_notice.get_photos|length > 1 %}
 | 
			
		||||
                    <div class="thumbnail-row minimal">
 | 
			
		||||
                        {% for photo in adoption_notice.get_photos|slice:"1:4" %}
 | 
			
		||||
                            <div class="thumbnail">
 | 
			
		||||
                                <a href="{{ MEDIA_URL }}{{ photo.image }}"
 | 
			
		||||
                                   data-pswp-width="{{ photo.image.width }}"
 | 
			
		||||
                                   data-pswp-height="{{ photo.image.height }}"
 | 
			
		||||
                                   target="_blank">
 | 
			
		||||
                                    <img src="{{ MEDIA_URL }}{{ photo.image }}"
 | 
			
		||||
                                         alt="{{ photo.alt_text }}">
 | 
			
		||||
                                </a>
 | 
			
		||||
                            </div>
 | 
			
		||||
                        {% endfor %}
 | 
			
		||||
                    </div>
 | 
			
		||||
                {% else %}
 | 
			
		||||
                    {% if adoption_notice.description_100_short %}
 | 
			
		||||
                        <div class="content">
 | 
			
		||||
                            {{ adoption_notice.description_100_short | render_markdown }}
 | 
			
		||||
                        </div>
 | 
			
		||||
                    {% endfor %}
 | 
			
		||||
                </div>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                {% endif %}
 | 
			
		||||
            </div>
 | 
			
		||||
        {% else %}
 | 
			
		||||
            {% if adoption_notice.description_short %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user