app/soc/views/helper/access.py
changeset 1922 800ec7253cf4
parent 1876 a77d4cdcc052
child 1995 768f533d91e3
equal deleted inserted replaced
1921:d92c5f08f24d 1922:800ec7253cf4
   963     if timeline_helper.isActivePeriod(program_entity.timeline, period_name):
   963     if timeline_helper.isActivePeriod(program_entity.timeline, period_name):
   964       return
   964       return
   965 
   965 
   966     raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG)
   966     raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG)
   967 
   967 
       
   968   @allowDeveloper
       
   969   @denySidebar
       
   970   def checkisAfterEvent(self, django_args, event_name, key_name_arg):
       
   971     """Checks if the given event has taken place for the given program.
       
   972 
       
   973     Args:
       
   974       django_args: a dictionary with django's arguments
       
   975       event_name: the name of the event which is checked
       
   976       key_name_arg: the entry in django_args that specifies the given program
       
   977         keyname. If none is given the key_name is constructed from django_args
       
   978         itself.
       
   979 
       
   980     Raises:
       
   981       AccessViolationResponse:
       
   982       * if no active Program is found
       
   983       * if the event has not taken place yet
       
   984     """
       
   985 
       
   986     if key_name_arg and key_name_arg in django_args:
       
   987       key_name = django_args[key_name_arg]
       
   988     else:
       
   989       key_name = program_logic.getKeyNameFromFields(django_args)
       
   990 
       
   991     program_entity = program_logic.getFromKeyName(key_name)
       
   992 
       
   993     if not program_entity or (
       
   994         program_entity.status in ['inactive', 'invalid']):
       
   995       raise out_of_band.AccessViolation(message_fmt=DEF_SCOPE_INACTIVE_MSG)
       
   996 
       
   997     if timeline_helper.isAfterEvent(program_entity.timeline, event_name):
       
   998       return
       
   999 
       
  1000     raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG)
       
  1001 
   968   def checkCanCreateOrgApp(self, django_args, period_name):
  1002   def checkCanCreateOrgApp(self, django_args, period_name):
   969     """Checks to see if the program in the scope_path is accepting org apps
  1003     """Checks to see if the program in the scope_path is accepting org apps
   970     
  1004     
   971     Args:
  1005     Args:
   972       django_args: a dictionary with django's arguments
  1006       django_args: a dictionary with django's arguments