• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wger-project / wger / 22365694667

24 Feb 2026 07:00PM UTC coverage: 84.187% (+0.003%) from 84.184%
22365694667

push

github

rolandgeider
Upgrade dependencies

15775 of 18738 relevant lines covered (84.19%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.88
/wger/utils/context_processor.py
1
# This file is part of wger Workout Manager.
2
#
3
# wger Workout Manager is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU Affero General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# wger Workout Manager is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU Affero General Public License
14
# along with Workout Manager.  If not, see <http://www.gnu.org/licenses/>.
15

16
# Django
17
from django.conf import settings
1✔
18
from django.templatetags.static import static
1✔
19
from django.utils.translation import get_language
1✔
20

21
# wger
22
from wger.config.models import GymConfig
1✔
23
from wger.utils import constants
1✔
24
from wger.utils.constants import ENGLISH_SHORT_NAME
1✔
25
from wger.utils.language import get_language_data
1✔
26

27

28
def processor(request):
1✔
29
    languages_dict = dict(settings.AVAILABLE_LANGUAGES)
1✔
30
    full_path = request.get_full_path()
1✔
31
    static_path = static('images/logos/logo-social.png')
1✔
32

33
    # fmt: off
34
    context = {
1✔
35
        'mastodon': settings.WGER_SETTINGS.get('MASTODON', ''),
36
        'twitter': settings.WGER_SETTINGS.get('TWITTER', ''),
37
        'allow_registration': settings.WGER_SETTINGS.get('ALLOW_REGISTRATION', False),
38

39
        # Languages
40
        'i18n_language': get_language_data(
41
            (get_language(), languages_dict.get(get_language(), ENGLISH_SHORT_NAME)),
42
        ),
43
        'languages': settings.AVAILABLE_LANGUAGES,
44

45
        # The current path
46
        'request_full_path': full_path,
47

48
        # The current full path with host
49
        'request_absolute_path': request.build_absolute_uri(),
50
        'image_absolute_path': request.build_absolute_uri(static_path),
51

52
        # Translation links
53
        'is_api_path': '/api/' in request.build_absolute_uri(),
54

55
        # Flag for guest users
56
        'has_demo_data': request.session.get('has_demo_data', False),
57

58
        # Don't show messages on AJAX requests (they are deleted if shown)
59
        'no_messages': request.META.get('HTTP_X_WGER_NO_MESSAGES', False),
60

61
        # Default cache time for template fragment caching
62
        'cache_timeout': settings.CACHES['default']['TIMEOUT'],
63

64
        # Used for logged in trainers
65
        'trainer_identity': request.session.get('trainer.identity'),
66

67
        # current gym, if available
68
        'custom_header': get_custom_header(request),
69
    }
70
    # fmt: on
71

72
    # Pseudo-intelligent navigation here
73
    if '/software/' in full_path or '/contact' in full_path or '/api/v2' in full_path:
1✔
74
        context['active_tab'] = constants.SOFTWARE_TAB
1✔
75

76
    elif '/nutrition/' in full_path:
1✔
77
        context['active_tab'] = constants.NUTRITION_TAB
1✔
78

79
    elif '/weight/' in full_path:
1✔
80
        context['active_tab'] = constants.WEIGHT_TAB
1✔
81

82
    elif (
1✔
83
        '/routine/' in full_path
84
        or '/measurement/' in full_path
85
        or '/exercise/' in full_path
86
        or '/gallery/' in full_path
87
        or '/trophies/' in full_path
88
    ):
89
        context['active_tab'] = constants.WORKOUT_TAB
1✔
90

91
    return context
1✔
92

93

94
def get_custom_header(request):
1✔
95
    """
96
    Loads the custom header for the application, if available
97

98
    Currently the header can only be overwritten to use the user's current gym
99
    """
100

101
    # Current gym
102
    current_gym = None
1✔
103
    if request.user.is_authenticated and request.user.userprofile.gym:
1✔
104
        current_gym = request.user.userprofile.gym
1✔
105
    else:
106
        global_gymconfig = GymConfig.objects.get(pk=1)
1✔
107
        if global_gymconfig.default_gym:
1✔
108
            current_gym = global_gymconfig.default_gym
×
109

110
    # Put the custom header together
111
    custom_header = None
1✔
112
    if current_gym and current_gym.config.show_name:
1✔
113
        custom_header = current_gym.name
1✔
114
    return custom_header
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc