From 0efcac49ef54e54c70b49d1413cc5af396cd4dda Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Wed, 30 Jan 2019 17:35:17 +0100 Subject: [PATCH] Dedicated submit text for the last step in the wizard, done step is TODO --- ippisite/ippidb/templates/add.html | 12 +++++++++--- ippisite/ippidb/templatetags/customtags.py | 4 ++++ ippisite/ippidb/views/contribute.py | 7 +++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ippisite/ippidb/templates/add.html b/ippisite/ippidb/templates/add.html index b3f1f9c7..fd85b7d4 100644 --- a/ippisite/ippidb/templates/add.html +++ b/ippisite/ippidb/templates/add.html @@ -122,9 +122,15 @@ window.onload = function() { <input type="hidden" name="ippi_wizard-current_step" value="{{ wizard.steps.current }}" id="id_ippi_wizard-current_step"/> - <input class="submit_button" type="submit" - value="{%block submit_button_text%}{% trans 'Next step' %}{%endblock%}" - /> + <button class="submit_button" type="submit"> + {%block submit_button_text%} + {% if wizard.steps.step1 == wizard.steps.count %} + {% trans 'Save in Database' %} + {%else%} + {% trans 'Next step' %} + {%endif%} + {%endblock%} + </button> </div> </form> <div class="empty_form" style="display:none">{% block emptyform %}{% endblock emptyform%}</div> diff --git a/ippisite/ippidb/templatetags/customtags.py b/ippisite/ippidb/templatetags/customtags.py index 46ea7702..7e4cec69 100644 --- a/ippisite/ippidb/templatetags/customtags.py +++ b/ippisite/ippidb/templatetags/customtags.py @@ -30,6 +30,10 @@ def bootstrap(object): wrapping_classes = "form-check" label_classes = "form-check-label" css_classes.add("form-check-input") + # elif isinstance(field.field.widget, widgets.RadioSelect): + # wrapping_classes = "form-check" + # label_classes = "form-check-label" + # css_classes.add("form-check-input") else: wrapping_classes = "input_field form-group" label_classes = "form-control-placeholder" diff --git a/ippisite/ippidb/views/contribute.py b/ippisite/ippidb/views/contribute.py index ad9d1ca2..d27aaead 100644 --- a/ippisite/ippidb/views/contribute.py +++ b/ippisite/ippidb/views/contribute.py @@ -69,6 +69,7 @@ TEMPLATES = {"IdForm": "IdForm.html", class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView): def get_context_data(self, **kwargs): + # @formatter:off context = super(IppiWizard, self).get_context_data(**kwargs) if self.steps.current == 'BibliographyForm': context['id_source'] = self.storage.get_step_data('IdForm').get('IdForm-id_source') @@ -82,6 +83,7 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView): context['complex_choice'] = self.storage.get_step_data('ProteinDomainComplexTypeForm').get('ProteinDomainComplexTypeForm-complexChoice') context['complex_type'] = self.storage.get_step_data('ProteinDomainComplexTypeForm').get('ProteinDomainComplexTypeForm-complexType') context['pdb_id'] = self.storage.get_step_data('PDBForm').get('PDBForm-pdb_id') + # @formatter:on return context def get_form_kwargs(self, step=None): @@ -145,7 +147,8 @@ class IppiWizard(LoginRequiredMixin, NamedUrlSessionWizardView): def get_template_names(self): return [TEMPLATES[self.steps.current]] - def done(self, form_list, **kwargs): + def done(self, form_list, form_dict=None, **kwargs): + super().done(form_list=form_list, **kwargs) return render(self.request, 'done.html', { 'form_data': [form.cleaned_data for form in form_list], - }) + }) -- GitLab