Browse Source

Ajusta de busca de mat e crud de legislacaocitada

pull/691/head
LeandroRoberto 8 years ago
parent
commit
98713161b9
  1. 2
      sapl/crud/base.py
  2. 51
      sapl/materia/views.py
  3. 2
      sapl/templates/crud/detail.html
  4. 14
      sapl/templates/materia/materialegislativa_filter.html
  5. 6
      sapl/templates/materia/subnav.yaml

2
sapl/crud/base.py

@ -316,7 +316,7 @@ class CrudBaseMixin(CrispyLayoutFormMixin):
def delete_url(self):
obj = self.crud if hasattr(self, 'crud') else self
if not obj.DeleteView.permission_required:
return self.resolve_url(ACTION_DELETE)
return self.resolve_url(ACTION_DELETE, args=(self.object.id,))
else:
return self.resolve_url(ACTION_DELETE, args=(self.object.id,))\
if self.request.user.has_perm(

51
sapl/materia/views.py

@ -27,8 +27,10 @@ from sapl.base.models import CasaLegislativa
from sapl.compilacao.views import IntegracaoTaView
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, CrudDetailView,
MasterDetailCrud, make_pagination)
from sapl.materia.forms import AnexadaForm
MasterDetailCrud, make_pagination,
ACTION_CREATE, ACTION_UPDATE, ACTION_LIST,
ACTION_DELETE)
from sapl.materia.forms import AnexadaForm, LegislacaoCitadaForm
from sapl.norma.models import LegislacaoCitada
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label,
autor_modal, gerar_hash_arquivo, get_base_url,
@ -51,8 +53,7 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
Tramitacao, UnidadeTramitacao)
AnexadaCrud = Crud.build(Anexada, '')
#AnexadaCrud = Crud.build(Anexada, '')
OrigemCrud = Crud.build(Origem, '')
TipoMateriaCrud = CrudAux.build(
@ -720,7 +721,37 @@ class LegislacaoCitadaCrud(MasterDetailCrud):
return reverse('%s:%s' % (namespace, self.url_name(suffix)),
args=args)
def has_permission(self):
return self.request.user.has_module_perms('materia')
@property
def list_url(self):
return self.resolve_url(ACTION_LIST, args=(self.kwargs['pk'],))\
if self.request.user.has_module_perms('materia') else ''
@property
def create_url(self):
obj = self.crud if hasattr(self, 'crud') else self
if not obj.CreateView:
return ''
return self.resolve_url(ACTION_CREATE, args=(self.kwargs['pk'],))\
if self.request.user.has_module_perms('materia') else ''
@property
def update_url(self):
return self.resolve_url(ACTION_CREATE, args=(self.kwargs['pk'],))\
if self.request.user.has_module_perms('materia') else ''
@property
def delete_url(self):
return self.resolve_url(ACTION_DELETE, args=(self.object.id,))\
if self.request.user.has_module_perms('materia') else ''
class CreateView(MasterDetailCrud.CreateView):
form_class = LegislacaoCitadaForm
class UpdateView(MasterDetailCrud.UpdateView):
form_class = LegislacaoCitadaForm
def get_initial(self):
self.initial['tipo'] = self.object.norma.tipo.id
@ -751,6 +782,18 @@ class AnexadaCrud(MasterDetailCrud):
class BaseMixin(MasterDetailCrud.BaseMixin):
list_field_names = ['materia_anexada', 'data_anexacao']
class CreateView(MasterDetailCrud.CreateView):
form_class = AnexadaForm
class UpdateView(MasterDetailCrud.UpdateView):
form_class = AnexadaForm
def get_initial(self):
self.initial['tipo'] = self.object.materia_anexada.tipo.id
self.initial['numero'] = self.object.materia_anexada.numero
self.initial['ano'] = self.object.materia_anexada.ano
return self.initial
class DetailView(MasterDetailCrud.DetailView):
@property

2
sapl/templates/crud/detail.html

@ -48,6 +48,7 @@
{% endfor %}
{% endblock detail_content %}
{% block table_content %}
<div class="container-table">
{% if not rows %}
<p>{{ NO_ENTRIES_MSG }}</p>
@ -80,4 +81,5 @@
{% endif %}
</div>
{% include "paginacao.html" %}
{% endblock table_content %}
{% endblock base_content %}

14
sapl/templates/materia/materialegislativa_filter.html

@ -2,7 +2,7 @@
{% load i18n %}
{% load crispy_forms_tags %}
{% block actions %}
{% block actions %}
<div class="actions btn-group pull-right" role="group">
{% if user.is_authenticated %}
<a href="{% url 'sapl.materia:materialegislativa_create' %}" class="btn btn-default">
@ -13,13 +13,9 @@
<a href="{% url 'sapl.materia:pesquisar_materia' %}" class="btn btn-default">{% trans 'Fazer nova pesquisa' %}</a>
{% endif %}
</div>
{% endblock %}
{% block sections_nav %}
{% endblock %}
{% block base_content %}
{% endblock %}
{% block detail_content %}
{% if not filter_url %}
{% crispy filter.form %}
{% endif %}
@ -62,4 +58,6 @@
</table>
{% include "paginacao.html" %}
{% endif %}
{% endblock base_content %}
{% endblock detail_content %}
{% block table_content %}
{% endblock table_content %}

6
sapl/templates/materia/subnav.yaml

@ -11,16 +11,12 @@
url: documentoacessorio_list
- title: {% trans 'Legislação Citada' %}
url: legislacaocitada_list
app_name: 'materia'
- title: {% trans 'Numeração' %}
url: numeracao_list
- title: {% trans 'Tramitação' %}
url: tramitacao_list
- title: {% trans 'Relatoria' %}
url: relatoria_list
# Opção adicionada para chamar o TextoArticulado da matéria.
# para integração foram necessárias apenas criar a url materia_ta em urls.py
# e a view MateriaTaView(IntegracaoTaView) em views.py
# Em nada mais a integração interfere em MateriaLegislativa
- title: {% trans 'Texto' %}
url: materia_ta

Loading…
Cancel
Save