diff --git a/sessao/views.py b/sessao/views.py index bd29b703a..3285624f1 100644 --- a/sessao/views.py +++ b/sessao/views.py @@ -2,6 +2,7 @@ from datetime import datetime from re import sub from django import forms +from django.forms.util import ErrorList from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse from django.utils.html import strip_tags @@ -1220,9 +1221,10 @@ class ExplicacaoEdit(FormMixin, sessao_crud.CrudDetailView): class VotacaoForm(forms.Form): - votos_sim = forms.CharField(required=True) - votos_nao = forms.CharField(required=True) - abstencoes = forms.CharField(required=True) + votos_sim = forms.CharField(required=True, label='Sim') + votos_nao = forms.CharField(required=True, label='Não') + abstencoes = forms.CharField(required=True, label='Abstenções') + total_votos = forms.CharField(required=False, label='total') class VotacaoEdit(forms.Form): @@ -1342,6 +1344,7 @@ class VotacaoView(FormMixin, sessao_crud.CrudDetailView): def post(self, request, *args, **kwargs): self.object = self.get_object() form = VotacaoForm(request.POST) + context = self.get_context_data(object=self.object) if form.is_valid(): materia_id = kwargs['oid'] @@ -1357,9 +1360,7 @@ class VotacaoView(FormMixin, sessao_crud.CrudDetailView): qtde_presentes -= 1 if (qtde_votos > qtde_presentes or qtde_votos < qtde_presentes): - # context.update ({'error_message': - # 'A quantidade de votos e de - # presentes não correspondem.'}) + form._errors["total_votos"] = ErrorList([u"aaaaa"]) return self.form_invalid(form) elif (qtde_presentes == qtde_votos): try: diff --git a/templates/sessao/votacao/votacao.html b/templates/sessao/votacao/votacao.html index 24396df71..373b2189b 100644 --- a/templates/sessao/votacao/votacao.html +++ b/templates/sessao/votacao/votacao.html @@ -2,10 +2,25 @@ {% load i18n %} {% block detail_content %} -
-{% endblock detail_content %} \ No newline at end of file +{% endblock detail_content %} +{% block foot_js %} + +{% endblock %} \ No newline at end of file