Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add custom context_processor

Roland Geider45e63a67c4a0
diff --git a/manager/context_processor.py b/manager/context_processor.py
new file mode 100644
index 000000000..6f945ac4d
--- /dev/null
+++ b/manager/context_processor.py
@@ -0,0 +1,22 @@
+# This file is part of Workout Manager.
+#
+# 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.
+#
+# 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
+# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.
+
+
+from workout_manager import get_version
+
+def processor(request):
+ return {
+ 'version' : get_version()
+ }
diff --git a/workout_manager/settings.sample.py b/workout_manager/settings.sample.py
index ba73e66be..6aa2280db 100644
--- a/workout_manager/settings.sample.py
+++ b/workout_manager/settings.sample.py
@@ -26,6 +26,13 @@ LOGIN_URL = '/login'
# Model for the user profile
AUTH_PROFILE_MODULE = 'manager.UserProfile'
+# Set the context processors
+TEMPLATE_CONTEXT_PROCESSORS = (
+ 'manager.context_processor.processor',
+ 'django.contrib.auth.context_processors.auth',
+)
+
+
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.