Adds comments to youtube videos

master
Laurent Morvillier 6 years ago
parent beae2cd3ef
commit 55252e5575
  1. 5
      news/models.py
  2. 20
      news/templates/news/index.html
  3. 6
      news/templates/news/post.html

@ -43,6 +43,11 @@ class Post(models.Model):
tag_names = map(lambda t: t.name, self.tag_set.all())
return ", ".join(tag_names)
def html_title(self):
if self.title:
return title
return 'Poker Rumble - Amazing content'
class Comment(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True)
post = models.ForeignKey(Post, on_delete=models.CASCADE)

@ -2,22 +2,20 @@
{% load static %}
{% block title %}Poker Rumble - {% endblock %}
{% block title %}Poker Rumble - Your source of great poker content{% endblock %}
{% block content %}
{% if latest_post_list %}
{% for post in latest_post_list %}
<!-- <div class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}"> -->
{% for post in latest_post_list %}
<!-- A post -->
<article>
<div class="details lat_padding">
{{ post.date }} - {{ post.author.username }}
</div>
<!-- A post -->
{% if post.style == 0 %}
<div class="imgcontainer">
@ -94,6 +92,18 @@
<iframe class="youtube" src="https://www.youtube.com/embed/{{ post.url }}"></iframe>
<div class="post_padding">
<div class="details info">
<a href="{% url 'news:post' post.id %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a>
</div>
<!-- Some comments -->
<div class="comments">
{% for comment in post.top_comments %}
<span>{{ comment.body }} - {{ comment.author.username }}</span><br/>
{% endfor %}
</div>
</div>
{% endif %}
<!-- {% if post.tag_set.count > 0 %}

@ -2,7 +2,7 @@
{% load static %}
{% block title %}My amazing blog{% endblock %}
{% block title %}{{ post.html_title }}{% endblock %}
{% block content %}
@ -23,7 +23,9 @@
</div>
</div>
{% if post.style != 1 %}
{% if post.style == 3 %}
<iframe class="youtube" src="https://www.youtube.com/embed/{{ post.url }}"></iframe>
{% elif post.style != 1 %}
<img src="{% static 'media/' %}{{ post.image_url }}"/>
{% endif %}

Loading…
Cancel
Save