Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Set form helper for user creation for gyms

Roland Geiderb81064d961d0
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 0ba6b8f34..d9f378cf0 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -23,7 +23,7 @@ Upgrade steps from 1.9:
🐛 Bug Fixes:
-* `#499`_, `#505`_
+* `#499`_, `#505`_, `#504`_
🧰 Maintenance:
@@ -38,6 +38,7 @@ Upgrade steps from 1.9:
.. _#340: https://github.com/wger-project/wger/issues/340
.. _#494: https://github.com/wger-project/wger/issues/494
.. _#499: https://github.com/wger-project/wger/issues/499
+.. _#504: https://github.com/wger-project/wger/issues/504
.. _#505: https://github.com/wger-project/wger/issues/505
diff --git a/wger/gym/views/gym.py b/wger/gym/views/gym.py
index b7c764c3a..27b14a8df 100644
--- a/wger/gym/views/gym.py
+++ b/wger/gym/views/gym.py
@@ -9,14 +9,13 @@
#
# wger Workout Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU Affero General Public License
+#
# Standard Library
-#
-# You should have received a copy of the GNU Affero General Public License
import csv
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
import datetime
import logging
@@ -43,6 +42,7 @@ from django.urls import (
reverse,
reverse_lazy
)
+from django.utils.text import slugify
from django.utils.translation import (
ugettext as _,
ugettext_lazy
@@ -54,6 +54,10 @@ from django.views.generic import (
UpdateView
)
+# Third Party
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Submit
+
# wger
from wger.config.models import GymConfig as GlobalGymConfig
from wger.gym.forms import (
@@ -359,8 +363,15 @@ class GymAddUserView(WgerFormMixin,
"""
Set available user permissions
"""
- return self.form_class(available_roles=get_permission_list(self.request.user),
+ form = self.form_class(available_roles=get_permission_list(self.request.user),
**self.get_form_kwargs())
+ form.helper = FormHelper()
+ form.helper.form_id = slugify(self.request.path)
+ form.helper.form_method = 'post'
+ form.helper.form_action = self.request.path
+ form.helper.add_input(Submit('submit', self.submit_text, css_class='btn-success btn-block'))
+ form.helper.form_class = 'wger-form'
+ return form
def form_valid(self, form):
"""