Browse Source

Add Tramitacao Doc Adm (lacking QA fixes)

pull/11/merge
Edward Ribeiro 9 years ago
parent
commit
34ab864875
  1. 18
      protocoloadm/urls.py
  2. 140
      protocoloadm/views.py
  3. 40
      templates/protocoloadm/tramitacao.html
  4. 28
      templates/protocoloadm/tramitacao_edit.html
  5. 28
      templates/protocoloadm/tramitacao_incluir.html

18
protocoloadm/urls.py

@ -16,7 +16,11 @@ from protocoloadm.views import (AnularProtocoloAdmView,
protocolo_materia_crud, protocolo_materia_crud,
status_tramitacao_administrativo_crud, status_tramitacao_administrativo_crud,
tipo_documento_administrativo_crud, tipo_documento_administrativo_crud,
tramitacao_administrativo_crud) tramitacao_administrativo_crud,
TramitacaoAdmView,
TramitacaoAdmEditView,
TramitacaoAdmIncluirView,
TramitacaoAdmDeleteView)
urlpatterns = [ urlpatterns = [
url(r'^protocoloadm/docadm/', include(documento_administrativo_crud.urls)), url(r'^protocoloadm/docadm/', include(documento_administrativo_crud.urls)),
@ -51,6 +55,16 @@ urlpatterns = [
url(r'^protocoloadm/doc-ace-adm/(?P<pk>\d+)', url(r'^protocoloadm/doc-ace-adm/(?P<pk>\d+)',
DocumentoAcessorioAdministrativoView.as_view(), name='doc_ace_adm'), DocumentoAcessorioAdministrativoView.as_view(), name='doc_ace_adm'),
url(r'^protocoloadm/(?P<pk>\d+)/tramitacao$',
TramitacaoAdmView.as_view(), name='tramitacao'),
url(r'^protocoloadm/(?P<pk>\d+)/tramitacao_incluir',
TramitacaoAdmIncluirView.as_view(), name='tramitacao_incluir'),
url(r'^protocoloadm/(?P<pk>\d+)/tramitacao_edit',
TramitacaoAdmEditView.as_view(), name='tramitacao_edit'),
url(r'^protocoloadm/(?P<pk>\d+)/tramitacao_delete/(?P<oid>\d+)',
TramitacaoAdmDeleteView.as_view(), name='tramitacao_delete'),
# TODO: move to Proposicoes app # TODO: move to Proposicoes app
url(r'^protocoloadm/proposicao-receber', url(r'^protocoloadm/proposicao-receber',
ProposicaoReceberView.as_view(), name='proposicao_receber'), ProposicaoReceberView.as_view(), name='proposicao_receber'),
@ -64,5 +78,5 @@ urlpatterns = [
ProposicoesIncorporadasView.as_view(), ProposicoesIncorporadasView.as_view(),
name='proposicoes_incorporadas'), name='proposicoes_incorporadas'),
url(r'^protocoloadm/(?P<pk>\d+)/proposicao', url(r'^protocoloadm/(?P<pk>\d+)/proposicao',
ProposicaoView.as_view(), name='proposicao_view') ProposicaoView.as_view(), name='proposicao_view'),
] ]

140
protocoloadm/views.py

