diff --git a/hc/accounts/middleware.py b/hc/accounts/middleware.py index bba200fb..589e5307 100644 --- a/hc/accounts/middleware.py +++ b/hc/accounts/middleware.py @@ -1,8 +1,15 @@ +from hc.accounts.models import Profile + + class TeamAccessMiddleware(object): def process_request(self, request): if not request.user.is_authenticated(): return + teams_q = Profile.objects.filter(member__user_id=request.user.id) + teams_q = teams_q.select_related("user") + request.teams = list(teams_q) + profile = request.user.profile if profile.current_team: request.team = profile.current_team diff --git a/hc/api/tests/test_create_check.py b/hc/api/tests/test_create_check.py index a18a639a..5ba6f0dd 100644 --- a/hc/api/tests/test_create_check.py +++ b/hc/api/tests/test_create_check.py @@ -2,7 +2,6 @@ import json from hc.api.models import Channel, Check from hc.test import BaseTestCase -from hc.accounts.models import Profile class CreateCheckTestCase(BaseTestCase): diff --git a/hc/front/views.py b/hc/front/views.py index e5ac8791..8a324d96 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -27,11 +27,12 @@ def pairwise(iterable): @login_required def my_checks(request): - checks = Check.objects.filter(user=request.team.user).order_by("created") + q = Check.objects.filter(user=request.team.user).order_by("created") + checks = list(q) counter = Counter() down_tags, grace_tags = set(), set() - for check in checks.iterator(): + for check in checks: status = check.get_status() for tag in check.tags_list(): if tag == "": diff --git a/templates/base.html b/templates/base.html index f6c5f1d0..0df5a352 100644 --- a/templates/base.html +++ b/templates/base.html @@ -110,26 +110,27 @@