diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index 08835c6..194fd7c 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -968,4 +968,13 @@ li.item .notify_badge { .mural .post_make .post-field h4 { cursor: text; font-style: italic; +} + +.post_action i { + font-size: 45px; +} + +.post-button { + padding-right: inherit !important; + padding-left: inherit !important; } \ No newline at end of file diff --git a/amadeus/static/css/themes/green.css b/amadeus/static/css/themes/green.css index e1162c1..4774d52 100644 --- a/amadeus/static/css/themes/green.css +++ b/amadeus/static/css/themes/green.css @@ -504,6 +504,10 @@ a.add-row { color: #CCCCCC; } +.post_action i { + color: #1d8fe0; +} + @media(max-width: 768px) { .navbar .navbar-nav .dropdown .dropdown-menu li > a { color: #333333 !important; diff --git a/mural/forms.py b/mural/forms.py index e69de29..7bfedde 100644 --- a/mural/forms.py +++ b/mural/forms.py @@ -0,0 +1,41 @@ +# coding=utf-8 +from django import forms +from django.utils.translation import ugettext_lazy as _ +from django.utils.html import strip_tags + +from .models import GeneralPost + +class Validation(forms.ModelForm): + MAX_UPLOAD_SIZE = 5*1024*1024 + + def clean_post(self): + post = self.cleaned_data.get('post', '') + cleaned_post = strip_tags(post) + + if cleaned_post == '': + self._errors['post'] = [_('This field is required.')] + + return ValueError + + return post + + 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 GeneralPostForm(Validation): + class Meta: + model = GeneralPost + fields = ['action', 'post', 'image'] + widgets = { + 'action': forms.RadioSelect, + 'post': forms.Textarea + } \ No newline at end of file diff --git a/mural/migrations/0003_auto_20170204_1625.py b/mural/migrations/0003_auto_20170204_1625.py new file mode 100644 index 0000000..5dc3f85 --- /dev/null +++ b/mural/migrations/0003_auto_20170204_1625.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-02-04 19:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mural', '0002_muralvisualizations'), + ] + + operations = [ + migrations.AlterField( + model_name='mural', + name='action', + field=models.CharField(choices=[('comment', 'Comment'), ('help', 'Ask for Help')], max_length=100, verbose_name='Action'), + ), + ] diff --git a/mural/models.py b/mural/models.py index 716a77d..59e7037 100644 --- a/mural/models.py +++ b/mural/models.py @@ -16,7 +16,7 @@ def validate_img_extension(value): raise ValidationError(_('File not supported.')) class Mural(KnowsChild): - action = models.CharField(_('Action'), max_length = 100, choices = (("comment", _("Comment")), ("help", _("Ask for Help"))), blank = True) + action = models.CharField(_('Action'), max_length = 100, default = "comment", choices = (("comment", _("Comment")), ("help", _("Ask for Help")))) post = models.TextField(_('Post'), blank = True) image = models.ImageField(verbose_name = _('Image'), null=True, blank = True, upload_to = 'posts/', validators = [validate_img_extension]) user = models.ForeignKey(User, verbose_name = _('User'), related_name = "post_user", null = True) diff --git a/mural/templates/mural/_form.html b/mural/templates/mural/_form.html new file mode 100644 index 0000000..3cf70d0 --- /dev/null +++ b/mural/templates/mural/_form.html @@ -0,0 +1,142 @@ +{% load static i18n %} +{% load widget_tweaks %} + +