app/soc/views/helper/access.py
changeset 2610 95949d4c45d9
parent 2583 3a8275049403
child 2660 e2654d53a643
equal deleted inserted replaced
2609:dc0d4c3d9d2e 2610:95949d4c45d9
   937 
   937 
   938   @allowDeveloper
   938   @allowDeveloper
   939   @denySidebar
   939   @denySidebar
   940   def checkIsHostForProgram(self, django_args):
   940   def checkIsHostForProgram(self, django_args):
   941     """Checks if the user is a host for the specified program.
   941     """Checks if the user is a host for the specified program.
   942     
   942 
   943     Args:
   943     Args:
   944       django_args: a dictionary with django's arguments
   944       django_args: a dictionary with django's arguments
   945     """
   945     """
   946 
   946 
   947     program = program_logic.getFromKeyFields(django_args)
   947     program = program_logic.getFromKeyFields(django_args)
   954 
   954 
   955   @allowDeveloper
   955   @allowDeveloper
   956   @denySidebar
   956   @denySidebar
   957   def checkIsHostForProgramInScope(self, django_args):
   957   def checkIsHostForProgramInScope(self, django_args):
   958     """Checks if the user is a host for the specified program.
   958     """Checks if the user is a host for the specified program.
   959     
   959 
   960     Args:
   960     Args:
   961       django_args: a dictionary with django's arguments
   961       django_args: a dictionary with django's arguments
   962     """
   962     """
   963 
   963 
   964     program = program_logic.getFromKeyName(django_args['scope_path'])
   964     scope_path = django_args.get('scope_path')
       
   965 
       
   966     if not scope_path:
       
   967       raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_DENIED_MSG)
       
   968 
       
   969     program = program_logic.getFromKeyName(scope_path)
   965 
   970 
   966     if not program or program.status == 'invalid':
   971     if not program or program.status == 'invalid':
   967       raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_PROGRAM_MSG)
   972       raise out_of_band.AccessViolation(message_fmt=DEF_NO_ACTIVE_PROGRAM_MSG)
   968 
   973 
   969     django_args = {'scope_path': program.scope_path}
   974     django_args = {'scope_path': program.scope_path}