Facebook
From parsa, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 182
  1. {% extends 'base.html' %}
  2. {% load static %}
  3. {% block custom-tags %}<script src="{% static 'js/a.js' %}"></script>
  4.  
  5. <script src="{% static 'js/jquery.js' %}"></script>
  6.  
  7.  
  8. {% endblock %}
  9. {% block content %}
  10.     {% if request.user.is_authenticated and request.user.id == post.user.id %}
  11.     <a href="{% url 'posts:post_delete' post.user.id post.id %}" class="btn btn-danger">Delete Post</a>
  12.  
  13.     <a href="{% url 'posts:edit_post' request.user.id post.id %}" class="btn btn-primary">Edit Post</a>
  14.     {% endif %}
  15.     <p>{{ post.user }} | {{ post.created }}</p>
  16.     <P>{{ post.body }}</P>
  17.     <hr/>
  18.     {% if comments.count != 0 %}
  19.     {% with total=comments.count %}
  20.         <p>This post has {{ total }} comment{{ total|pluralize }}</p>
  21.     {% endwith %}
  22.     {% endif %}
  23.  
  24.     <br/>
  25.     {% if request.user.is_authenticated%}
  26.         <form method="post" class="col-md-7">
  27.             {% csrf_token %}
  28.             {{ form.as_p}}
  29.             <input value="Send" type="submit" class="btn btn-primary">
  30.         </form>
  31.     {% else %}
  32.     <P>Only logged in user can send comments</P>
  33.     {% endif %}
  34.  
  35.     <br/><br/>
  36.     {% for comment in comments %}
  37.  
  38.         <div class="card bg-dark text-white">
  39.             <pre style="color: white" class="card-header">{{ comment.user }}     <button onclick="show()" class="btn btn-primary">reply</button></pre>
  40.         <p class="card-body">{{ comment.body }}</p>
  41.         {% if request.user.is_authenticated %}
  42.         <div class="card-body">
  43.             <form style="display:none" class="a" method="post" action="{% url 'posts:add_reply' post.id comment.id %}">
  44.                 {% csrf_token %}
  45.                 {{ reply.as_p }}
  46.                 <input value="Send" type="submit">
  47.             </form>
  48.         </div>
  49.         {% else %}
  50.             <p>You have to login to send reply</p>
  51.         {% endif %}
  52.         {% for reply in comment.rcomment.all %}
  53.             <p class="bg-primary text-white p-3 m-5">{{ reply.user }} <br/> {{ reply.body }}</p>
  54.         {% endfor %}
  55.  
  56.  
  57.         </div>
  58.         <br/>
  59.     {% empty %}
  60.         <P>There is no comment</P>
  61.     {% endfor %}
  62.  
  63.  
  64. {% endblock %}