Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Crispify exercise edit form

Roland Geider277333536552
diff --git a/wger/core/static/js/wger-core.js b/wger/core/static/js/wger-core.js
index a00cc1a4e..a05cf5718 100644
--- a/wger/core/static/js/wger-core.js
+++ b/wger/core/static/js/wger-core.js
@@ -213,9 +213,10 @@ function wgerInitTinymce() {
mode: 'textareas',
theme: 'silver',
width: '100%',
- height: '200',
+
entity_encoding: 'raw',
- menu: {},
+ plugins: "lists",
+ menubar: false,
toolbar: 'undo redo | bold italic | bullist numlist '
});
}
diff --git a/wger/core/templates/form.html b/wger/core/templates/form.html
index 5c997eab7..9a3026430 100644
--- a/wger/core/templates/form.html
+++ b/wger/core/templates/form.html
@@ -5,7 +5,9 @@
{{ form.media }}
{% if custom_js %}
<script type="text/javascript">
+ $(document).ready(function() {
{{custom_js|safe}}
+ });
</script>
{% endif %}
{% endblock %}
diff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.py
index 78f156600..09197573c 100644
--- a/wger/exercises/views/exercises.py
+++ b/wger/exercises/views/exercises.py
@@ -28,9 +28,11 @@ from django.contrib.auth.mixins import (
from django.core import mail
from django.core.cache import cache
from django.forms import (
+ CheckboxSelectMultiple,
ModelChoiceField,
ModelForm,
- ModelMultipleChoiceField
+ ModelMultipleChoiceField,
+ Select
)
from django.http import (
HttpResponseForbidden,
@@ -57,6 +59,13 @@ from django.views.generic import (
UpdateView
)
+# Third Party
+from crispy_forms.layout import (
+ Column,
+ Layout,
+ Row
+)
+
# wger
from wger.config.models import LanguageConfig
from wger.exercises.models import (
@@ -74,11 +83,7 @@ from wger.utils.language import (
load_item_languages,
load_language
)
-from wger.utils.widgets import (
- TranslatedOriginalSelectMultiple,
- TranslatedSelect,
- TranslatedSelectMultiple
-)
+from wger.utils.widgets import TranslatedSelectMultiple
from wger.weight.helpers import process_log_entries
@@ -189,18 +194,16 @@ class ExercisesEditAddView(WgerFormMixin):
def get_form_class(self):
- # Define the exercise form here because only at this point during the request
- # have we access to the currently used language. In other places Django defaults
- # to 'en-us'.
class ExerciseForm(ModelForm):
category = ModelChoiceField(queryset=ExerciseCategory.objects.all(),
- widget=TranslatedSelect())
+ widget=Select()
+ )
muscles = ModelMultipleChoiceField(queryset=Muscle.objects.all(),
- widget=TranslatedOriginalSelectMultiple(),
+ widget=CheckboxSelectMultiple(),
required=False)
muscles_secondary = ModelMultipleChoiceField(queryset=Muscle.objects.all(),
- widget=TranslatedOriginalSelectMultiple(),
+ widget=CheckboxSelectMultiple(),
required=False)
class Meta:
@@ -220,6 +223,25 @@ class ExercisesEditAddView(WgerFormMixin):
return ExerciseForm
+ def get_form(self, form_class=None):
+ form = super(ExercisesEditAddView, self).get_form(form_class)
+ form.helper.layout = Layout(
+ "name_original",
+ "description",
+ "category",
+ "equipment",
+ Row(
+ Column('muscles', css_class='form-group col-6 mb-0'),
+ Column('muscles_secondary', css_class='form-group col-6 mb-0'),
+ css_class='form-row'
+ ),
+ Row(
+ Column('license', css_class='form-group col-6 mb-0'),
+ Column('license_author', css_class='form-group col-6 mb-0'),
+ css_class='form-row'
+ ),
+ )
+ return form
class ExerciseUpdateView(ExercisesEditAddView,
LoginRequiredMixin,