Coverage for xplanung_light/middleware.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.17.5, created at 2026-11-27 10:10 +0000

1from xplanung_light.models import AdminOrgaUser 

2from django.conf import settings 

3 

4class UserRoleInfoMiddleware: 

5 def __init__(self, get_response): 

6 self.get_response = get_response 

7 

8 def __call__(self, request): 

9 # Code executed for each request before the view is called 

10 is_toeb_reporter = False 

11 is_admin = False 

12 request.xplanung_light_version = getattr(settings, 'XPLANUNG_LIGHT_VERSION', 'unknown') 

13 if request.user.is_authenticated: 

14 if AdminOrgaUser.objects.filter(user=request.user, is_admin=True).exists(): 

15 is_admin = True 

16 if AdminOrgaUser.objects.filter(user=request.user, is_toeb_reporter=True).exists(): 

17 is_toeb_reporter = True 

18 request.user_is_admin = is_admin 

19 request.user_is_toeb_reporter = is_toeb_reporter 

20 response = self.get_response(request) 

21 return response 

22 

23""" 

24class SystemInfoMiddleware: 

25 def __init__(self, get_response): 

26 self.get_response = get_response 

27 

28 def __call__(self, request): 

29 response = self.get_response(request) 

30 if settings.XPLANUNG_LIGHT_VERSION: 

31 request.xplanung_light_version = settings.XPLANUNG_LIGHT_VERSION 

32 return response 

33"""