From 46f4e690382bdcf139ea7d8705253e0ac60e2807 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 13 Sep 2018 12:33:50 +0200 Subject: QA packaging - fix date initialization --- archaeological_finds/forms_treatments.py | 5 ++++- .../templates/ishtar/forms/qa_find_treatment.html | 10 ++++------ archaeological_finds/views.py | 1 + bootstrap_datepicker/widgets.py | 4 ++-- ishtar_common/models_imports.py | 4 ++-- ishtar_common/widgets.py | 4 ++++ 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index 364c22ed6..b09d234f0 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -288,7 +288,9 @@ class QAFindTreatmentForm(IshtarForm): associated_model=Container, new=True), validators=[valid_id(Container)]) create_treatment = forms.BooleanField( - label=_(u"Create a treatment"), required=False) + label=_(u"Create a treatment"), required=False, + widget=widgets.CheckboxInput + ) year = forms.IntegerField( label=_("Year"), initial=lambda: datetime.datetime.now().year, validators=[validators.MinValueValidator(1000), @@ -309,6 +311,7 @@ class QAFindTreatmentForm(IshtarForm): validators=[valid_id(Organization)], required=False) def __init__(self, *args, **kwargs): + self.confirm = False self.user = None if 'user' in kwargs: self.user = kwargs.pop('user') diff --git a/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html b/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html index 07f633848..ef3906735 100644 --- a/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html +++ b/archaeological_finds/templates/ishtar/forms/qa_find_treatment.html @@ -27,10 +27,8 @@
-   -
@@ -48,7 +46,7 @@ {% block js %} var update_form_display = function(){ - if ($("#create-choice:checked").length){ + if ($("#{{form.create_treatment.auto_id}}:checked").length){ $("#new-treatment").show(); } else { $("#new-treatment").hide(); @@ -56,7 +54,7 @@ var update_form_display = function(){ } $(document).ready(function(){ - $("#create-choice").click(update_form_display); + $("#{{form.create_treatment.auto_id}}").click(update_form_display); update_form_display(); }); diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 30a382e2c..e930c0830 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -633,6 +633,7 @@ class QAFindTreatmentFormView(QAItemForm): def get_form_kwargs(self): kwargs = super(QAFindTreatmentFormView, self).get_form_kwargs() kwargs['user'] = self.request.user + kwargs['prefix'] = "qa-packaging" return kwargs def form_valid(self, form): diff --git a/bootstrap_datepicker/widgets.py b/bootstrap_datepicker/widgets.py index 9416ac16b..338319311 100644 --- a/bootstrap_datepicker/widgets.py +++ b/bootstrap_datepicker/widgets.py @@ -159,8 +159,8 @@ class DatePicker(DateTimeInput): html = self.html_template % dict(div_attrs=flatatt(div_attrs), input_attrs=flatatt(input_attrs), icon_attrs=flatatt(icon_attrs)) - js = self.js_template % dict(picker_id=picker_id, - options=json_dumps(self.options or {})) + js = self.js_template % dict( + picker_id=picker_id, options=json_dumps(self.options or {})) return mark_safe(force_text(html + js)) diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 2dec39c84..b52219c11 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -1058,8 +1058,8 @@ class Import(models.Model): put_session_message( session_key, unicode( - _(u"Modification check {} added to the queue")).format( - self.name), + _(u"Modification check {} added to the queue") + ).format(self.name), "info") self.state = 'HQ' self.end_date = datetime.datetime.now() diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index b5e1f5891..6292db202 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -476,6 +476,10 @@ if settings.SURFACE_UNIT == 'square-metre': AreaWidget = SquareMeterWidget +class CheckboxInput(forms.CheckboxInput): + NO_FORM_CONTROL = True + + class SearchWidget(forms.TextInput): template_name = 'widgets/search_input.html' -- cgit v1.2.3