From 8e3db9630b1e6a59b4cf7dbcd663eede2f440c01 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Wed, 14 Jun 2017 08:56:28 -0300 Subject: [PATCH] Fix #1187 --- sapl/base/templatetags/common_tags.py | 12 ++++++ sapl/crispy_layout_mixin.py | 25 +++++++++---- sapl/materia/views.py | 24 ++++++------ sapl/templates/materia/proposicao_detail.html | 37 ++++++++++++------- 4 files changed, 65 insertions(+), 33 deletions(-) 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 = '