diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index 7e05949..56f4ea4 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -1009,16 +1009,17 @@ li.item .notify_badge { .post .post-body { padding-right: 0; + margin-bottom: 10px; } -.post .post-user { +.post .post-user, .comment .comment-user { margin-top: 0; margin-bottom: 5px; font-size: 18px; font-weight: 700; } -.post .post-user .btn-group { +.post .post-user .btn-group, .comment .comment-user .btn-group { margin: 0; } @@ -1030,28 +1031,27 @@ li.item .notify_badge { font-size: 18px; } -.post .post-user .user-action { +.post .post-user .user-action, .comment .comment-user .user-action { padding-left: 5px; font-size: 16px; font-weight: normal; } -.post .post-user .user-action i { +.post .post-user .user-action i, .comment .comment-user .user-action i { font-size: 22px; } -.post .time { +.post .time, .comment-time { font-size: 14px; } .post .post-comment { - margin-top: 10px; border-top-width: 1px; border-top-style: solid; padding: 10px 0px 8px 0px; } -.post .post-comment .user-img div { +.post .post-comment .user-img div, .comment .comment-img div { display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */ display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */ display: -ms-flexbox; /* TWEENER - IE 10 */ @@ -1084,6 +1084,19 @@ li.item .notify_badge { margin-bottom: 15px; } +.comment-section { + max-height: 700px; + overflow-y: scroll; +} + +.comment { + padding: 10px 0px 8px 0px; +} + +.comment .comment-user .btn-group .btn_menu i { + font-size: 15px; +} + .btn:focus, .btn:active:focus, .btn.active:focus, .btn.focus, .btn:active.focus, .btn.active.focus { outline: none; } \ No newline at end of file diff --git a/amadeus/static/css/themes/green.css b/amadeus/static/css/themes/green.css index 27728ed..24a2aef 100644 --- a/amadeus/static/css/themes/green.css +++ b/amadeus/static/css/themes/green.css @@ -496,7 +496,7 @@ a.add-row { background: #FFFFFF; } -.mural .post_make .user-img, .post .post-img, .post .post-comment .user-img div { +.mural .post_make .user-img, .post .post-img, .post .post-comment .user-img div, .comment .comment-img div { background: #CCCCCC; } @@ -508,11 +508,11 @@ a.add-row { color: #CCCCCC; } -.post_action i, .post .post-user .user-action i { +.post_action i, .post .post-user .user-action i, .comment .comment-user .user-action i { color: #1d8fe0; } -.post .post-user { +.post .post-user, .comment .comment-user { color: #4caf50; } @@ -534,6 +534,18 @@ a.add-row { background: #FFFFFF; } +.comment-section { + background: #D5D5D5; +} + +.comment .comment-user .user-action { + color: #999999; +} + +.comment-time { + color: #9A9A9A; +} + .btn_unfav { color: #FF0000 !important; } diff --git a/mural/forms.py b/mural/forms.py index 7bfedde..eebc153 100644 --- a/mural/forms.py +++ b/mural/forms.py @@ -3,7 +3,7 @@ from django import forms from django.utils.translation import ugettext_lazy as _ from django.utils.html import strip_tags -from .models import GeneralPost +from .models import GeneralPost, Comment class Validation(forms.ModelForm): MAX_UPLOAD_SIZE = 5*1024*1024 @@ -38,4 +38,34 @@ class GeneralPostForm(Validation): widgets = { 'action': forms.RadioSelect, 'post': forms.Textarea - } \ No newline at end of file + } + +class CommentForm(forms.ModelForm): + MAX_UPLOAD_SIZE = 5*1024*1024 + + def clean_comment(self): + comment = self.cleaned_data.get('comment', '') + cleaned_comment = strip_tags(comment) + + if cleaned_comment == '': + self._errors['comment'] = [_('This field is required.')] + + return ValueError + + return comment + + def clean_image(self): + image = self.cleaned_data.get('image', False) + + if image: + if hasattr(image, '_size'): + if image._size > self.MAX_UPLOAD_SIZE: + self._errors['image'] = [_("The image is too large. It should have less than 5MB.")] + + return ValueError + + return image + + class Meta: + model = Comment + fields = ['comment', 'image'] \ No newline at end of file diff --git a/mural/models.py b/mural/models.py index 3754a7e..40bbdc4 100644 --- a/mural/models.py +++ b/mural/models.py @@ -65,7 +65,7 @@ class SubjectPost(Mural): class Comment(models.Model): comment = models.TextField(_('Comment'), blank = True) image = models.ImageField(verbose_name = _('Image'), null=True, blank = True, upload_to = 'posts/comments/', validators = [validate_img_extension]) - post = models.ForeignKey(Mural, verbose_name = _('Post'), related_name = 'comment_post') + post = models.ForeignKey(Mural, verbose_name = _('Post'), related_name = 'comment_post', null = True) user = models.ForeignKey(User, verbose_name = _('User'), related_name = "comment_user", null = True) create_date = models.DateTimeField(_('Create Date'), auto_now_add = True) last_update = models.DateTimeField(_('Last Update'), auto_now = True) diff --git a/mural/templates/mural/_form_comment.html b/mural/templates/mural/_form_comment.html new file mode 100644 index 0000000..9c37af6 --- /dev/null +++ b/mural/templates/mural/_form_comment.html @@ -0,0 +1,121 @@ +{% load static i18n %} +{% load widget_tweaks %} + +
+ {{ comment.user }} + + + {% trans 'Comment' %} + + {% if request.user == comment.user or request.user.is_staff %} + + +
++- {% trans 'Edit' %}
+ -
+ {% trans 'Remove' %}
+
+ + {% endif %} ++ + {% trans 'In' %} {{ comment.last_update }} +
+ + {% autoescape off %} + {{ comment.comment }} + {% endautoescape %} + + {% if comment.image %} +