# HG changeset patch # User Lennard de Rijk # Date 1237392869 0 # Node ID 800ec7253cf4a9780d93dc5df220590ef19d2347 # Parent d92c5f08f24d13853750492c37b80c665209f012 Added new access method that can check if a given event has taken place already. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r d92c5f08f24d -r 800ec7253cf4 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Wed Mar 18 15:29:25 2009 +0000 +++ b/app/soc/views/helper/access.py Wed Mar 18 16:14:29 2009 +0000 @@ -965,6 +965,40 @@ raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG) + @allowDeveloper + @denySidebar + def checkisAfterEvent(self, django_args, event_name, key_name_arg): + """Checks if the given event has taken place for the given program. + + Args: + django_args: a dictionary with django's arguments + event_name: the name of the event which is checked + key_name_arg: the entry in django_args that specifies the given program + keyname. If none is given the key_name is constructed from django_args + itself. + + Raises: + AccessViolationResponse: + * if no active Program is found + * if the event has not taken place yet + """ + + if key_name_arg and key_name_arg in django_args: + key_name = django_args[key_name_arg] + else: + key_name = program_logic.getKeyNameFromFields(django_args) + + program_entity = program_logic.getFromKeyName(key_name) + + if not program_entity or ( + program_entity.status in ['inactive', 'invalid']): + raise out_of_band.AccessViolation(message_fmt=DEF_SCOPE_INACTIVE_MSG) + + if timeline_helper.isAfterEvent(program_entity.timeline, event_name): + return + + raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG) + def checkCanCreateOrgApp(self, django_args, period_name): """Checks to see if the program in the scope_path is accepting org apps