def register_notification_listeners(): """Register notification listeners. Notification listeners will be registered only if `NOTIFICATIONS_ENABLED` flag in settings is set to `True` value. """ if not settings.NOTIFICATIONS_ENABLED: logger.warning( "Could not register notification listeners. Notifications " "are disabled. Use `NOTIFICATIONS_ENABLED` setting to " "enable notifications.") return listeners = extensions.get_module_contributions("NOTIFICATION_LISTENERS") for listener in listeners: listener()
def get_service_function(cls, name): """Get callback function for an object. This returns a service function which is a registered callback for an object that has a notification. Args: name: Name of an object for which we want to get a service function, such as "CycleTask", "Assessment", etc. Returns: callable: A function that takes a notification and returns a data dict with all the data for that notification. """ if not cls.services: cls.services = extensions.get_module_contributions( "contributed_notifications") if name not in cls.services: raise ValueError("unknown service name: %s" % name) return cls.services[name]
def nightly_cron_endpoint(): cron_jobs = extensions.get_module_contributions("CONTRIBUTED_CRON_JOBS") for job in cron_jobs: run_job(job) return 'Ok'
def job_runner(name): """Run all contributed jobs from all extension modules""" cron_jobs = extensions.get_module_contributions(name) for job in cron_jobs: run_job(job) return 'Ok'
def register_notification_listeners(): listeners = extensions.get_module_contributions("NOTIFICATION_LISTENERS") for listener in listeners: listener()
def job_runner(name): cron_jobs = extensions.get_module_contributions(name) for job in cron_jobs: run_job(job) return 'Ok'