You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
516 B

  1. from hc.accounts.models import Profile
  2. class TeamAccessMiddleware(object):
  3. def process_request(self, request):
  4. if not request.user.is_authenticated():
  5. return
  6. teams_q = Profile.objects.filter(member__user_id=request.user.id)
  7. teams_q = teams_q.select_related("user")
  8. request.teams = list(teams_q)
  9. profile = request.user.profile
  10. if profile.current_team:
  11. request.team = profile.current_team
  12. else:
  13. request.team = profile