def validate_identifier_is_task(state_entries, identifier, address): try: container = message_accessor.get_task_container( state_accessor.get_state_entry(state_entries, address)) if not message_accessor.is_in_task_container(container, identifier): raise InvalidTransaction("{} is not a task.".format(identifier)) except KeyError: raise InvalidTransaction("{} is not a task".format(identifier))
def validate_create_task_state(state_entries, payload): user_validator.validate_list_of_user_are_users(state_entries, payload.admins) user_validator.validate_list_of_user_are_users(state_entries, payload.owners) try: entry = state_accessor.get_state_entry( state_entries, addresser.task.address(payload.task_id)) container = message_accessor.get_task_container(entry) if message_accessor.is_in_task_container(container, payload.task_id): raise InvalidTransaction("Task with id {} already in " "state".format(payload.task_id)) except KeyError: # The task container is not in state, so no at this address. pass