diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py
index e12c7493b..e5f66a37c 100644
--- a/sapl/materia/forms.py
+++ b/sapl/materia/forms.py
@@ -1,5 +1,6 @@
from datetime import datetime
+import django_filters
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout
from django import forms
@@ -11,7 +12,6 @@ from django.db import models, transaction
from django.db.models import Max
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
-import django_filters
from sapl.comissoes.models import Comissao
from sapl.crispy_layout_mixin import form_actions, to_row
@@ -26,7 +26,6 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa,
Tramitacao, UnidadeTramitacao)
-
ANO_CHOICES = [('', '---------')] + RANGE_ANOS
@@ -662,9 +661,8 @@ class AutorForm(ModelForm):
'email',
'nome',
'tipo',
- 'cargo',
- 'parlamentar',
- 'comissao']
+ 'cargo']
+ widgets = {'nome': forms.HiddenInput()}
def valida_igualdade(self, texto1, texto2, msg):
if texto1 != texto2:
diff --git a/sapl/materia/views.py b/sapl/materia/views.py
index 4d0bcd5e2..afc1f091f 100644
--- a/sapl/materia/views.py
+++ b/sapl/materia/views.py
@@ -118,21 +118,64 @@ class TipoAutorCrud(Crud):
return permissao_tb_aux(self)
+def montar_helper_autor(self):
+ autor_row = montar_row_autor('nome')
+ self.helper = FormHelper()
+ self.helper.layout = SaplFormLayout(*self.get_layout())
+
+ # Adiciona o novo campo 'autor' e mecanismo de busca
+ self.helper.layout[0][0].append(HTML(autor_label))
+ self.helper.layout[0][0].append(HTML(autor_modal))
+ self.helper.layout[0][1] = autor_row
+
+ # Adiciona espaço entre o novo campo e os botões
+ # self.helper.layout[0][4][1].append(HTML('
'))
+
+ # Remove botões que estão fora do form
+ self.helper.layout[1].pop()
+
+ # Adiciona novos botões dentro do form
+ self.helper.layout[0][4][0].insert(2, form_actions(more=[
+ HTML('Cancelar')]))
+
+
class AutorCrud(Crud):
model = Autor
help_path = 'autor'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
- list_field_names = ['tipo', 'nome',
- 'username', 'cargo']
+ list_field_names = ['tipo', 'nome']
def has_permission(self):
return permissao_tb_aux(self)
+ class UpdateView(CrudUpdateView):
+ form_class = AutorForm
+ layout_key = 'AutorCreate'
+
+ def __init__(self, *args, **kwargs):
+ montar_helper_autor(self)
+ super(UpdateView, self).__init__(*args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ context = super(UpdateView, self).get_context_data(**kwargs)
+ context['helper'] = self.helper
+ return context
+
class CreateView(CrudCreateView):
form_class = AutorForm
layout_key = 'AutorCreate'
+ def __init__(self, *args, **kwargs):
+ montar_helper_autor(self)
+ super(CreateView, self).__init__(*args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ context = super(CreateView, self).get_context_data(**kwargs)
+ context['helper'] = self.helper
+ return context
+
def get_success_url(self):
pk_autor = Autor.objects.get(
email=self.request.POST.get('email')).id
@@ -663,9 +706,9 @@ class TramitacaoCrud(MasterDetailCrud):
return HttpResponseRedirect(url)
-def montar_row_autor():
+def montar_row_autor(name):
autor_row = to_row(
- [('autor', 0),
+ [(name, 0),
(Button('pesquisar',
'Pesquisar Autor',
css_class='btn btn-primary btn-sm'), 2),
@@ -677,7 +720,7 @@ def montar_row_autor():
def montar_helper_documento_acessorio(self):
- autor_row = montar_row_autor()
+ autor_row = montar_row_autor('autor')
self.helper = FormHelper()
self.helper.layout = SaplFormLayout(*self.get_layout())
diff --git a/sapl/protocoloadm/urls.py b/sapl/protocoloadm/urls.py
index 2c7f4f529..c98afe4c1 100644
--- a/sapl/protocoloadm/urls.py
+++ b/sapl/protocoloadm/urls.py
@@ -43,9 +43,9 @@ urlpatterns = [
include(ProtocoloMateriaCrud.get_urls()), name='protocolomat'),
url(r'^protocoloadm/protocolo$',
ProtocoloPesquisaView.as_view(), name='protocolo'),
- url(r'^protocoloadm/protocolo_list$',
+ url(r'^protocoloadm/protocolo-list$',
ProtocoloListView.as_view(), name='protocolo_list'),
- url(r'^protocoloadm/(?P\d+)/(?P\d+)/protocolo_mostrar$',
+ url(r'^protocoloadm/(?P\d+)/(?P\d+)/protocolo-mostrar$',
ProtocoloMostrarView.as_view(), name='protocolo_mostrar'),
url(r'^protocoloadm/anular-protocolo',
AnularProtocoloAdmView.as_view(), name='anular_protocolo'),
@@ -66,12 +66,12 @@ urlpatterns = [
url(r'^protocoloadm/(?P\d+)/(?P\d+)/comprovante$',
ComprovanteProtocoloView.as_view(), name='comprovante_protocolo'),
- url(r'^protocoloadm/(?P\d+)/(?P\d+)/criar_documento$',
+ url(r'^protocoloadm/(?P\d+)/(?P\d+)/criar-documento$',
CriarDocumentoProtocolo.as_view(), name='criar_documento'),
# FIXME: Usado para pesquisar autor
# Melhor forma de fazer?
# Deve mudar de app?
- url(r'^proposicao/pesquisar_autor',
+ url(r'^proposicao/pesquisar-autor',
pesquisa_autores, name='pesquisar_autor'),
]
diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py
index be02f467b..c9fffea30 100644
--- a/sapl/protocoloadm/views.py
+++ b/sapl/protocoloadm/views.py
@@ -95,7 +95,7 @@ class ProtocoloPesquisaView(PermissionRequiredMixin, FilterView):
kwargs = {'data': self.request.GET or None}
- qs = self.get_queryset()
+ qs = self.get_queryset().order_by('ano', 'numero')
qs = qs.distinct()
diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js
index b9d4d08f8..84ceb0e8a 100644
--- a/sapl/static/js/app.js
+++ b/sapl/static/js/app.js
@@ -90,7 +90,7 @@ function autorModal() {
$("#pesquisar").click(function() {
var query = $("#q").val()
- $.get("/proposicao/pesquisar_autor?q="+ query, function(
+ $.get("/proposicao/pesquisar-autor?q="+ query, function(
data, status){
$("#div-resultado").children().remove();
@@ -142,7 +142,7 @@ function autorModal() {
if ($(fieldname).length > 0) { // se campo existir
if ($(fieldname).val() != "") { // e não for vazio
var id = $(fieldname).val();
- $.get("/proposicao/get_nome_autor?id=" + id, function(data, status){
+ $.get("/proposicao/get-nome-autor?id=" + id, function(data, status){
$("#nome_autor").text(data.nome);
});
}
diff --git a/sapl/templates/materia/autor_form.html b/sapl/templates/materia/autor_form.html
new file mode 100644
index 000000000..fb5810653
--- /dev/null
+++ b/sapl/templates/materia/autor_form.html
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% load i18n crispy_forms_tags %}
+
+{% block base_content %}
+ {% crispy form helper %}
+{% endblock %}
diff --git a/sapl/templates/materia/layouts.yaml b/sapl/templates/materia/layouts.yaml
index d5ade5b8c..c61375b58 100644
--- a/sapl/templates/materia/layouts.yaml
+++ b/sapl/templates/materia/layouts.yaml
@@ -58,10 +58,11 @@ Autor:
AutorCreate:
Autor:
- - tipo:3 nome
+ - tipo
+ - nome
- username:4 senha:4 senha_confirma:4
- email:6 confirma_email:6
- - cargo:4 parlamentar:4 comissao:4
+ - cargo
Autoria:
{% trans 'Autoria' %}: