diff --git a/protocoloadm/urls.py b/protocoloadm/urls.py index d56920344..0d3353897 100644 --- a/protocoloadm/urls.py +++ b/protocoloadm/urls.py @@ -4,6 +4,7 @@ from protocoloadm.views import (AnularProtocoloAdmView, DocumentoAcessorioAdministrativoView, PesquisarDocumentoAdministrativo, ProposicaoReceberView, + ProposicaoView, ProposicoesIncorporadasView, ProposicoesNaoIncorporadasView, ProposicoesNaoRecebidasView, @@ -62,4 +63,6 @@ urlpatterns = [ url(r'^protocoloadm/proposicoes-incorporadas', ProposicoesIncorporadasView.as_view(), name='proposicoes_incorporadas'), + url(r'^protocoloadm/(?P\d+)/proposicao', + ProposicaoView.as_view(), name='proposicao_view') ] diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 5d01982f3..c64713d96 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -16,6 +16,11 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import DetailView, ListView from django.views.generic.base import TemplateView from django.views.generic.edit import FormMixin +from django.views.generic import FormView +from django.views.generic import DetailView +from vanilla import GenericView +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Layout, Field from materia.models import Proposicao, TipoMateriaLegislativa from sapl.crud import build_crud from vanilla import GenericView @@ -540,6 +545,52 @@ class ProposicoesIncorporadasView(ListView): data_recebimento__isnull=False, status='I') +class ProposicaoSimpleForm(forms.Form): + + tipo = forms.CharField(label='Tipo', + widget = forms.TextInput( + attrs={'readonly':'readonly'})) + materia = forms.CharField(label='Matéria', + widget = forms.TextInput( + attrs={'readonly':'readonly'})) + data_envio = forms.DateField(label='Data Envio', + widget=forms.DateInput(format = '%d/%m/%Y', attrs={'readonly':'readonly'})) + data_recebimento = forms.DateField(label='Data Recebimento', + widget=forms.DateInput(format = '%d/%m/%Y', attrs={'readonly':'readonly'})) + + descricao = forms.CharField(label='Descrição', + widget = forms.TextInput( + attrs={'readonly':'readonly'})) + + numero_proposicao = forms.CharField(label='Número', + widget = forms.TextInput( + attrs={'readonly':'readonly'})) + # ano = forms.CharField(label='Ano', + # widget = forms.TextInput( + # attrs={'readonly':'readonly'})) + + +class ProposicaoView(DetailView): + template_name = "protocoloadm/proposicao_view.html" + model = Proposicao + + def get(self, request, *args, **kwargs): + proposicao = Proposicao.objects.get(id=kwargs['pk']) + data = {# 'ano': proposicao.ano, # TODO: FIX + 'tipo': proposicao.tipo.descricao, #TODO: FIX + 'materia': proposicao.materia, + 'numero_proposicao': proposicao.numero_proposicao, + 'data_envio': proposicao.data_envio, + 'data_recebimento': proposicao.data_recebimento, + 'descricao': proposicao.descricao} + form = ProposicaoSimpleForm(initial=data) + return self.render_to_response({'form': form}) + + def get_context_data(self, **kwargs): + context = super(ProposicaoView, self).get_context_data(**kwargs) + context['form'] = ProposicaoSimpleForm + return context + # class PesquisaDocForm(forms.Form): diff --git a/templates/materia/formulario_simplificado.html b/templates/materia/formulario_simplificado.html index 54db1129d..99ca4da4f 100644 --- a/templates/materia/formulario_simplificado.html +++ b/templates/materia/formulario_simplificado.html @@ -5,7 +5,7 @@ {% block detail_content %}
{% csrf_token %} - {{ form.as_p }} + {% crispy form %}
diff --git a/templates/protocoloadm/proposicao_view.html b/templates/protocoloadm/proposicao_view.html new file mode 100644 index 000000000..ffccb66a4 --- /dev/null +++ b/templates/protocoloadm/proposicao_view.html @@ -0,0 +1,7 @@ +{% extends "protocoloadm/protocoloadm_detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} + +{% block detail_content %} + {{ form.as_p }} +{% endblock detail_content %} \ No newline at end of file diff --git a/templates/protocoloadm/proposicoes_incorporadas.html b/templates/protocoloadm/proposicoes_incorporadas.html index b6f8bcf5b..527b4556c 100644 --- a/templates/protocoloadm/proposicoes_incorporadas.html +++ b/templates/protocoloadm/proposicoes_incorporadas.html @@ -8,7 +8,9 @@ {% for p in object_list %} - {{ p.data_envio|date:"d/m/Y" }} + + {{ p.data_envio|date:"d/m/Y" }} +