Browse Source

Add tinymce in bower and ExpedienteForm

pull/6/head
Eduardo Edson Batista Cordeiro Alves 10 years ago
parent
commit
4a5ff0ee48
  1. 1
      sapl/settings.py
  2. 33
      sessao/views.py
  3. 3
      templates/base.html
  4. 7
      templates/sessao/expediente.html

1
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

33
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

3
templates/base.html

@ -65,6 +65,9 @@
{% block foot_js %}
<script type="text/javascript" src="{% static 'foundation/js/foundation.min.js' %}"></script>
<script type="text/javascript" src="{% static 'foundation/js/vendor/fastclick.js' %}"></script>
<script src="{% static 'tinymce/tinymce.min.js' %}"></script>
<script>tinymce.init({selector:'textarea'});</script>
<script>
$(document).foundation();
</script>

7
templates/sessao/expediente.html

@ -2,5 +2,10 @@
{% load i18n %}
{% block detail_content %}
TODO ... Expediente
<form method="Post" action="">
{% csrf_token %}
<textarea name="teste"></textarea>
<input type="submit" name="Salvar" />
</form>
{% endblock detail_content %}

Loading…
Cancel
Save