app/soc/views/helper/access.py
changeset 746 018efb9863dc
parent 729 7fe218e3d359
child 791 30da180c4bca
equal deleted inserted replaced
745:ed3b545a9c14 746:018efb9863dc
    31   ]
    31   ]
    32 
    32 
    33 
    33 
    34 from google.appengine.api import users
    34 from google.appengine.api import users
    35 
    35 
       
    36 from django.core import urlresolvers
    36 from django.utils.translation import ugettext_lazy
    37 from django.utils.translation import ugettext_lazy
    37 from django.core import urlresolvers
       
    38 
    38 
    39 from soc.logic import accounts
    39 from soc.logic import accounts
    40 from soc.logic import dicts
    40 from soc.logic import dicts
    41 from soc.logic.models import host as host_logic
    41 from soc.logic.models import host as host_logic
    42 from soc.logic.models import notification as notification_logic
    42 from soc.logic.models import notification as notification_logic
   213 
   213 
   214   if accounts.isDeveloper(account=users.get_current_user()):
   214   if accounts.isDeveloper(account=users.get_current_user()):
   215     return
   215     return
   216 
   216 
   217   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
   217   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
   218       'role': 'a site developer '}
   218       'role': 'a Site Developer '}
   219 
   219 
   220   raise out_of_band.LoginRequest(message_fmt=login_message_fmt)
   220   raise out_of_band.LoginRequest(message_fmt=login_message_fmt)
   221 
   221 
   222 
   222 
   223 def checkIsHost(request):
   223 def checkIsHost(request):
   253 
   253 
   254   if host:
   254   if host:
   255     return
   255     return
   256 
   256 
   257   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
   257   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
   258       'role': 'a host '}
   258       'role': 'a Program Administrator '}
   259 
   259 
   260   raise out_of_band.LoginRequest(message_fmt=login_message_fmt)
   260   raise out_of_band.LoginRequest(message_fmt=login_message_fmt)
   261 
   261 
   262 
   262 
   263 def checkIsInvited(request):
   263 def checkIsInvited(request):
   284     pass
   284     pass
   285 
   285 
   286   checkIsUser(request)
   286   checkIsUser(request)
   287 
   287 
   288   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
   288   login_message_fmt = DEF_DEV_LOGOUT_LOGIN_MSG_FMT % {
   289       'role': 'a host for this program'}
   289       'role': 'a Program Administrator for this Program'}
   290 
   290 
   291   splitpath = request.path.split('/')
   291   splitpath = request.path.split('/')
   292   splitpath = splitpath[1:] # cut off leading ''
   292   splitpath = splitpath[1:] # cut off leading ''
   293 
   293 
   294   if len(splitpath) < 4:
   294   if len(splitpath) < 4:
   362 
   362 
   363   # TODO(ljvderijk) Make this give a proper error message
   363   # TODO(ljvderijk) Make this give a proper error message
   364   deny(request)
   364   deny(request)
   365 
   365 
   366 def checkCanInvite(request):
   366 def checkCanInvite(request):
   367   """Checks to see if the current user can create an invite
   367   """Checks to see if the current user can create an invite.
   368 
   368 
   369   Note that if the current url is not in the default 'request' form
   369   Note that if the current url is not in the default 'request' form
   370   this method either deny()s or performs the wrong access check.
   370   this method either deny()s or performs the wrong access check.
   371 
   371 
   372   Args:
   372   Args: