Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove user agent check

Roland Geider9d35b82f2518
diff --git a/wger/manager/forms.py b/wger/manager/forms.py
index 2e0e78327..d631dc064 100644
--- a/wger/manager/forms.py
+++ b/wger/manager/forms.py
@@ -109,31 +109,6 @@ class SetForm(ModelForm):
'they will be grouped together for a superset.')
-class SetFormMobile(ModelForm):
- '''
- Don't use the auto completer when accessing the mobile version
- '''
- class Meta:
- model = Set
- exclude = ('order', 'exerciseday')
- widgets = {'exercises': MultipleHiddenInput(), }
-
- categories_list = ModelChoiceField(ExerciseCategory.objects.all(),
- empty_label=_('All categories'),
- label=_('Categories'),
- widget=TranslatedSelect(),
- required=False)
- exercise_list = ModelChoiceField(Exercise.objects)
-
- # We need to overwrite the init method here because otherwise Django
- # will output a default help text, regardless of the widget used
- # https://code.djangoproject.com/ticket/9321
- def __init__(self, *args, **kwargs):
- super(SetFormMobile, self).__init__(*args, **kwargs)
- self.fields['exercise_list'].help_text = _('You can search for more than one exercise, '
- 'they will be grouped together for a superset.')
-
-
class SettingForm(ModelForm):
class Meta:
model = Setting
diff --git a/wger/manager/views/set.py b/wger/manager/views/set.py
index b1fb29fe1..3321403a6 100644
--- a/wger/manager/views/set.py
+++ b/wger/manager/views/set.py
@@ -35,15 +35,10 @@ from django.shortcuts import (
)
from django.urls import reverse
-# Third Party
-from django_user_agents.utils import get_user_agent
-
# wger
-from wger.config.models import LanguageConfig
from wger.exercises.models import Exercise
from wger.manager.forms import (
SetForm,
- SetFormMobile,
SettingForm
)
from wger.manager.models import (
@@ -51,7 +46,6 @@ from wger.manager.models import (
Set,
Setting
)
-from wger.utils.language import load_item_languages
logger = logging.getLogger(__name__)
@@ -80,30 +74,13 @@ def create(request, day_pk):
if day.get_owner_object().user != request.user:
return HttpResponseForbidden()
- # Select the correct form depending on the user-agent.
- # The difference is that the mobile form doesn't use the autocompleter for
- # exercises, but 2 dropdowns, one to filter by category and one to select
- # the exercises themselves.
- user_agent = get_user_agent(request)
- if user_agent.is_mobile:
- form_class = SetFormMobile
- else:
- form_class = SetForm
-
context = {}
formsets = []
- form = form_class(initial={'sets': Set.DEFAULT_SETS})
-
- # For the mobile dropdown list we need to manually filter the exercises
- # by language and status
- if user_agent.is_mobile:
- languages = load_item_languages(LanguageConfig.SHOW_ITEM_EXERCISES)
- form.fields['exercise_list'].queryset = Exercise.objects.accepted() \
- .filter(language__in=languages)
+ form = SetForm(initial={'sets': Set.DEFAULT_SETS})
# If the form and all formsets validate, save them
if request.method == "POST":
- form = form_class(request.POST)
+ form = SetForm(request.POST)
if form.is_valid():
for exercise in form.cleaned_data['exercises']:
formset = SettingFormset(request.POST,