Browse Source

Restaura funcionalidades e alguns ajt em protocolo

pull/781/head
LeandroRoberto 8 years ago
parent
commit
8a1c566002
  1. 11
      sapl/protocoloadm/forms.py
  2. 43
      sapl/protocoloadm/urls.py
  3. 52
      sapl/protocoloadm/views.py
  4. 3
      sapl/rules/map_rules.py
  5. 2
      sapl/templates/crud/detail.html
  6. 10
      sapl/templates/protocoloadm/anular_protocoloadm.html
  7. 4
      sapl/templates/protocoloadm/comprovante.html
  8. 9
      sapl/templates/protocoloadm/protocolar_documento.html
  9. 8
      sapl/templates/protocoloadm/protocolar_materia.html
  10. 22
      sapl/templates/protocoloadm/protocolo_filter.html
  11. 4
      sapl/templates/protocoloadm/protocolo_mostrar.html
  12. 6
      sapl/templates/protocoloadm/protocoloadm_detail.html

11
sapl/protocoloadm/forms.py

@ -1,6 +1,5 @@
from datetime import datetime
import django_filters
from crispy_forms.bootstrap import InlineRadios
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit
@ -9,6 +8,7 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
import django_filters
from sapl.base.models import Autor
from sapl.crispy_layout_mixin import form_actions, to_row
@ -20,6 +20,7 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo, TipoDocumentoAdministrativo,
TramitacaoAdministrativo)
TIPOS_PROTOCOLO = [('0', 'Enviado'), ('1', 'Recebido'), ('', 'Ambos')]
NATUREZA_PROCESSO = [('', 'Ambos'),
@ -131,7 +132,7 @@ class ProtocoloFilterSet(django_filters.FilterSet):
self.form.helper = FormHelper()
self.form.helper.form_method = 'GET'
self.form.helper.layout = Layout(
Fieldset(_('Pesquisar Protocolo'),
Fieldset('',
row1, row2,
row3,
HTML(autor_label),
@ -313,7 +314,7 @@ class ProtocoloDocumentForm(ModelForm):
empty_label='Selecione',
)
num_paginas = forms.CharField(label=_('Núm. Páginas'), required=True)
numero_paginas = forms.CharField(label=_('Núm. Páginas'), required=True)
assunto = forms.CharField(
widget=forms.Textarea, label='Assunto', required=True)
@ -327,7 +328,7 @@ class ProtocoloDocumentForm(ModelForm):
model = Protocolo
fields = ['tipo_protocolo',
'tipo_documento',
'num_paginas',
'numero_paginas',
'assunto',
'interessado',
'observacao',
@ -339,7 +340,7 @@ class ProtocoloDocumentForm(ModelForm):
[(InlineRadios('tipo_protocolo'), 12)])
row2 = to_row(
[('tipo_documento', 6),
('num_paginas', 6)])
('numero_paginas', 6)])
row3 = to_row(
[('assunto', 12)])
row4 = to_row(

43
sapl/protocoloadm/urls.py

@ -9,9 +9,7 @@ from sapl.protocoloadm.views import (AnularProtocoloAdmView,
DocumentoAcessorioAdministrativoView,
DocumentoAdministrativoCrud,
PesquisarDocumentoAdministrativoView,
ProtocoloDocumentoCrud,
ProtocoloDocumentoView, ProtocoloListView,
ProtocoloMateriaCrud,
ProtocoloMateriaView,
ProtocoloMostrarView,
ProtocoloPesquisaView,
@ -42,31 +40,38 @@ urlpatterns_documento_administrativo = [
]
urlpatterns_protocolo = [
url(r'^protocoloadm/protocolo-doc/',
include(ProtocoloDocumentoCrud.get_urls())),
url(r'^protocoloadm/protocolo-mat/',
include(ProtocoloMateriaCrud.get_urls()), name='protocolomat'),
url(r'^protocoloadm/protocolo$',
# url(r'^protocoloadm/protocolo-doc/',
# include(ProtocoloDocumentoCrud.get_urls())),
# url(r'^protocoloadm/protocolo-mat/',
# include(ProtocoloMateriaCrud.get_urls()), name='protocolomat'),
# url(r'^protocoloadm/protocolo-list$',
# ProtocoloListView.as_view(), name='protocolo_list'),
url(r'^protocoloadm/$',
ProtocoloPesquisaView.as_view(), name='protocolo'),
url(r'^protocoloadm/protocolo-list$',
ProtocoloListView.as_view(), name='protocolo_list'),
url(r'^protocoloadm/anular-protocolo',
AnularProtocoloAdmView.as_view(), name='anular_protocolo'),
url(r'^protocoloadm/protocolar-doc',
ProtocoloDocumentoView.as_view(), name='protocolar_doc'),
url(r'^protocoloadm/(?P<pk>\d+)/protocolo-mostrar$',
ProtocoloMostrarView.as_view(), name='protocolo_mostrar'),
url(r'^protocoloadm/anular-protocolo',
AnularProtocoloAdmView.as_view(), name='anular_protocolo'),
url(r'^protocoloadm/protocolar-mat',
ProtocoloMateriaView.as_view(), name='protocolar_mat'),
# FIXME estas urls com pk e ano não fazem sentido
# se vai buscar por pk não precisa de nenhuma outra informação
# mas veja, apesar de chamar de pk aqui nas urls
# usou-se dentro da view como paramentro para ano.
url(r'^protocoloadm/(?P<pk>\d+)/(?P<ano>\d+)/protocolo-mostrar$',
ProtocoloMostrarView.as_view(), name='protocolo_mostrar'),
url(r'^protocoloadm/(?P<pk>\d+)/(?P<ano>\d+)/comprovante$',
url(r'^protocoloadm/(?P<pk>\d+)/comprovante$',
ComprovanteProtocoloView.as_view(), name='comprovante_protocolo'),
url(r'^protocoloadm/(?P<pk>\d+)/(?P<ano>\d+)/criar-documento$',
url(r'^protocoloadm/(?P<pk>\d+)/criar-documento$',
CriarDocumentoProtocolo.as_view(), name='criar_documento'),
]
urlpatterns_sistema = [

52
sapl/protocoloadm/views.py

@ -31,9 +31,9 @@ TipoDocumentoAdministrativoCrud = CrudAux.build(
TipoDocumentoAdministrativo, '')
ProtocoloDocumentoCrud = Crud.build(Protocolo, '')
#ProtocoloDocumentoCrud = Crud.build(Protocolo, '')
# FIXME precisa de uma chave diferente para o layout
ProtocoloMateriaCrud = Crud.build(Protocolo, '')
#ProtocoloMateriaCrud = Crud.build(Protocolo, '')
DocumentoAcessorioAdministrativoCrud = Crud.build(
@ -109,6 +109,8 @@ class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView):
context['page_range'] = make_pagination(
page_obj.number, paginator.num_pages)
context['title'] = _('Pesquisa de Protocolos')
return context
def get(self, request, *args, **kwargs):
@ -166,7 +168,7 @@ class AnularProtocoloAdmView(PermissionRequiredMixin, CreateView):
template_name = 'protocoloadm/anular_protocoloadm.html'
form_class = AnularProcoloAdmForm
form_valid_message = _('Protocolo anulado com sucesso!')
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.action_anular_protocolo', )
def get_success_url(self):
return reverse('sapl.protocoloadm:protocolo')
@ -195,10 +197,11 @@ class ProtocoloDocumentoView(PermissionRequiredMixin,
template_name = "protocoloadm/protocolar_documento.html"
form_class = ProtocoloDocumentForm
form_valid_message = _('Protocolo cadastrado com sucesso!')
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.add_protocolo', )
def get_success_url(self):
return reverse('sapl.protocoloadm:protocolo')
return reverse('sapl.protocoloadm:protocolo_mostrar',
kwargs={'pk': self.object.id})
def form_valid(self, form):
f = form.save(commit=False)
@ -231,31 +234,28 @@ class ProtocoloDocumentoView(PermissionRequiredMixin,
f.assunto_ementa = self.request.POST['assunto']
f.save()
self.object = f
return redirect(self.get_success_url())
class CriarDocumentoProtocolo(PermissionRequiredMixin, CreateView):
template_name = "protocoloadm/criar_documento.html"
form_class = DocumentoAdministrativoForm
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.add_documentoadministrativo',)
def get_initial(self):
numero = self.kwargs['pk']
ano = self.kwargs['ano']
protocolo = Protocolo.objects.get(ano=ano, numero=numero)
protocolo = Protocolo.objects.get(pk=self.kwargs['pk'])
return self.criar_documento(protocolo)
def get_success_url(self):
return reverse('sapl.protocoloadm:protocolo_mostrar',
kwargs={'pk': self.kwargs['pk'],
'ano': self.kwargs['ano']})
kwargs={'pk': self.kwargs['pk']})
def criar_documento(self, protocolo):
numero = Protocolo.objects.filter(
tipo_documento=protocolo.tipo_documento,
ano=protocolo.ano,
anulado=False).aggregate(Max('numero'))
numero_max = DocumentoAdministrativo.objects.filter(
tipo=protocolo.tipo_documento
).aggregate(Max('numero'))['numero__max']
doc = {}
doc['tipo'] = protocolo.tipo_documento
@ -264,24 +264,18 @@ class CriarDocumentoProtocolo(PermissionRequiredMixin, CreateView):
doc['numero_protocolo'] = protocolo.numero
doc['assunto'] = protocolo.assunto_ementa
doc['interessado'] = protocolo.interessado
doc['numero'] = numero['numero__max']
if doc['numero'] is None:
doc['numero'] = 1
else:
doc['numero'] = doc['numero'] + 1
doc['numero'] = numero_max + 1 if numero_max else 1
return doc
class ProtocoloMostrarView(PermissionRequiredMixin, TemplateView):
template_name = "protocoloadm/protocolo_mostrar.html"
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.detail_protocolo', )
def get_context_data(self, **kwargs):
context = super(ProtocoloMostrarView, self).get_context_data(**kwargs)
numero = self.kwargs['pk']
ano = self.kwargs['ano']
protocolo = Protocolo.objects.get(ano=ano, numero=numero)
protocolo = Protocolo.objects.get(pk=self.kwargs['pk'])
context['protocolo'] = protocolo
return context
@ -289,16 +283,14 @@ class ProtocoloMostrarView(PermissionRequiredMixin, TemplateView):
class ComprovanteProtocoloView(PermissionRequiredMixin, TemplateView):
template_name = "protocoloadm/comprovante.html"
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.detail_protocolo', )
def get_context_data(self, **kwargs):
context = super(ComprovanteProtocoloView, self).get_context_data(
**kwargs)
numero = self.kwargs['pk']
ano = self.kwargs['ano']
protocolo = Protocolo.objects.get(ano=ano, numero=numero)
protocolo = Protocolo.objects.get(pk=self.kwargs['pk'])
# numero is string, padd with zeros left via .zfill()
base64_data = create_barcode(numero.zfill(6))
base64_data = create_barcode(str(protocolo.numero).zfill(6))
barcode = 'data:image/png;base64,{0}'.format(base64_data)
autenticacao = _("** NULO **")
@ -320,7 +312,7 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView):
template_name = "protocoloadm/protocolar_materia.html"
form_class = ProtocoloMateriaForm
form_valid_message = _('Matéria cadastrada com sucesso!')
permission_required = permissoes_protocoloadm()
permission_required = ('protocoloadm.add_protocolo',)
def get_success_url(self):
return reverse('sapl.protocoloadm:protocolo')

3
sapl/rules/map_rules.py

@ -35,7 +35,8 @@ rules_group_protocolo = {
'rules': [
(protocoloadm.Protocolo, __base__ + [
'action_anular_protocolo']),
(protocoloadm.DocumentoAdministrativo, __listdetailchange__),
(protocoloadm.DocumentoAdministrativo,
[RP_ADD] + __listdetailchange__),
(protocoloadm.DocumentoAcessorioAdministrativo, __listdetailchange__),
(materia.MateriaLegislativa, __listdetailchange__),

2
sapl/templates/crud/detail.html

@ -41,6 +41,7 @@
{% endblock actions %}
</div>
<div class="container-detail clearfix">
{% block detail_content %}
{% for fieldset in view.layout_display %}
<h2 class="legend">{{ fieldset.legend }}</h2>
@ -65,6 +66,7 @@
{% endfor %}
{% endfor %}
{% endblock detail_content %}
</div>
{% block table_content %}
<div class="container-table">

10
sapl/templates/protocoloadm/anular_protocoloadm.html

@ -1,6 +1,16 @@
{% extends "protocoloadm/protocoloadm_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block actions %}
{{ block.super }}
<div class="actions btn-group pull-right grid-gutter-width-right " role="group">
<a href="{% url 'protocoloadm:protocolo' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
{% endblock %}
{% block detail_content %}
<div>{{ message }} </div>
{% crispy form %}

4
sapl/templates/protocoloadm/comprovante.html

@ -83,9 +83,5 @@
<th>Número Páginas</th>
<td>{{ protocolo.numero_paginas }}</td>
</tr>
<tr>
<th>Número Páginas</th>
<td>{{ protocolo.numero_paginas }}</td>
</tr>
</table>
{% endblock detail_content %}

9
sapl/templates/protocoloadm/protocolar_documento.html

@ -2,6 +2,15 @@
{% load i18n %}
{% load crispy_forms_tags %}
{% block actions %}
{{ block.super }}
<div class="actions btn-group pull-right grid-gutter-width-right " role="group">
<a href="{% url 'protocoloadm:protocolo' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
{% endblock %}
{% block detail_content %}
{% crispy form %}
{% endblock detail_content %}

8
sapl/templates/protocoloadm/protocolar_materia.html

@ -2,6 +2,14 @@
{% load i18n %}
{% load crispy_forms_tags %}
{% block actions %}
{{ block.super }}
<div class="actions btn-group pull-right grid-gutter-width-right " role="group">
<a href="{% url 'protocoloadm:protocolo' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
{% endblock %}
{% block detail_content %}
{% crispy form %}
{% endblock detail_content %}

22
sapl/templates/protocoloadm/protocolo_filter.html

@ -3,17 +3,22 @@
{% load crispy_forms_tags %}
{% load static %}
{% block sections_nav %} {% endblock %}
{% block base_content %}
<h1><b>Pesquisa de Protocolo</b></h1>
<br></br>
{% block actions %}
{{ block.super }}
{% if filter_url %}
<div class="actions btn-group pull-right" role="group">
<div class="actions btn-group pull-right grid-gutter-width-right " role="group">
<a href="{% url 'protocoloadm:protocolo' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
</div>
{% endif %}
{% endblock %}
{% block detail_content %}
<br>
{% if not filter_url %}
{% crispy filter.form %}
{% endif %}
@ -33,7 +38,7 @@
<tr>
<td>
<strong>Protocolo:
<a href="{% url 'protocoloadm:protocolo_mostrar' p.numero p.ano %}">{{ p.numero|stringformat:'06d' }}/{{ p.ano }}</a></strong>&nbsp;&nbsp;<strong>-</strong>&nbsp;&nbsp;
<a href="{% url 'protocoloadm:protocolo_mostrar' p.pk %}">{{ p.numero|stringformat:'06d' }}/{{ p.ano }}</a></strong>&nbsp;&nbsp;<strong>-</strong>&nbsp;&nbsp;
<a href="{% url 'relatorios:relatorio_etiqueta_protocolo' p.numero p.ano %}"><img src="{% static 'img/etiqueta.png' %}" alt="Etiqueta Individual"></a></br>
<strong>Assunto:</strong> {{ p.assunto_ementa|default_if_none:"Não Informado"}}</br>
<strong>Data Protocolo:</strong> {{ p.data|date:"d/m/Y"|default_if_none:"Não Informado" }} - Horário: {{ p.hora|date:"G:i:s" }}</br>
@ -50,4 +55,7 @@
</table>
{% include "paginacao.html" %}
{% endif %}
{% endblock base_content %}
{% endblock detail_content %}
{% block table_content %}
{% endblock table_content %}

4
sapl/templates/protocoloadm/protocolo_mostrar.html

@ -16,8 +16,8 @@
<br />
<strong>Documento Vinculado:</strong></br>
<a href="{% url 'sapl.protocoloadm:criar_documento' protocolo.numero protocolo.ano %}" class="btn btn-primary">Criar Documento</a>
<a href="{% url 'sapl.protocoloadm:criar_documento' protocolo.pk %}" class="btn btn-primary">Criar Documento</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="{% url 'sapl.protocoloadm:comprovante_protocolo' protocolo.numero protocolo.ano %}" target="popup" class="btn btn-primary" onclick="window.open('{% url 'sapl.protocoloadm:comprovante_protocolo' protocolo.numero protocolo.ano %}','Comprovante','width=800, height=600')">Comprovante
<a target="popup" class="btn btn-primary" onclick="window.open('{% url 'sapl.protocoloadm:comprovante_protocolo' protocolo.pk%}','Comprovante','width=800, height=600')">Comprovante
</a>
{% endblock detail_content %}

6
sapl/templates/protocoloadm/protocoloadm_detail.html

@ -1,9 +1,9 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block actions %}
{% block editions %}
<div class="actions btn-group pull-right" role="group">
<a href="{% url 'protocoloadm:protocolar_doc' %}" class="btn btn-default">{% trans 'Protocolar Documento' %}</a>
<a href="{% url 'protocoloadm:protocolar_mat' %}" class="btn btn-default">{% trans 'Protocolar Matéria' %}</a>
<a href="{% url 'protocoloadm:anular_protocolo' %}" class="btn btn-default">{% trans 'Anular Protocolo' %}</a>
<a href="{% url 'protocoloadm:anular_protocolo' %}" class="btn btn-default btn-excluir">{% trans 'Anular Protocolo' %}</a>
</div>
{% endblock actions %}
{% endblock editions %}

Loading…
Cancel
Save