Coverage for gui/context_processors.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.2.1, created at 2023-03-14 06:24 +0000

1from .models import MembershipPeriod, Membership 

2import os 

3 

4 

5def admin_tasks_count(request): 

6 user = request.user 

7 

8 admin_tasks_count = 0 

9 if user.is_superuser: 

10 admin_tasks_count = Membership.pending_memberships().count() 

11 

12 return {"admin_tasks_count": admin_tasks_count} 

13 

14 

15class Website: 

16 def __init__(self, request): 

17 self.request = request 

18 

19 @property 

20 def version(self): 

21 return os.getenv('WEBSITE_VERSION', None) 

22 

23 @property 

24 def project_url(self): 

25 return "https://gitlab.freedesktop.org/xorgfoundation/xorg_membership" 

26 

27 @property 

28 def version_url(self): 

29 return "{}/-/commit/{}".format(self.project_url, self.version) 

30 

31 

32def global_context(request): 

33 return { 

34 "current_membership_period": MembershipPeriod.current_period(), 

35 "website": Website(request) 

36 }