diff --git a/district/models.py b/district/models.py index 3e3de7d732fd430e20f6288e81f91bcd40bf7eaa..da2863ecd55fbc4354742b4584ba6e86c7e5e8e1 100644 --- a/district/models.py +++ b/district/models.py @@ -389,11 +389,8 @@ class DistrictArticlePage( if not self.image and not self.thumb_image: raise ValidationError("Musí být nahraný buď obrázek nebo náhledový obrázek") - elif not self.thumb_image and self.image: - self.thumb_image = self.image - return cleaned_data - else: - return cleaned_data + + return cleaned_data def get_context(self, request): context = super().get_context(request) diff --git a/shared/templates/shared/article_preview.html b/shared/templates/shared/article_preview.html index d91ab7c884577edaf5ef6095624de42666f12aa5..3379cc9e0f3243e42beb58b6db95aed23d56c830 100644 --- a/shared/templates/shared/article_preview.html +++ b/shared/templates/shared/article_preview.html @@ -11,8 +11,13 @@ <div class="article-card-cover"> <a href="{{ article.url }}" itemprop="image" itemtype="http://schema.org/ImageObject" itemscope=""> - {% image article.thumb_image fill-356x192 as img %} - {% image article.thumb_image fill-714x384 as img_2x %} + {% if article.thumb_image %} + {% image article.thumb_image fill-356x192 as img %} + {% image article.thumb_image fill-714x384 as img_2x %} + {% else %} + {% image article.image fill-356x192 as img %} + {% image article.image fill-714x384 as img_2x %} + {% endif %} <img src="{{ img.url }}" srcset="{{ img.url }}, {{ img_2x.url }} 2x" @@ -46,7 +51,7 @@ <div class="article-card-meta c-metadata-block-section__item"> <span itemprop="description" class="article-card-meta__item"> {{ article.date|date:"SHORT_DATE_FORMAT" }} - <meta itemprop="datePublished" content="{{ article.last_published_at }}" /> + <meta itemprop="datePublished" content="{{ article.last_published_at }}"/> </span> {% if article.author %} <span class="article-card-meta__item" itemprop="author" itemtype="http://schema.org/Person" itemscope=""> @@ -68,14 +73,14 @@ {{ article.perex }} </p> <div class="inline-block-nogap mt-4"> - {% for tag in article.tags.all %} - <a - href="{{ articles_tag_page_url }}?tag={{ tag.slug }}" - class="btn article-card__category-button btn--condensed text-sm font-light btn--grey-{% if article.is_black %}700{% else %}125{% endif %} btn--hoveractive" - > - <div class="btn__body">{{ tag }}</div> - </a> - {% endfor %} + {% for tag in article.tags.all %} + <a + href="{{ articles_tag_page_url }}?tag={{ tag.slug }}" + class="btn article-card__category-button btn--condensed text-sm font-light btn--grey-{% if article.is_black %}700{% else %}125{% endif %} btn--hoveractive" + > + <div class="btn__body">{{ tag }}</div> + </a> + {% endfor %} </div> </div>