From b8680d1de69535a8c10812fef44c15684501f0c5 Mon Sep 17 00:00:00 2001 From: Yaroslsav-95 Date: Mon, 8 Oct 2018 07:34:20 +0300 Subject: added publish date to comments, css for comments --- weblog/models.py | 1 + weblog/static/weblog/css/weblog.css | 29 ++++++++++++++++++++++++++++- weblog/templates/weblog/post.html | 35 +++++++++++++++++++---------------- weblog/views.py | 4 ++-- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/weblog/models.py b/weblog/models.py index 3830f6f..cccb8d3 100755 --- a/weblog/models.py +++ b/weblog/models.py @@ -80,6 +80,7 @@ class PostComment(models.Model): author = models.ForeignKey(User, verbose_name=_('Author'), null=True, blank=True, on_delete=models.PROTECT) post = models.ForeignKey(BlogPost, verbose_name=pgettext_lazy('Noun, as in blog post', 'Post'), on_delete=models.CASCADE) content = models.TextField(verbose_name=pgettext_lazy('Of post, comment, article, etc.', 'Content'), blank=False) + publish_date = models.DateTimeField(verbose_name=_('Publish date')) class Meta: verbose_name = pgettext_lazy('Noun', 'Comment') diff --git a/weblog/static/weblog/css/weblog.css b/weblog/static/weblog/css/weblog.css index 7adb7bd..201dbdf 100755 --- a/weblog/static/weblog/css/weblog.css +++ b/weblog/static/weblog/css/weblog.css @@ -236,7 +236,6 @@ hr{ .blog-wrapper{ display: flex; flex-wrap: wrap; - max-width: 45em; justify-content: center; } @@ -244,6 +243,7 @@ hr{ flex: 3; padding: 1em; padding-bottom: 3em; + max-width: 45em; } .weblog-sidebar{ @@ -289,6 +289,33 @@ hr{ padding: 2em; } +.alert{ + width: 100%; + padding: 0.5em 1em; + margin: 2em 0; + text-align: center; + color: #222; +} + +.alert-success{ + background-color: #6ed363; +} + +.alert-error{ + background-color: #a33030; +} + +.media, +.media-body{ + width: 100%; +} + +.media-date{ + font-size: 0.8em; + font-style: italic; + text-align: right; +} + @media (max-width: 760px){ .blog-content, .weblog-sidebar{ diff --git a/weblog/templates/weblog/post.html b/weblog/templates/weblog/post.html index b92d43c..7a7a09a 100755 --- a/weblog/templates/weblog/post.html +++ b/weblog/templates/weblog/post.html @@ -49,31 +49,34 @@ {% if comments %} {% if comment_submission %} {% if comment_submission_error %} -
- × +
+ {{ comment_submission_error }}
{% else %} -
- × +
+ {% trans 'Comment submited successfully' %}
{% endif %} {% endif %} - {% for comment in comments %} -
-
-

{% if comment.author %}{{ comment.author.get_username }}{% else %}{% trans 'Anonymous' context 'Unauthenticated comment poster' %}{% endif %}

-

{{ comment.content }}

+
+ {% for comment in comments %} +
+
+

{% if comment.author %}{{ comment.author.get_username }}{% else %}{% trans 'Anonymous' context 'Unauthenticated comment poster' %}{% endif %}

+

{{ comment.content }}

+

{{ comment.publish_date }}

+
+
+ {% endfor %} + {% else %} +
+
+

{% trans 'Nobody has left a comment on this post yet' %}

+ {% endif %}
- {% endfor %} - {% else %} -
-
-

{% trans 'Nobody has left a comment on this post yet' %}

-
- {% endif %} {% endif %}