Browse Source

Add add DocumentoAcessorio in DocumentoAdministrativo

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
a1a35d4055
  1. 3
      protocoloadm/urls.py
  2. 95
      protocoloadm/views.py
  3. 1
      templates/protocoloadm/detail_doc_detail.html
  4. 54
      templates/protocoloadm/documento_acessorio_administrativo.html

3
protocoloadm/urls.py

@ -1,6 +1,7 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from protocoloadm.views import (AnularProtocoloAdmView, from protocoloadm.views import (AnularProtocoloAdmView,
DetailDocumentoAdministrativo, DetailDocumentoAdministrativo,
DocumentoAcessorioAdministrativoView,
PesquisarDocumentoAdministrativo, PesquisarDocumentoAdministrativo,
ProposicaoReceberView, ProposicaoReceberView,
ProposicoesIncorporadasView, ProposicoesIncorporadasView,
@ -46,6 +47,8 @@ urlpatterns = [
PesquisarDocumentoAdministrativo.as_view(), name='pesq_doc_adm'), PesquisarDocumentoAdministrativo.as_view(), name='pesq_doc_adm'),
url(r'^protocoloadm/doc-adm/(?P<pk>\d+)', url(r'^protocoloadm/doc-adm/(?P<pk>\d+)',
DetailDocumentoAdministrativo.as_view(), name='detail_doc_adm'), DetailDocumentoAdministrativo.as_view(), name='detail_doc_adm'),
url(r'^protocoloadm/doc-ace-adm/(?P<pk>\d+)',
DocumentoAcessorioAdministrativoView.as_view(), name='doc_ace_adm'),
# TODO: move to Proposicoes app # TODO: move to Proposicoes app
url(r'^protocoloadm/proposicao-receber', url(r'^protocoloadm/proposicao-receber',

95
protocoloadm/views.py

@ -1,22 +1,24 @@
from datetime import date, datetime from datetime import date, datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit, HTML
from django import forms from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Max from django.db.models import Max
from django.forms import ModelForm
from django.http import HttpResponseRedirect
from django.shortcuts import render from django.shortcuts import render
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView, DetailView from django.views.generic import DetailView, ListView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from vanilla import GenericView
from materia.models import Proposicao, TipoMateriaLegislativa from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud from sapl.crud import build_crud
from vanilla import GenericView
from .models import (Autor, DocumentoAcessorioAdministrativo, from .models import (Autor, DocumentoAcessorioAdministrativo,
DocumentoAdministrativo, Protocolo, DocumentoAdministrativo, Protocolo,
@ -514,9 +516,7 @@ class ProposicoesNaoRecebidasView(ListView):
paginate_by = 10 paginate_by = 10
def get_queryset(self): def get_queryset(self):
return Proposicao.objects.filter(data_envio__isnull=False, return Proposicao.objects.filter(data_envio__isnull=False, status='E')
status='E')
class ProposicoesNaoIncorporadasView(ListView): class ProposicoesNaoIncorporadasView(ListView):
template_name = "protocoloadm/proposicoes_naoincorporadas.html" template_name = "protocoloadm/proposicoes_naoincorporadas.html"
@ -667,3 +667,84 @@ class DetailDocumentoAdministrativo(DetailView):
def get_success_url(self): def get_success_url(self):
return reverse('pesq_doc_adm') return reverse('pesq_doc_adm')
class ModelFormDocumentoAcessorioAdministrativo(ModelForm):
data = forms.DateField(label=u'Data', input_formats=['%d/%m/%Y'],
required=False, widget=forms.DateInput(format='%d/%m/%Y'))
class Meta:
model = DocumentoAcessorioAdministrativo
fields = ['tipo',
'nome',
'data',
'autor',
'arquivo',
'assunto']
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'Incluir Documento Acessório',
'tipo',
'nome',
'data',
'autor',
'arquivo',
'assunto',
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
),
)
super(ModelFormDocumentoAcessorioAdministrativo, self).__init__(*args, **kwargs)
class DocumentoAcessorioAdministrativoView(FormMixin, GenericView):
template_name = "protocoloadm/documento_acessorio_administrativo.html"
def get(self, request, *args, **kwargs):
form = ModelFormDocumentoAcessorioAdministrativo()
doc = DocumentoAdministrativo.objects.get(
id=kwargs['pk'])
doc_ace_null = ''
try:
doc_acessorio = DocumentoAcessorioAdministrativo.objects.filter(
documento_id=kwargs['pk'])
except ObjectDoesNotExist:
doc_ace_null = 'Nenhum documento acessório \
cadastrado para este processo.'
return self.render_to_response({'doc': doc,
'doc_ace': doc_acessorio,
'doc_ace_null': doc_ace_null,
'form': form})
def post(self, request, *args, **kwargs):
form = ModelFormDocumentoAcessorioAdministrativo(request.POST)
if form.is_valid():
doc_acessorio = DocumentoAcessorioAdministrativo()
doc_acessorio.tipo = form.cleaned_data['tipo']
doc_acessorio.nome = form.cleaned_data['nome']
doc_acessorio.data = form.cleaned_data['data']
doc_acessorio.autor = form.cleaned_data['autor']
doc_acessorio.assunto = form.cleaned_data['assunto']
doc_acessorio.arquivo = form.cleaned_data['arquivo']
doc_acessorio.documento = DocumentoAdministrativo.objects.get(
id=kwargs['pk'])
doc_acessorio.save()
return self.form_valid(form)
else:
print(form['data'])
import ipdb; ipdb.set_trace()
return self.form_invalid(form)
# return HttpResponseRedirect(self.get_success_url())
def get_success_url(self):
pk = self.kwargs['pk']
return reverse('doc_ace_adm',kwargs={'pk': pk})

1
templates/protocoloadm/detail_doc_detail.html

@ -3,6 +3,7 @@
{% block sections_nav %} {% block sections_nav %}
<dl class="sub-nav left"> <dl class="sub-nav left">
<dd><a href="#" class="button secondary">{% trans 'Inicio' %}</a></dd>
<dd><a href="#" class="button secondary">{% trans 'Documento Acessório' %}</a></dd> <dd><a href="#" class="button secondary">{% trans 'Documento Acessório' %}</a></dd>
<dd><a href="#" class="button secondary">{% trans 'Tramitação' %}</a></dd> <dd><a href="#" class="button secondary">{% trans 'Tramitação' %}</a></dd>
{% endblock sections_nav %} {% endblock sections_nav %}

54
templates/protocoloadm/documento_acessorio_administrativo.html

@ -0,0 +1,54 @@
{% extends "protocoloadm/detail_doc_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<fieldset>
<legend>Documento Administrativo</legend>
<ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3">
<li>Tipo: <b>{{doc.tipo.sigla}}</b></li>
<li>Número: <b>{{doc.numero}}</b></li>
<li>Ano: <b>{{doc.ano}}</b></li>
</ul>
Assunto: <b>{{doc.assunto}}</b>
<fieldset>
<legend>Documentos Acessórios</legend>
{{ doc_ace_null }}
<table>
<tr>
<th>Documento</th>
<th>Nome</th>
<th>Tipo</th>
<th>Data</th>
<th>Autor</th>
</tr>
{% for d in doc_ace %}
<tr>
<td>{{d.arquivo}}</td>
<td>{{d.nome}}</td>
<td>{{d.tipo.descricao}}</td>
<td>{{d.data|date:"d/m/Y"}}</td>
<td>{{d.autor}}</td>
</tr>
{% endfor %}
</table>
</fieldset>
{% crispy form %}
</fieldset>
{% endblock %}
{% block foot_js %}
<script type="text/javascript">
$(function () {
$('.dateinput').fdatepicker({
// TODO localize
format: 'dd/mm/yyyy',
language: 'pt',
endDate: '31/12/2100',
todayBtn: true
});
});
</script>
{% endblock %}
Loading…
Cancel
Save