\d+)/edit',
+ language_config.LanguageConfigUpdateView.as_view(),
+ name='languageconfig-edit'),
+
+ # Gym config
+ url(r'^default-gym',
+ gym_config.GymConfigUpdateView.as_view(),
+ name='gymconfig-edit'),
)
diff --git a/wger/config/views/gym_config.py b/wger/config/views/gym_config.py
new file mode 100644
index 000000000..f11ab14a6
--- /dev/null
+++ b/wger/config/views/gym_config.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+# This file is part of wger Workout Manager.
+#
+# wger Workout Manager is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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
+
+import logging
+
+from django.core.urlresolvers import reverse
+from django.core.urlresolvers import reverse_lazy
+from django.utils.translation import ugettext as _
+from django.views.generic import UpdateView
+
+from wger.config.models import GymConfig
+from wger.utils.generic_views import WgerFormMixin
+
+
+logger = logging.getLogger('wger.custom')
+
+
+class GymConfigUpdateView(WgerFormMixin, UpdateView):
+ '''
+ Generic view to edit the gym config table
+ '''
+ model = GymConfig
+ permission_required = 'config.change_gymconfig'
+ success_url = reverse_lazy('config:gymconfig-edit')
+
+ def get_object(self):
+ '''
+ Return the only gym config object
+ '''
+ return GymConfig.objects.get(pk=1)
+
+ def get_context_data(self, **kwargs):
+ context = super(GymConfigUpdateView, self).get_context_data(**kwargs)
+ context['form_action'] = reverse('config:gymconfig-edit')
+ context['title'] = _('Edit')
+ return context
diff --git a/wger/core/templates/gym/list.html b/wger/core/templates/gym/list.html
index 49f308438..4559c4aaf 100644
--- a/wger/core/templates/gym/list.html
+++ b/wger/core/templates/gym/list.html
@@ -36,7 +36,7 @@
{% block sidebar %}
{% if perms.core.add_gym %}
-{% trans "Options" %}
+{% trans "Options" %}
@@ -49,4 +49,19 @@
{% endif %}
+
+{% if perms.core.change_gymconfig %}
+{% trans "Default gym" %}
+
+
+
+ {% trans "Default gym configuration" %}
+
+
+{% endif %}
{% endblock %}
diff --git a/wger/core/views/user.py b/wger/core/views/user.py
index 2cd90e3ea..569c53dba 100644
--- a/wger/core/views/user.py
+++ b/wger/core/views/user.py
@@ -42,6 +42,7 @@ from wger.core.forms import UserPreferencesForm, UserPersonalInformationForm
from wger.core.forms import PasswordConfirmationForm
from wger.core.forms import RegistrationForm
from wger.core.forms import RegistrationFormNoCaptcha
+from wger.config.models import GymConfig
logger = logging.getLogger('wger.custom')
@@ -168,9 +169,14 @@ def registration(request):
password)
user.save()
- # Save the notification language
+ # Pre-set some values of the user's profile
language = Language.objects.get(short_name=translation.get_language())
user.userprofile.notification_language = language
+
+ gym_config = GymConfig.objects.get(pk=1)
+ if gym_config:
+ user.userprofile.gym = gym_config.default_gym
+
user.userprofile.save()
user = authenticate(username=username, password=password)
diff --git a/wger/manager/tests/testcase.py b/wger/manager/tests/testcase.py
index 189b9675b..64ff167f1 100644
--- a/wger/manager/tests/testcase.py
+++ b/wger/manager/tests/testcase.py
@@ -51,6 +51,7 @@ class BaseTestCase(object):
'''
fixtures = ('days_of_week',
+ 'gym-config',
'test-languages',
'test-licenses',
'test-gyms',
diff --git a/wger/settings_global.py b/wger/settings_global.py
index 83cb7f315..91d4b0201 100644
--- a/wger/settings_global.py
+++ b/wger/settings_global.py
@@ -348,3 +348,9 @@ REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',
'rest_framework.filters.OrderingFilter',)
}
+
+
+# Configure south database migrations
+SOUTH_MIGRATION_MODULES = {
+ 'easy_thumbnails': 'easy_thumbnails.south_migrations',
+}