Browse Source

Adiciona modal para selecao de autor

pull/258/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
c0fb1f79f8
  1. 5
      materia/forms.py
  2. 18
      materia/urls.py
  3. 1
      materia/views.py
  4. 4
      protocoloadm/urls.py
  5. 37
      protocoloadm/views.py
  6. 20
      sapl/utils.py

5
materia/forms.py

@ -1,10 +1,11 @@
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, Fieldset, Layout, Submit, Button, HTML from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Submit
from django import forms from django import forms
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import sapl
import crispy_layout_mixin import crispy_layout_mixin
import sapl
from crispy_layout_mixin import form_actions from crispy_layout_mixin import form_actions
from norma.models import LegislacaoCitada, TipoNormaJuridica from norma.models import LegislacaoCitada, TipoNormaJuridica
from parlamentares.models import Parlamentar, Partido from parlamentares.models import Parlamentar, Partido

18
materia/urls.py

@ -11,15 +11,15 @@ from materia.views import (AcompanhamentoConfirmarView,
MateriaAnexadaEditView, MateriaAnexadaView, MateriaAnexadaEditView, MateriaAnexadaView,
MateriaLegislativaPesquisaView, MateriaTaView, MateriaLegislativaPesquisaView, MateriaTaView,
NumeracaoEditView, NumeracaoView, NumeracaoEditView, NumeracaoView,
PesquisaMateriaListView, ProposicaoListView, PesquisaMateriaListView, ProposicaoEditView,
ProposicaoTaView, ProposicaoView, RelatoriaEditView, ProposicaoListView, ProposicaoTaView,
RelatoriaView, TramitacaoEditView, TramitacaoView, ProposicaoView, RelatoriaEditView, RelatoriaView,
autor_crud, materia_legislativa_crud, orgao_crud, TramitacaoEditView, TramitacaoView, autor_crud,
origem_crud, regime_tramitacao_crud, materia_legislativa_crud, orgao_crud, origem_crud,
status_tramitacao_crud, tipo_autor_crud, regime_tramitacao_crud, status_tramitacao_crud,
tipo_documento_crud, tipo_fim_relatoria_crud, tipo_autor_crud, tipo_documento_crud,
tipo_materia_crud, tipo_proposicao_crud, tipo_fim_relatoria_crud, tipo_materia_crud,
unidade_tramitacao_crud, ProposicaoEditView) tipo_proposicao_crud, unidade_tramitacao_crud)
materia_legislativa_patterns = materia_legislativa_crud.urlpatterns materia_legislativa_patterns = materia_legislativa_crud.urlpatterns

1
materia/views.py

@ -1404,6 +1404,7 @@ class ProposicaoEditView(CreateView):
else: else:
return self.render_to_response({'form': form}) return self.render_to_response({'form': form})
class MateriaTaView(IntegracaoTaView): class MateriaTaView(IntegracaoTaView):
model = MateriaLegislativa model = MateriaLegislativa
model_type_foreignkey = TipoMateriaLegislativa model_type_foreignkey = TipoMateriaLegislativa

4
protocoloadm/urls.py

@ -18,7 +18,7 @@ from protocoloadm.views import (AnularProtocoloAdmView,
TramitacaoAdmIncluirView, TramitacaoAdmView, TramitacaoAdmIncluirView, TramitacaoAdmView,
documento_acessorio_administrativo_crud, documento_acessorio_administrativo_crud,
documento_administrativo_crud, documento_administrativo_crud,
protocolo_documento_crud, pesquisa_autores, protocolo_documento_crud,
protocolo_materia_crud, protocolo_materia_crud,
status_tramitacao_administrativo_crud, status_tramitacao_administrativo_crud,
tipo_documento_administrativo_crud, tipo_documento_administrativo_crud,
@ -91,4 +91,6 @@ urlpatterns = [
name='proposicoes_incorporadas'), name='proposicoes_incorporadas'),
url(r'^proposicoes/(?P<pk>\d+)/proposicao', url(r'^proposicoes/(?P<pk>\d+)/proposicao',
ProposicaoDetailView.as_view(), name='proposicao_view'), ProposicaoDetailView.as_view(), name='proposicao_view'),
url(r'^proposicoes/pesquisar_autores',
pesquisa_autores, name='pesquisar_autores')
] ]

37
protocoloadm/views.py

@ -1,10 +1,11 @@
import json
from datetime import date, datetime from datetime import date, datetime
from re import sub from re import sub
from braces.views import FormValidMessageMixin from braces.views import FormValidMessageMixin
from django.core.urlresolvers import reverse, reverse_lazy from django.core.urlresolvers import reverse, reverse_lazy
from django.db.models import Max from django.db.models import Q, Max
from django.http import HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.html import strip_tags from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@ -656,3 +657,35 @@ class TramitacaoAdmDeleteView(DetailView):
return self.render_to_response({'documento': documento, return self.render_to_response({'documento': documento,
'tramitacoes': tramitacoes}) 'tramitacoes': tramitacoes})
def pesquisa_autores(request):
q = ''
if request.method == 'GET':
q = request.GET.get('q', '')
autor = Autor.objects.filter(
Q(nome__icontains=q) |
Q(parlamentar__nome_parlamentar__icontains=q) |
Q(comissao__nome__icontains=q)
)
autores = []
for a in autor:
nome = ''
if a.nome:
nome = a.nome
elif a.parlamentar:
nome = a.parlamentar.nome_parlamentar
elif a.comissao:
nome = a.comissao.nome
autores.append((a.id, nome))
autores = sorted(autores, key=lambda x: x[1])
return HttpResponse(json.dumps(autores,
sort_keys=True,
ensure_ascii=False),
content_type="application/json; charset=utf-8")

20
sapl/utils.py

@ -5,6 +5,26 @@ from django.apps import apps
from django.contrib import admin from django.contrib import admin
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
autor_label = '''
<div class="col-xs-12">
Autor: <span id="nome_autor"></span>
</div>
'''
autor_modal = '''
<div id="modal_autor" title="Selecione o Autor" align="center">
<form>
<input id="q" type="text" />
<input id="pesquisar" type="submit" value="Pesquisar"
class="btn btn-primary btn-sm"/>
</form>
<div id="div-resultado"></div>
<input type="submit" id="selecionar" value="Selecionar"
hidden="true" />
</div>
'''
def register_all_models_in_admin(module_name): def register_all_models_in_admin(module_name):
appname = module_name.split('.')[0] appname = module_name.split('.')[0]

Loading…
Cancel
Save