From 4a5ff0ee48caa2e7af43c0492faa05e65a4a7aff Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 30 Jul 2015 17:17:33 -0300 Subject: [PATCH] Add tinymce in bower and ExpedienteForm --- sapl/settings.py | 1 + sessao/views.py | 33 +++++++++++++++++++++++++++----- templates/base.html | 3 +++ templates/sessao/expediente.html | 7 ++++++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/sapl/settings.py b/sapl/settings.py index 60b9373c3..79d5a2280 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -144,6 +144,7 @@ BOWER_INSTALLED_APPS = ( 'foundation-datepicker', 'components-font-awesome', 'foundation-icon-fonts', + 'tinymce' ) # hack to suppress many annoying warnings from crispy_forms diff --git a/sessao/views.py b/sessao/views.py index 20c255fd4..627b881b1 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -1,10 +1,13 @@ +from django import forms +from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +from django.views.generic.edit import FormMixin from sapl.crud import build_crud -from .models import (ExpedienteMateria, OrdemDia, RegistroVotacao, - SessaoPlenaria, TipoExpediente, TipoResultadoVotacao, - TipoSessaoPlenaria) +from .models import (ExpedienteMateria, ExpedienteSessao, OrdemDia, + RegistroVotacao, SessaoPlenaria, TipoExpediente, + TipoResultadoVotacao, TipoSessaoPlenaria) tipo_sessao_crud = build_crud( TipoSessaoPlenaria, 'tipo_sessao_plenaria', [ @@ -80,6 +83,26 @@ registro_votacao_crud = build_crud( ]) -class ExpedienteView(sessao_crud.CrudDetailView): +class ExpedienteForm(forms.Form): + teste = forms.CharField(widget=forms.Textarea, max_length=100) + + +class ExpedienteView(FormMixin, sessao_crud.CrudDetailView): template_name = 'sessao/expediente.html' - # TODO ... + form_class = ExpedienteForm + + def post(self, request, *args, **kwargs): + self.object = self.get_object() + form = self.get_form() + if form.is_valid(): + expediente = ExpedienteSessao() + expediente.sessao_plenaria = self.object + expediente.tipo = TipoExpediente.objects.first() + expediente.conteudo = form.fields['teste'] + expediente.save() + return self.form_valid(form) + else: + return self.form_invalid(form) + + def get_success_url(self): + return self.detail_url diff --git a/templates/base.html b/templates/base.html index 7d209c1d5..ee39f48b8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -65,6 +65,9 @@ {% block foot_js %} + + + diff --git a/templates/sessao/expediente.html b/templates/sessao/expediente.html index ccbbdd5e4..73bcf4309 100644 --- a/templates/sessao/expediente.html +++ b/templates/sessao/expediente.html @@ -2,5 +2,10 @@ {% load i18n %} {% block detail_content %} - TODO ... Expediente +
+ {% csrf_token %} + + +
+ {% endblock detail_content %}