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 = '