diff options
author | Yaroslsav-95 <contact@yaroslavps.com> | 2018-10-08 07:34:20 +0300 |
---|---|---|
committer | Yaroslsav-95 <contact@yaroslavps.com> | 2018-10-08 07:34:20 +0300 |
commit | b8680d1de69535a8c10812fef44c15684501f0c5 (patch) | |
tree | 1974cb22fe89caec4bb20cf238f8b0ea5e74fd42 | |
parent | 246dd98e40436371ff9a96f5cf68a5c496a60153 (diff) | |
download | w3blog-b8680d1de69535a8c10812fef44c15684501f0c5.tar.gz w3blog-b8680d1de69535a8c10812fef44c15684501f0c5.zip |
added publish date to comments, css for comments
-rwxr-xr-x | weblog/models.py | 1 | ||||
-rwxr-xr-x | weblog/static/weblog/css/weblog.css | 29 | ||||
-rwxr-xr-x | weblog/templates/weblog/post.html | 35 | ||||
-rwxr-xr-x | 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 %} - <div class="alert alert-danger alert-dismissable"> - <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> + <div class="alert alert-error"> + <!--<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>--> {{ comment_submission_error }} </div> {% else %} - <div class="alert alert-success alert-dismissable"> - <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> + <div class="alert alert-success"> + <!--<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>--> {% trans 'Comment submited successfully' %} </div> {% endif %} {% endif %} - {% for comment in comments %} - <div class="media"> - <div class="media-body"> - <h4 class="media-heading">{% if comment.author %}{{ comment.author.get_username }}{% else %}{% trans 'Anonymous' context 'Unauthenticated comment poster' %}{% endif %}</h4> - <p>{{ comment.content }}</p> + <div id="comment-section"> + {% for comment in comments %} + <div class="media"> + <div class="media-body"> + <h4 class="media-heading">{% if comment.author %}{{ comment.author.get_username }}{% else %}{% trans 'Anonymous' context 'Unauthenticated comment poster' %}{% endif %}</h4> + <p>{{ comment.content }}</p> + <p class="media-date">{{ comment.publish_date }}</p> + </div> + </div> + {% endfor %} + {% else %} + <div class="text-center"> + <br> + <h3>{% trans 'Nobody has left a comment on this post yet' %}</h3> </div> + {% endif %} </div> - {% endfor %} - {% else %} - <div class="text-center"> - <br> - <h3>{% trans 'Nobody has left a comment on this post yet' %}</h3> - </div> - {% endif %} {% endif %} </div> <script> diff --git a/weblog/views.py b/weblog/views.py index 72700c0..d3a7066 100755 --- a/weblog/views.py +++ b/weblog/views.py @@ -223,10 +223,10 @@ def PostView(request, category_slug, post_slug, language=None): # Make sure that either anonymous comments are allowed or # that the user is authenticated if request.user.is_authenticated: - new_comment = PostComment(author=request.user, post=post, content=comment_content) + new_comment = PostComment(author=request.user, post=post, content=comment_content, publish_date=datetime.datetime.now()) new_comment.save() elif ALLOW_ANON_COMMENTS: - new_comment = PostComment(post=post, content=comment_content) + new_comment = PostComment(post=post, content=comment_content, publish_date=datetime.datetime.now()) new_comment.save() else: context_dict['comment_submission_error'] = _('You need to sign in to submit a comment') |