Coverage for bundesliga_tippspiel/template_extras.py: 92%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

16 statements  

1"""LICENSE 

2Copyright 2017 Hermann Krumrey <hermann@krumreyh.com> 

3 

4This file is part of bundesliga-tippspiel. 

5 

6bundesliga-tippspiel is free software: you can redistribute it and/or modify 

7it under the terms of the GNU General Public License as published by 

8the Free Software Foundation, either version 3 of the License, or 

9(at your option) any later version. 

10 

11bundesliga-tippspiel is distributed in the hope that it will be useful, 

12but WITHOUT ANY WARRANTY; without even the implied warranty of 

13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

14GNU General Public License for more details. 

15 

16You should have received a copy of the GNU General Public License 

17along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>. 

18LICENSE""" 

19 

20from typing import Dict, Any 

21from flask_login import current_user 

22from bundesliga_tippspiel.db import Team, UserProfile 

23from bundesliga_tippspiel.db.settings.DisplayBotsSettings import \ 

24 DisplayBotsSettings 

25from bundesliga_tippspiel.db.settings.ReminderSettings import ReminderSettings 

26 

27 

28def profile_extras() -> Dict[str, Any]: 

29 """ 

30 Makes sure that the profile page has access to information on email 

31 reminders. 

32 :return: The variables to forward to the template 

33 """ 

34 teams = Team.query.all() 

35 teams.sort(key=lambda x: x.name) 35 ↛ exitline 35 didn't run the lambda on line 35

36 user_profile = UserProfile.query.filter_by(user=current_user).first() 

37 reminder_settings = { 

38 x.reminder_type: x for x in 

39 ReminderSettings.query.filter_by(user=current_user).all() 

40 } 

41 reminder_time = None 

42 for reminder in reminder_settings.values(): 

43 if reminder is not None: 43 ↛ 42line 43 didn't jump to line 42, because the condition on line 43 was never false

44 reminder_time = reminder.reminder_time 

45 break 

46 return { 

47 "teams": teams, 

48 "user_profile": user_profile, 

49 "reminder_settings": reminder_settings, 

50 "reminder_time": reminder_time, 

51 "display_bots_setting": 

52 DisplayBotsSettings.query.filter_by(user=current_user).first() 

53 }