summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar/furnitures/forms.py2
-rw-r--r--ishtar/furnitures/widgets.py14
2 files changed, 13 insertions, 3 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py
index 334a93a58..30fcefa3d 100644
--- a/ishtar/furnitures/forms.py
+++ b/ishtar/furnitures/forms.py
@@ -1501,7 +1501,7 @@ class OperationFormGeneral(forms.Form):
choices=models.OperationType.get_types())
start_date = forms.DateField(label=_(u"Start date"), required=False,
widget=widgets.JQueryDate)
- surface = forms.IntegerField(label=_(u"Surface"), required=False,)
+ surface = forms.IntegerField(label=_(u"Surface (m²)"), required=False,)
year = forms.IntegerField(label=_("Year"),
initial=lambda:datetime.datetime.now().year,
validators=[validators.MinValueValidator(1900),
diff --git a/ishtar/furnitures/widgets.py b/ishtar/furnitures/widgets.py
index 346cbd5a5..4217d5194 100644
--- a/ishtar/furnitures/widgets.py
+++ b/ishtar/furnitures/widgets.py
@@ -44,9 +44,19 @@ class JQueryDate(forms.TextInput):
rendered = super(JQueryDate, self).render(name, value, attrs)
rendered += """
<script type="text/javascript"><!--//
- $(function() {$("#id_%s").datepicker($.datepicker.regional["%s"]);});
+ $(function() {
+ $("#id_%(name)s").datepicker($.datepicker.regional["%(country)s"]);
+ var val = $("#id_%(name)s").val();
+ if(val){
+ var dt = $.datepicker.parseDate('yy-mm-dd', val);
+ val = $.datepicker.formatDate(
+ $.datepicker.regional["%(country)s"]['dateFormat'],
+ dt);
+ $("#id_%(name)s").val(val);
+ }
+ });
//--></script>
-""" % (name, settings.COUNTRY)
+""" % {"name":name, "country":settings.COUNTRY}
return rendered
class JQueryAutoComplete(forms.TextInput):