Self hosted FLOSS fitness/workout, nutrition and weight tracker
Crispify gym email forms
Roland Geideref66698d1e12
diff --git a/wger/gym/templates/gym/member_list.html b/wger/gym/templates/gym/member_list.htmlindex a7229bf67..f97f456d2 100644--- a/wger/gym/templates/gym/member_list.html+++ b/wger/gym/templates/gym/member_list.html@@ -271,7 +271,7 @@{# #}{# Email lists #}{# #}-{% if perms.email.change_log %}+{% if perms.mailer.change_log %}<div class="dropdown float-right"><a role="button" class="btn btn-default dropdown-toggle btn-sm" data-toggle="dropdown">{% trans "Actions" %} <span class="caret"></span>diff --git a/wger/mailer/forms.py b/wger/mailer/forms.pyindex c704c3130..0c9b531f6 100644--- a/wger/mailer/forms.py+++ b/wger/mailer/forms.py@@ -23,6 +23,9 @@ from django.forms import ()from django.utils.translation import pgettext+# Third Party+from crispy_forms.helper import FormHelper+class EmailListForm(Form):"""@@ -31,3 +34,9 @@ class EmailListForm(Form):subject = CharField(label=pgettext('As in "email subject"', 'Subject'))body = CharField(widget=Textarea, label=pgettext('As in "content of an email"', 'Content'))++ def __init__(self, *args, **kwargs):+ super(EmailListForm, self).__init__(*args, **kwargs)++ self.helper = FormHelper()+ self.helper.form_tag = Falsediff --git a/wger/mailer/templates/mailer/gym/form.html b/wger/mailer/templates/mailer/gym/form.htmlindex 62634234e..39c96aba8 100644--- a/wger/mailer/templates/mailer/gym/form.html+++ b/wger/mailer/templates/mailer/gym/form.html@@ -1,5 +1,5 @@{% extends "base.html" %}-{% load wger_extras i18n django_bootstrap_breadcrumbs %}+{% load i18n django_bootstrap_breadcrumbs crispy_forms_tags %}{% block title %}{% trans 'Email' %} - {{ gym }}{% endblock %}@@ -16,10 +16,11 @@{% endblock %}{% block content %}-<form action="{{ form_action }}"+<form action="{{ request.get_full_path }}"method="post"class="wger-form">- {% render_form_fields form "Vorschau erzeugen" %}+ {% crispy form %}+ <input type="submit" name="submit" value="{% trans 'Generate preview' %}" class="btn btn-primary btn-success btn-block" id="submit-id-submit"></form>{% endblock %}diff --git a/wger/mailer/templates/mailer/gym/preview.html b/wger/mailer/templates/mailer/gym/preview.htmlindex d6fce0461..1f6497bd6 100644--- a/wger/mailer/templates/mailer/gym/preview.html+++ b/wger/mailer/templates/mailer/gym/preview.html@@ -1,5 +1,5 @@{% extends "base.html" %}-{% load wger_extras i18n django_bootstrap_breadcrumbs %}+{% load i18n django_bootstrap_breadcrumbs crispy_forms_tags %}{% block title %}{% trans 'Email' %} - {{ gym }}{% endblock %}@@ -20,7 +20,7 @@{% block content %}<h3>{% trans 'Current version' %}</h3>-<form action="{{ form_action }}" method="post">+<form action="{{ request.get_full_path }}" method="post">{% csrf_token %}<input type="hidden" name="{{ stage_field }}" value="2" /><input type="hidden" name="{{ hash_field }}" value="{{ hash_value }}" />@@ -44,15 +44,17 @@</div></div><div class="row" style="margin-top: 1em;">- {% render_form_submit 'Emails verschicken' %}+ <input type="submit" name="submit" value="{% trans 'Send emails' %}" class="btn btn-primary btn-success btn-block" id="submit-id-submit"></div></form><h3>{% trans 'Correction' %}</h3>-<form action="{{ form_action }}"+<form action="{{ request.get_full_path }}"method="post"class="wger-form">- {% render_form_fields form 'Correction' %}+ {% crispy form %}+ <input type="submit" name="submit" value="{% trans 'Correction' %}" class="btn btn-primary btn-success btn-block" id="submit-id-correction">+</form>{% endblock %}diff --git a/wger/mailer/views/gym.py b/wger/mailer/views/gym.pyindex 00a7277d7..a7dd902fe 100644--- a/wger/mailer/views/gym.py+++ b/wger/mailer/views/gym.py@@ -97,7 +97,7 @@ class EmailListFormPreview(FormPreview):"""if not request.user.is_authenticated or\request.user.userprofile.gym_id != self.gym.id or \- not request.user.has_perms('core.change_emailcron'):+ not request.user.has_perm('mailer.change_log'):return HttpResponseForbidden()context = super(EmailListFormPreview, self).get_context(request, form)