{% extends 'base.html' %} {% load static django_bootstrap5 %} {% block title %}{% firstof post.title "Публикация" %}{% endblock %} {% block content %} {% firstof post.id post.pk as post_id %} {% firstof post.author.id post.author.pk post.author_id as author_id %} {% firstof post.department.id post.department.pk post.department_id as dept_id %}
{% if post.type == 'company' %} К ленте {% elif post.type == 'department' and dept_id %} К отделу {% else %} {% if author_id %} К публикациям автора {% else %} К ленте {% endif %} {% endif %} {# Пин — без скобок в условии #} {% if post_id %} {% if post.type == 'company' and user.is_staff %} {% if post.pinned %}Открепить{% else %}Закрепить{% endif %} {% elif post.type == 'department' and dept_id %} {% if user.is_staff %} {% if post.pinned %}Открепить{% else %}Закрепить{% endif %} {% elif post.department and post.department.head_id == user.id %} {% if post.pinned %}Открепить{% else %}Закрепить{% endif %} {% endif %} {% endif %} {% endif %}
{% with a=post.author %} {% if a %} {% firstof a.avatar.url 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 %}
{% firstof post.title 'Публикация' %}
{% endif %} {% endif %}

{% firstof post.title "Без названия" %}

{{ post.body|linebreaks }}
{% if post.attachment %} {% firstof post.attachment.url post.attachment as att_url %} {% if att_url %} {% endif %} {% endif %}

Комментарии

({{ comments|length }})
{% if comments %}
{% for c in comments %} {% firstof c.id c.pk as cid %} {% firstof c.author.id c.author.pk c.author_id as c_author_id %} {% endfor %}
{% else %}
Пока нет комментариев.
{% endif %}
{% if user.is_authenticated and post_id %}
Оставить комментарий
{% csrf_token %}
{% else %} {% endif %}
{% endblock %}