{% load static %} {% for post in items %} {% firstof post.id post.pk as post_id %}
{% with a=post.author %} {% if a %} {% firstof a.avatar as ava_url %} {% if ava_url %} {% else %} {% endif %} {% else %} {% endif %} {% endwith %}
{% if post.created_at %} {{ post.created_at_display }} {% endif %} {% if post.type == 'department' %} {% firstof post.department.name post.department_name as dept_name %} {% if dept_name %} · {{ dept_name }}{% endif %} {% endif %}
{% if post.pinned %} {% endif %}
{% if post.image %} {% firstof post.image.url post.image as img_url %} {% if img_url %}
{% if post_id %}{% endif %} {{ post.title|default:'Публикация' }}
{% endif %} {% endif %}

{% if post_id %} {{ post.title|default:"Без названия" }} {% else %} {{ post.title|default:"Без названия" }} {% endif %}

{% with body=post.body|default_if_none:"" %} {% if body|wordcount > 42 %}
{{ body|truncatewords:42 }}
{{ body|linebreaksbr }}
{% else %}
{{ body|linebreaksbr }}
{% endif %} {% endwith %}
{# ===== СКЛАДНОЙ БЛОК КОММЕНТАРИЕВ ===== #}
{% if post.comments_count %}
{% with last=post.last_comment_list|first %} {% if last %}
{% firstof last.author.id last.author.pk as last_author_id %} {% firstof last.author.get_full_name last.author.username "Сотрудник" %} ·
{{ last.text|truncatechars:220 }}
{% elif post.last_comment %} {% with lc=post.last_comment %}
{% if lc.author.id %} {{ lc.author.full_name|default:"Сотрудник" }} {% else %} {{ lc.author.full_name|default:"Сотрудник" }} {% endif %} ·
{{ lc.text|truncatechars:220 }}
{% endwith %} {% endif %} {% endwith %}
{% endif %} {% if user.is_authenticated and post_id %}
{% endif %}
{% empty %}
Пока нет новостей.
{% endfor %}