Browse Source

Conserta relatoria de matérias (#3692)

Fix relatoria de matérias
pull/3694/head
Edward 1 year ago
committed by GitHub
parent
commit
6c002459a3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      sapl/crispy_layout_mixin.py
  2. 20
      sapl/crud/base.py
  3. 3
      sapl/materia/views.py
  4. 15
      sapl/templates/materia/layouts.yaml
  5. 2
      sapl/templates/norma/layouts.yaml
  6. 6
      sapl/templates/protocoloadm/layouts.yaml
  7. 1
      sapl/templates/sessao/blocos_ata/ocorrencias_da_sessao.html
  8. 2
      sapl/templates/sessao/layouts.yaml

10
sapl/crispy_layout_mixin.py

@ -284,7 +284,7 @@ class CrispyLayoutFormMixin:
'text': field_display, 'text': field_display,
} }
def fk_urlize_for_detail(self, obj, fieldname): def fk_urlify_for_detail(self, obj, fieldname):
field = obj._meta.get_field(fieldname) field = obj._meta.get_field(fieldname)
value = getattr(obj, fieldname) value = getattr(obj, fieldname)
@ -298,6 +298,14 @@ class CrispyLayoutFormMixin:
return field.verbose_name, display return field.verbose_name, display
def fk_urlify_for_list(self, obj, field):
value = getattr(obj, field)
return reverse(
'%s:%s_detail' % (
value._meta.app_config.name,
value._meta.model_name),
kwargs={'pk': value.id}),
def m2m_urlize_for_detail(self, obj, fieldname): def m2m_urlize_for_detail(self, obj, fieldname):
manager, fieldname = tuple(fieldname.split('__')) manager, fieldname = tuple(fieldname.split('__'))

20
sapl/crud/base.py

@ -413,7 +413,7 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView):
'composicao__periodo__data_inicio', 'composicao__periodo__data_fim')] 'composicao__periodo__data_inicio', 'composicao__periodo__data_fim')]
""" """
r = [] r = []
for fieldname in self.list_field_names: for (fieldname, _) in self._parse_field_names(self.list_field_names):
if not isinstance(fieldname, tuple): if not isinstance(fieldname, tuple):
fieldname = fieldname, fieldname = fieldname,
s = [] s = []
@ -446,14 +446,26 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView):
r.append(s) r.append(s)
return r return r
def _parse_field_names(self, field_name_list):
parsed_list = []
for field_name in field_name_list:
field_tuple = tuple(field_name.split('|')) \
if '|' in field_name else (field_name, None)
parsed_list.append(field_tuple)
return parsed_list
def _as_row(self, obj): def _as_row(self, obj):
r = [] r = []
for i, name in enumerate(self.list_field_names): for i, (name, func) in enumerate(self._parse_field_names(self.list_field_names)):
# URL padrão para primeira coluna da listagem
url = self.resolve_url( url = self.resolve_url(
ACTION_DETAIL, args=(obj.id,)) if i == 0 else None ACTION_DETAIL, args=(obj.id,)) if i == 0 else None
# gera URL para matéria a partir de fk_urlify_for_list em layouts.yaml
if i > 0 and func is not None:
url = getattr(self, func)(obj, name)[0]
"""Caso o crud list seja para uma relação ManyToManyField""" """Caso o crud list seja para uma relação ManyToManyField"""
if url and hasattr(self, 'crud') and\ if url and hasattr(self, 'crud') and \
hasattr(self.crud, 'is_m2m') and self.crud.is_m2m: hasattr(self.crud, 'is_m2m') and self.crud.is_m2m:
url = url + ('?pkk=' + self.kwargs['pk'] url = url + ('?pkk=' + self.kwargs['pk']
if 'pk' in self.kwargs else '') if 'pk' in self.kwargs else '')
@ -483,7 +495,7 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView):
if m: if m:
ss = get_field_display(m, n[-1])[1] ss = get_field_display(m, n[-1])[1]
ss = ( ss = (
('<br>' if '<ul>' in ss else ' - ') + ss)\ ('<br>' if '<ul>' in ss else ' - ') + ss) \
if ss and j != 0 and s else ss if ss and j != 0 and s else ss
except: except:
pass pass

3
sapl/materia/views.py

