diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py
index eb53629a0..0f274ab29 100644
--- a/sapl/base/templatetags/common_tags.py
+++ b/sapl/base/templatetags/common_tags.py
@@ -168,3 +168,15 @@ def search_get_model(object):
return 'n'
return None
+
+
+@register.filter
+def urldetail_content_type(obj, value):
+ return '%s:%s_detail' % (
+ value._meta.app_config.name, obj.content_type.model)
+
+
+@register.filter
+def urldetail(obj):
+ return '%s:%s_detail' % (
+ obj._meta.app_config.name, obj._meta.model_name)
diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py
index 369b6fe9e..29cd7849f 100644
--- a/sapl/crispy_layout_mixin.py
+++ b/sapl/crispy_layout_mixin.py
@@ -1,12 +1,13 @@
from math import ceil
-import rtyaml
from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit
from django import template
+from django.core.urlresolvers import reverse
from django.utils import formats
from django.utils.translation import ugettext as _
+import rtyaml
def heads_and_tails(list_of_lists):
@@ -77,29 +78,30 @@ def get_field_display(obj, fieldname):
else:
value = getattr(obj, fieldname)
- str_type = str(type(value))
+ str_type_from_value = str(type(value))
+ str_type_from_field = str(type(field))
if value is None:
display = ''
- elif 'date' in str_type:
+ elif 'date' in str_type_from_value:
display = formats.date_format(value, "SHORT_DATE_FORMAT")
- elif 'bool' in str(type(value)):
+ elif 'bool' in str_type_from_value:
display = _('Sim') if value else _('Não')
elif 'ImageFieldFile' in str(type(value)):
if value:
display = ''.format(value.url)
else:
display = ''
- elif 'FieldFile' in str(type(value)):
+ elif 'FieldFile' in str_type_from_value:
if value:
display = '{}'.format(
value.url,
value.name.split('/')[-1:][0])
else:
display = ''
- elif 'ManyRelatedManager' in str(type(value))\
- or 'RelatedManager' in str(type(value))\
- or 'GenericRelatedObjectManager' in str(type(value)):
+ elif 'ManyRelatedManager' in str_type_from_value\
+ or 'RelatedManager' in str_type_from_value\
+ or 'GenericRelatedObjectManager' in str_type_from_value:
display = '
'
for v in value.all():
display += '- %s
' % str(v)
@@ -110,6 +112,13 @@ def get_field_display(obj, fieldname):
field.related_model._meta.verbose_name_plural)
elif hasattr(field, 'model'):
verbose_name = str(field.model._meta.verbose_name_plural)
+ elif 'GenericForeignKey' in str_type_from_field:
+ display = '{}'.format(
+ reverse(
+ '%s:%s_detail' % (
+ value._meta.app_config.name, obj.content_type.model),
+ args=(value.id,)),
+ value)
else:
display = str(value)
return verbose_name, display
diff --git a/sapl/materia/views.py b/sapl/materia/views.py
index 69da1c757..5ceb73377 100644
--- a/sapl/materia/views.py
+++ b/sapl/materia/views.py
@@ -21,7 +21,6 @@ from django.views.generic.base import RedirectView
from django.views.generic.edit import FormView
from django_filters.views import FilterView
-import sapl
from sapl.base.models import Autor, CasaLegislativa
from sapl.comissoes.models import Comissao, Participacao
from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_RESTRICT,
@@ -42,6 +41,7 @@ from sapl.settings import EMAIL_SEND_USER
from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label,
autor_modal, gerar_hash_arquivo, get_base_url,
montar_row_autor)
+import sapl
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm,
AdicionarVariasAutoriasFilterSet, DespachoInicialForm,
@@ -446,7 +446,7 @@ class ReceberProposicao(PermissionRequiredForAppCrudMixin, FormView):
hasher = gerar_hash_arquivo(
proposicao.texto_original.path,
str(proposicao.pk)) \
- if proposicao.texto_original else None
+ if proposicao.texto_original else None
if hasher == form.cleaned_data['cod_hash']:
return HttpResponseRedirect(
reverse('sapl.materia:proposicao-confirmar',
@@ -551,7 +551,7 @@ class ProposicaoCrud(Crud):
class BaseMixin(Crud.BaseMixin):
list_field_names = ['data_envio', 'data_recebimento', 'descricao',
- 'tipo']
+ 'tipo', 'conteudo_gerado_related']
class BaseLocalMixin:
form_class = ProposicaoForm
@@ -914,7 +914,7 @@ class TramitacaoCrud(MasterDetailCrud):
id=request.POST['status']).first()
unidade_destino = UnidadeTramitacao.objects.get(
id=request.POST['unidade_tramitacao_destino']
- )
+ )
texto = request.POST['texto']
data_tramitacao = request.POST['data_tramitacao']
do_envia_email_tramitacao(
@@ -934,7 +934,7 @@ class TramitacaoCrud(MasterDetailCrud):
id=request.POST['status']).first()
unidade_destino = UnidadeTramitacao.objects.get(
id=request.POST['unidade_tramitacao_destino']
- )
+ )
texto = request.POST['texto']
data_tramitacao = request.POST['data_tramitacao']
do_envia_email_tramitacao(
@@ -1494,8 +1494,8 @@ def criar_email_confirmacao(request, casa_legislativa, materia, hash_txt=''):
def criar_email_tramitacao(
- request, casa_legislativa, materia, status,
- unidade_destino, texto, data_tramitacao, hash_txt=''):
+ request, casa_legislativa, materia, status,
+ unidade_destino, texto, data_tramitacao, hash_txt=''):
if not casa_legislativa:
raise ValueError("Casa Legislativa é obrigatória")
@@ -1612,7 +1612,7 @@ def do_envia_email_confirmacao(request, materia, email):
def do_envia_email_tramitacao(
- request, materia, status, unidade_destino, texto, data_tramitacao):
+ request, materia, status, unidade_destino, texto, data_tramitacao):
#
# Envia email de tramitacao para usuarios cadastrados
#
@@ -1787,10 +1787,10 @@ class TramitacaoEmLoteView(PrimeiraTramitacaoEmLoteView):
qr = self.request.GET.copy()
if ('tramitacao__status' in qr and
- 'tramitacao__unidade_tramitacao_destino' in qr and
- qr['tramitacao__status'] and
- qr['tramitacao__unidade_tramitacao_destino']
- ):
+ 'tramitacao__unidade_tramitacao_destino' in qr and
+ qr['tramitacao__status'] and
+ qr['tramitacao__unidade_tramitacao_destino']
+ ):
lista = filtra_tramitacao_destino_and_status(
qr['tramitacao__status'],
qr['tramitacao__unidade_tramitacao_destino'])
diff --git a/sapl/templates/materia/proposicao_detail.html b/sapl/templates/materia/proposicao_detail.html
index 007b63b6b..5039cce6b 100644
--- a/sapl/templates/materia/proposicao_detail.html
+++ b/sapl/templates/materia/proposicao_detail.html
@@ -110,19 +110,30 @@
- {% if object.materia_de_vinculo %}
- {% trans "Vínculo com a Matéria Legislativa" %}
-
-
-
{% endblock detail_content %}