Self hosted FLOSS fitness/workout, nutrition and weight tracker
Crispify weight import views
Roland Geiderd053b0f1382e
diff --git a/wger/weight/forms.py b/wger/weight/forms.pyindex b80faa723..f4e3eea82 100644--- a/wger/weight/forms.py+++ b/wger/weight/forms.py@@ -26,6 +26,10 @@ from django.forms import ()from django.utils.translation import ugettext as _+# Third Party+from crispy_forms.helper import FormHelper+from crispy_forms.layout import Layout+# wgerfrom wger.utils.constants import DATE_FORMATSfrom wger.utils.widgets import Html5DateInput@@ -47,6 +51,16 @@ class WeightCsvImportForm(Form):csv_input = CharField(widget=Textarea, label=_('Input'))date_format = forms.ChoiceField(choices=CSV_DATE_FORMAT, label=_('Date format'))+ def __init__(self, *args, **kwargs):+ super(WeightCsvImportForm, self).__init__(*args, **kwargs)++ self.helper = FormHelper()+ self.helper.layout = Layout(+ "csv_input",+ "date_format",+ )+ self.helper.form_tag = False+class WeightForm(ModelForm):date = DateField(input_formats=DATE_FORMATS, widget=Html5DateInput())diff --git a/wger/weight/templates/import_csv_form.html b/wger/weight/templates/import_csv_form.htmlindex c23985d60..d7b3491ed 100644--- a/wger/weight/templates/import_csv_form.html+++ b/wger/weight/templates/import_csv_form.html@@ -1,16 +1,12 @@{% extends "base.html" %}-{% load wger_extras %}-{% load i18n %}+{% load i18n crispy_forms_tags %}{% block title %}{% trans "Import weight logs" %}{% endblock %}{% block content %}-<form action="{{form_action}}"- method="post"- class="wger-form">-- {% trans 'Submit' as submit_text %}- {% render_form_fields form submit_text %}+<form action="{{request.get_full_path}}" method="post">+ {% crispy form %}+ <input type="submit" name="submit" value="{% trans 'Submit' %}" class="btn btn-primary btn-success btn-block" id="submit-id-submit"></form>{% endblock %}diff --git a/wger/weight/templates/import_csv_preview.html b/wger/weight/templates/import_csv_preview.htmlindex 5b3c9e45a..87564436f 100644--- a/wger/weight/templates/import_csv_preview.html+++ b/wger/weight/templates/import_csv_preview.html@@ -1,6 +1,5 @@{% extends "base.html" %}-{% load wger_extras %}-{% load i18n %}+{% load i18n crispy_forms_tags %}{% block title %}{% trans "Preview imported CSV entries" %}{% endblock %}@@ -62,14 +61,12 @@ entries that were successfully converted. All entries that produced an errorwill simply be ignored. It's up to you to decide whether they are useful(unrecognised entries) or not (e.g. headers, comments, etc.).{% endblocktrans %}</p>-<form action="{{form_action}}"- method="post"- class="wger-form">+<form action="{{request.get_full_path}}" method="post"><input type="hidden" name="{{ stage_field }}" value="2" /><input type="hidden" name="{{ hash_field }}" value="{{ hash_value }}" />- {% trans 'Import' as submit_text %}- {% render_form_fields form submit_text %}+ {% crispy form %}+ <input type="submit" name="submit" value="{% trans 'Import' %}" class="btn btn-primary btn-success btn-block" id="submit-id-submit"></form>@@ -79,13 +76,13 @@ will simply be ignored. It's up to you to decide whether they are useful<p>{% blocktrans %}You can correct the list here and re-submit it as often asyou want.{% endblocktrans %}</p>-<form action="{{form_action}}"+<form action="{{request.get_full_path}}"method="post"class="form"><input type="hidden" name="{{ stage_field }}" value="1" />- {% trans 'Re-Submit' as submit_text %}- {% render_form_fields form submit_text %}+ {% crispy form %}+ <input type="submit" name="submit" value="{% trans 'Re-Submit' %}" class="btn btn-primary btn-success btn-block" id="submit-id-submit"></form>{% endblock %}