@ -1337,6 +1337,9 @@ class RelatoriaCrud(MasterDetailCrud):
return {'comissao': localizacao} return {'comissao': localizacao}
class ListView(MasterDetailCrud.ListView):
layout_key = 'RelatoriaList'
class UpdateView(MasterDetailCrud.UpdateView): class UpdateView(MasterDetailCrud.UpdateView):
form_class = RelatoriaForm form_class = RelatoriaForm
layout_key = None layout_key = None

15
sapl/templates/materia/layouts.yaml

@ -59,8 +59,8 @@ Anexada:
AnexadaDetail: AnexadaDetail:
{% trans 'Matéria Anexada' %}: {% trans 'Matéria Anexada' %}:
- materia_principal|fk_urlize_for_detail - materia_principal|fk_urlify_for_detail
- materia_anexada|fk_urlize_for_detail - materia_anexada|fk_urlify_for_detail
- data_anexacao data_desanexacao - data_anexacao data_desanexacao
Autoria: Autoria:
@ -86,11 +86,18 @@ Orgao:
Relatoria: Relatoria:
{% trans 'Relatoria' %}: {% trans 'Relatoria' %}:
- comissao|fk_urlize_for_detail - comissao
- materia|fk_urlize_for_detail - materia
- data_designacao_relator data_destituicao_relator - data_designacao_relator data_destituicao_relator
- parlamentar tipo_fim_relatoria - parlamentar tipo_fim_relatoria
RelatoriaList:
{% trans 'Relatoria' %}:
- comissao
- materia|fk_urlify_for_list
- data_designacao_relator data_destituicao_relator
- parlamentar|fk_urlify_for_list tipo_fim_relatoria
TipoProposicao: TipoProposicao:
{% trans 'Tipo Proposição' %}: {% trans 'Tipo Proposição' %}:
- descricao content_type - descricao content_type

2
sapl/templates/norma/layouts.yaml

@ -51,7 +51,7 @@ LegislacaoCitada:
LegislacaoCitadaDetail: LegislacaoCitadaDetail:
{% trans 'Legislação Citada' %}: {% trans 'Legislação Citada' %}:
- norma|fk_urlize_for_detail - norma|fk_urlify_for_detail
- disposicoes parte livro titulo - disposicoes parte livro titulo
- capitulo secao subsecao artigo - capitulo secao subsecao artigo
- paragrafo inciso alinea item - paragrafo inciso alinea item

6
sapl/templates/protocoloadm/layouts.yaml

@ -43,8 +43,8 @@ Anexado:
AnexadoDetail: AnexadoDetail:
{% trans 'Documento Anexado' %}: {% trans 'Documento Anexado' %}:
- documento_principal|fk_urlize_for_detail - documento_principal|fk_urlify_for_detail
- documento_anexado|fk_urlize_for_detail - documento_anexado|fk_urlify_for_detail
- data_anexacao data_desanexacao - data_anexacao data_desanexacao
Protocolo: Protocolo:
@ -70,5 +70,5 @@ VinculoDocAdminMateria:
VinculoDocAdminMateriaDetail: VinculoDocAdminMateriaDetail:
{% trans 'Matéria Vinculada' %}: {% trans 'Matéria Vinculada' %}:
- materia|fk_urlize_for_detail data_anexacao:3 data_desanexacao:3 - materia|fk_urlify_for_detail data_anexacao:3 data_desanexacao:3
- documento - documento

1
sapl/templates/sessao/blocos_ata/ocorrencias_da_sessao.html

@ -3,7 +3,6 @@
<p style="text-align: justify;margin-top: 0"> <p style="text-align: justify;margin-top: 0">
<strong>Ocorrências da Sessão: </strong> <strong>Ocorrências da Sessão: </strong>
{{ object.ocorrenciasessao.conteudo|striptags|safe }} {{ object.ocorrenciasessao.conteudo|striptags|safe }}
</p> </p>
</fieldset> </fieldset>
{% endif %} {% endif %}

2
sapl/templates/sessao/layouts.yaml

@ -133,5 +133,5 @@ Correspondencia:
CorrespondenciaDetail: CorrespondenciaDetail:
{% trans 'Correspondencia' %}: {% trans 'Correspondencia' %}:
- numero_ordem:2 tipo:3 sessao_plenaria - numero_ordem:2 tipo:3 sessao_plenaria
- documento|fk_urlize_for_detail - documento|fk_urlify_for_detail
- observacao - observacao
Loading…
Cancel
Save