From 22b87f36ebc8659a6ecaf8831ab0f425206b0993 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Sun, 6 Jan 2019 16:49:40 -0200 Subject: [PATCH] =?UTF-8?q?bump=20django-crispy-forms=20e=20ajustes=20de?= =?UTF-8?q?=20c=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements/requirements.txt | 2 +- sapl/utils.py | 16 ++++++++++++---- setup.py | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 944b300d7..7b6dc25c1 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -6,8 +6,8 @@ djangorestframework==3.9.0 dj-database-url==0.5.0 django-bower==5.2.0 django-braces==1.9.0 +django-crispy-forms==1.7.2 -django-crispy-forms==1.6.1 django-extensions==1.9.8 django-extra-views==0.11.0 django-floppyforms==1.6.2 diff --git a/sapl/utils.py b/sapl/utils.py index c884a8c48..706d5cb65 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -208,19 +208,27 @@ class RangeWidgetOverride(forms.MultiWidget): def __init__(self, attrs=None): widgets = (forms.DateInput(format='%d/%m/%Y', - attrs={'class': 'dateinput', + attrs={'class': 'dateinput form-control', 'placeholder': 'Inicial'}), forms.DateInput(format='%d/%m/%Y', - attrs={'class': 'dateinput', + attrs={'class': 'dateinput form-control', 'placeholder': 'Final'})) super(RangeWidgetOverride, self).__init__(widgets, attrs) def decompress(self, value): if value: return [value.start, value.stop] - return [None, None] + return [] + + def render(self, name, value, attrs=None, renderer=None): + rendered_widgets = [] + for i, x in enumerate(self.widgets): + rendered_widgets.append( + x.render( + '%s_%d' % (name, i), value[i] if value else '' + ) + ) - def format_output(self, rendered_widgets): html = '
%s
%s
'\ % tuple(rendered_widgets) return '
%s
' % html diff --git a/setup.py b/setup.py index e44ded347..018ff1002 100644 --- a/setup.py +++ b/setup.py @@ -17,8 +17,8 @@ install_requires = [ 'dj-database-url==0.5.0', 'django-bower==5.2.0', 'django-braces==1.9.0', + 'django-crispy-forms==1.7.2', - 'django-crispy-forms==1.6.1', 'django-extensions==1.9.8', 'django-extra-views==0.11.0', 'django-floppyforms==1.6.2', @@ -46,7 +46,7 @@ install_requires = [ # 'git+git://github.com/interlegis/trml2pdf.git', # 'git+git://github.com/jasperlittle/django-rest-framework-docs' # 'git+git://github.com/rubgombar1/django-admin-bootstrapped.git'' - + #'django-compressor==2.2', ] setup(