app/soc/views/helper/access.py
changeset 890 b3bf833c4580
parent 889 5f3136a5eb4c
child 891 3d40190f35b6
equal deleted inserted replaced
889:5f3136a5eb4c 890:b3bf833c4580
   234 
   234 
   235   raise out_of_band.LoginRequest(message_fmt=login_message_fmt)
   235   raise out_of_band.LoginRequest(message_fmt=login_message_fmt)
   236 
   236 
   237 
   237 
   238 def checkIsHost(request, args, kwargs):
   238 def checkIsHost(request, args, kwargs):
   239   """Returns an alternate HTTP response if Google Account has no Host entity
   239   """Raises an alternate HTTP response if Google Account has no Host entity
   240      for the specified program.
   240      for the specified program.
   241 
   241 
   242   Args:
   242   Args:
   243     request: a Django HTTP request
   243     request: a Django HTTP request
   244 
   244 
   245    Raises:
   245   Raises:
   246      AccessViolationResponse: if the required authorization is not met
   246     AccessViolationResponse:
   247 
   247     * if User has not been invited to be a Host, or
   248   Returns:
   248     * if User is not already a Host, or
   249     None if Host exists for the specified program, or a subclass of
   249     * if User has not agreed to the site-wide ToS, or
   250     django.http.HttpResponse which contains the alternate response
   250     * if no User exists for the logged-in Google Account, or
   251     should be returned by the calling view.
   251     * if the user is not even logged in
   252   """
   252   """
       
   253   checkAgreesToSiteToS(request, args, kwargs)
   253 
   254 
   254   try:
   255   try:
   255     # if the current user is invited to create a host profile we allow access
   256     # if the current user is invited to create a host profile we allow access
   256     checkIsInvited(request, args, kwargs)
   257     checkIsInvited(request, args, kwargs)
   257     return
   258     return
   258   except out_of_band.Error:
   259   except out_of_band.Error:
   259     pass
   260     pass
   260 
       
   261   checkAgreesToSiteToS(request, args, kwargs)
       
   262 
   261 
   263   user = user_logic.getForFields({'account': users.get_current_user()},
   262   user = user_logic.getForFields({'account': users.get_current_user()},
   264                                  unique=True)
   263                                  unique=True)
   265 
   264 
   266   host = host_logic.getForFields({'user': user}, unique=True)
   265   host = host_logic.getForFields({'user': user}, unique=True)