@ -2,7 +2,7 @@ from datetime import date, datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit from crispy_forms.layout import ButtonHolder, Fieldset, Field, Layout, Submit
from django import forms from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -10,6 +10,7 @@ from django.db.models import Max
from django.forms import ModelForm from django.forms import ModelForm
from django.http import HttpResponseRedirect 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 _
@ -798,3 +799,140 @@ class DocumentoAcessorioAdministrativoView(FormMixin, GenericView):
def get_success_url(self): def get_success_url(self):
pk = self.kwargs['pk'] pk = self.kwargs['pk']
return reverse('doc_ace_adm', kwargs={'pk': pk}) return reverse('doc_ace_adm', kwargs={'pk': pk})
class TramitacaoAdmView(FormMixin, GenericView):
template_name = "protocoloadm/tramitacao.html"
def get(self, request, *args, **kwargs):
pk = kwargs['pk']
documento = DocumentoAdministrativo.objects.get(id=pk)
tramitacoes = TramitacaoAdministrativo.objects.filter(
documento=documento).order_by('-data_tramitacao')
return self.render_to_response({'documento': documento, 'tramitacoes': tramitacoes})
class TramitacaoAdmForm(ModelForm):
data_tramitacao = forms.DateField(label=u'Data Tramitação',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_encaminhamento = forms.DateField(label=u'Data Encaminhamento',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
data_fim_prazo = forms.DateField(label=u'Data Fim Prazo',
input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y',
attrs={'class': 'dateinput'}))
class Meta:
model = TramitacaoAdministrativo
fields = ['data_tramitacao',
'unidade_tramitacao_local',
'status',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto',
'documento',
]
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset('Incluir Tramitação',
'data_tramitacao',
'unidade_tramitacao_local',
'status',
'unidade_tramitacao_destino',
'data_encaminhamento',
'data_fim_prazo',
'texto'),
Field('documento', type="hidden"),
ButtonHolder(
Submit('submit', 'Salvar',
css_class='button primary')
)
)
super(TramitacaoAdmForm, self).__init__(
*args, **kwargs)
class TramitacaoAdmIncluirView(FormMixin, GenericView):
template_name = "protocoloadm/tramitacao_incluir.html"
def get(self, request, *args, **kwargs):
pk = kwargs['pk']
documento = DocumentoAdministrativo.objects.get(id=pk)
data = {'documento': documento}
form = TramitacaoAdmForm(initial=data)
return self.render_to_response({'documento': documento, 'form': form})
def post(self, request, *args, **kwargs):
pk = kwargs['pk']
documento = DocumentoAdministrativo.objects.get(id=pk)
form = TramitacaoAdmForm(request.POST or None)
if form.is_valid():
tramitacao = form.save(commit=False)
tramitacao.ultima = False
tramitacao.save()
message = "Tramitação criada com sucesso"
return HttpResponseRedirect(reverse('tramitacao', kwargs={'pk': pk}))
else:
return self.form_invalid(form)
class TramitacaoAdmEditView(FormMixin, GenericView):
template_name = "protocoloadm/tramitacao_edit.html"
def get(self, request, *args, **kwargs):
pk = kwargs['pk']
tramitacao = TramitacaoAdministrativo.objects.get(id=pk)
documento = tramitacao.documento
form = TramitacaoAdmForm(instance=tramitacao)
return self.render_to_response({'documento': documento, 'form': form})
def post(self, request, *args, **kwargs):
pk = kwargs['pk']
tramitacao = TramitacaoAdministrativo.objects.get(id=pk)
documento = tramitacao.documento
form = TramitacaoAdmForm(request.POST, instance=tramitacao)
if form.is_valid():
tramitacao = form.save(commit=False)
tramitacao.ultima = False
tramitacao.save()
return HttpResponseRedirect(reverse('tramitacao', kwargs={'pk': pk}))
else:
return self.form_invalid(form)
class TramitacaoAdmDeleteView(FormMixin, GenericView):
template_name = "protocoloadm/tramitacao.html"
def get(self, request, *args, **kwargs):
pk = kwargs['pk']
oid = kwargs['oid']
documento = DocumentoAdministrativo.objects.get(id=pk)
tramitacao = TramitacaoAdministrativo.objects.get(id=oid)
tramitacao.delete()
tramitacoes = TramitacaoAdministrativo.objects.filter(
documento=documento)
return self.render_to_response({'documento': documento, 'tramitacoes': tramitacoes})

40
templates/protocoloadm/tramitacao.html

@ -0,0 +1,40 @@
{% extends "protocoloadm/protocoloadm_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<fieldset>
Tipo: {{documento.tipo.sigla}} Número: {{documento.numero}} Ano: {{documento.ano}}</br>
Assunto: {{documento.assunto}}
</fieldset>
<fieldset>
<h2>Tramitação</h2>
{% if tramitacoes %}
<table>
<tr>
<td>Data Ação</td>
<td>Origem</td>
<td>Destino</td>
<td>Status</td>
<td>Excluir</td>
</tr>
{% for t in tramitacoes %}
<tr>
<td><a href="{% url 'tramitacao_edit' t.id %}">{{t.data_encaminhamento|date:"d/m/Y"}}</a></td>
<td>{{t.unidade_tramitacao_local}}</td>
<td>{{t.unidade_tramitacao_destino}}</td>
<td>{{t.status.sigla}}</td>
<td><a href="{% url 'tramitacao_delete' documento.id t.id %}">Excluir</ad></td>
</tr>
{% endfor %}
</table>
{% else %}
<strong>Nenhuma tramitação cadastrada para este documento.</strong>
{% endif %}
</br>
<a href="{% url 'tramitacao_incluir' documento.id %}" class="button primary">Incluir Tramitação</a>
</fieldset>
{% endblock detail_content %}

28
templates/protocoloadm/tramitacao_edit.html

@ -0,0 +1,28 @@
{% extends "protocoloadm/protocoloadm_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<fieldset>
Tipo: {{documento.tipo.sigla}} Número: {{documento.numero}} Ano: {{documento.ano}}</br>
Assunto: {{documento.assunto}}
</fieldset>
<h2>Tramitação Edit</h2>
{% crispy form %}
{% endblock detail_content %}
{% 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 %}

28
templates/protocoloadm/tramitacao_incluir.html

@ -0,0 +1,28 @@
{% extends "protocoloadm/protocoloadm_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<fieldset>
Tipo: {{documento.tipo.sigla}} Número: {{documento.numero}} Ano: {{documento.ano}}</br>
Assunto: {{documento.assunto}}
</fieldset>
<h2>Tramitação</h2>
{% crispy form %}
{% endblock detail_content %}
{% 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