matacoder

Untitled

Sep 6th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.59 KB | None | 0 0
  1. <!-- Начало блока с отдельным постом -->
  2. <div class="card mb-3 mt-1 shadow-sm">
  3.         {% load thumbnail %}
  4.     {% thumbnail post.image "960x339" crop="center" upscale=True as im %}
  5.         <img class="card-img" src="{{ im.url }}">
  6.     {% endthumbnail %}
  7.     <div class="card-body">
  8.             <p class="card-text">
  9.                     <!-- Ссылка на страницу автора в атрибуте href; username автора в тексте ссылки -->
  10.                     <a href="{% url 'profile' username=post.author %}"><strong class="d-block text-gray-dark">{{ post.author }}</strong></a>
  11.                     <!-- Текст поста -->
  12.                     {{ post.text|linebreaksbr}}
  13.             </p>
  14.                     <!-- Если пост относится к какому-нибудь сообществу, то отобразим ссылку на него через # -->
  15.         {% if post.group %}
  16.         <a class="card-link muted" href="{% url 'group_url' post.group.slug %}">
  17.                 <strong class="d-block text-gray-dark">#{{ post.group.title }}</strong>
  18.         </a>
  19.         {% endif %}
  20.             <div class="d-flex justify-content-between align-items-center">
  21.                     <div class="btn-group ">
  22.                             <!-- Ссылка на страницу записи в атрибуте href-->
  23.                             <a class="btn btn-sm text-muted" href="{% url 'post_single' username=post.author post_id=post.pk %}" role="button">
  24.                                 {% if post.post_comments.exists %}
  25.                              {{ post.post_comments.count }} комментариев
  26.                             {% else%}
  27.                               Добавить комментарий
  28.                                   {% endif %}
  29.  
  30.                             </a>
  31.                             <!-- Ссылка на редактирование, показывается только автору записи -->
  32.                             {% if user.is_authenticated  and user.username == post.author.username %}
  33.                             <a class="btn btn-sm text-muted" href="{% url 'post_edit' username=post.author post_id=post.pk %}" role="button">Редактировать</a>
  34.                             {% endif %}
  35.                     </div>
  36.                     <!-- Дата публикации  -->
  37.                     <small class="text-muted">{{ post.pub_date }}</small>
  38.             </div>
  39.     </div>
  40. </div>
  41. <!-- Конец блока с отдельным постом -->
Advertisement
Add Comment
Please, Sign In to add comment