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.

20 lines
603 B

8 years ago
8 years ago
8 years ago
8 years ago
  1. from hc.accounts.models import Profile
  2. class TeamAccessMiddleware(object):
  3. def __init__(self, get_response):
  4. self.get_response = get_response
  5. def __call__(self, request):
  6. if not request.user.is_authenticated:
  7. return self.get_response(request)
  8. profile = Profile.objects.for_user(request.user)
  9. if profile.current_project is None:
  10. profile.current_project = profile.get_own_project()
  11. profile.save()
  12. request.profile = profile
  13. request.project = profile.current_project
  14. return self.get_response(request)