def handle(self, *args, **options): for condition_class in get_all_conditions(): for instance in condition_class.objects.all(): if instance.has_timeout: if timezone.now() > instance.get_timeout(): retry_action_signal.send(sender=condition_class, instance=instance, created=False)
def get_condition_class(self, *, condition_type): """Get condition class object given condition type.""" for condition in get_all_conditions(): if condition.__name__.lower() == condition_type.lower(): return condition
def is_valid_condition_type(self, condition_type, lower=True): condition_models = get_all_conditions() for model_type in condition_models: if lower and model_type.__name__.lower() == condition_type.lower(): return True if model_type.__name__ == condition_type: return True return False
def get_possible_conditions(self): """Get all possible conditions.""" return get_all_conditions()
def get_condition_model(condition_type): for condition_model in get_all_conditions(): if condition_model.__name__.lower() == condition_type.lower(): return condition_model