diff --git a/news/choices.py b/news/choices.py
index 939064d..92fc064 100644
--- a/news/choices.py
+++ b/news/choices.py
@@ -1,5 +1,6 @@
STYLE_CHOICES = (
(0, "Standard [Title + URL + Image]"),
(1, "Quote [Title]"),
- (2, "Image Only [Image]")
+ (2, "Image Only [Image]"),
+ (3, "Youtube [Put video id in URL]")
)
diff --git a/news/models.py b/news/models.py
index 2300b0b..df6ab82 100644
--- a/news/models.py
+++ b/news/models.py
@@ -2,6 +2,7 @@ from django.db import models
from django.contrib.auth.models import User
from django.conf import settings
from enum import Enum
+from django.db.models import Q
# Create your models here.
class PostState(Enum):
@@ -19,26 +20,25 @@ class Post(models.Model):
state = models.IntegerField(default=0)
style = models.IntegerField(default=0)
image_url = models.CharField(max_length=100)
+
def __str__(self):
- return self.title
+ string = self.title
+ if self.style == 2:
+ string = "some image"
+ elif self.style == 3:
+ string = "Youtube: " + self.title
+ return string
def top_comments(self):
return self.comment_set.order_by('-voters').all()[:1]
def flat_comments(self, user):
flat = []
- for comment in self.comment_set.all():
- # flat.append(comment)
- flat.extend(comment.flat_children(0, user))
+ for comment in self.comment_set.filter(Q(parent_comment=None)).all():
+ children = comment.flat_children(0, user)
+ flat.extend(children)
return flat
- def is_youtube_video(self):
- return "youtube.com" in self.url
-
- # return self.comment_set.annotate(ratings_num=count('voters')).order_by('-ratings_num')[:5]
- # return self.comment_set.order_by('voters_num').all()[:5]
-
-
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)
diff --git a/news/static/news/css/app.css b/news/static/news/css/app.css
index f7f6ad6..78986aa 100644
--- a/news/static/news/css/app.css
+++ b/news/static/news/css/app.css
@@ -349,3 +349,26 @@ form .secondary_button {
.reply_form {
margin-top: 8px;
}
+
+.youtube {
+ width: 95vw;
+ height: 60vw;
+}
+/* @media print, screen and (min-width: 40em) {
+ .youtube {
+ width: 90vw;
+ height: 60vw;
+ }
+} */
+@media print, screen and (min-width: 50em) {
+ .youtube {
+ width: 60vw;
+ height: 35vw;
+ }
+}
+@media print, screen and (min-width: 70em) {
+ .youtube {
+ width: 45vw;
+ height: 25vw;
+ }
+}
diff --git a/news/templates/news/index.html b/news/templates/news/index.html
index 7e2dbbe..caee1d8 100644
--- a/news/templates/news/index.html
+++ b/news/templates/news/index.html
@@ -20,12 +20,6 @@
{% if post.style == 0 %}
- {% if post.is_youtube_video %}
-
- {{ post.title }}
-
-
- {% else %}