def stop_notification(flask_report, id_): jobs = flask_report.sched.get_jobs() for job in jobs: if job.name == 'flask_report_notification' + str(id_): notification = Notification(flask_report, id_) notification.enabled = False notification.dump() flask_report.sched.unschedule_job(job) return 'ok' else: return 'unknown notifiaction:' + str(id_), 404
def start_notification(self, id_): notification = Notification(self, id_) def _closure(environ): def _push_notification(): with self.app.request_context(environ): self.push_notification(id_) return _push_notification job = self.sched.add_cron_job(_closure(request.environ), name='flask_report_notification' + str(id_), **notification.crontab._asdict()) notification.enabled = True notification.dump() return 'ok'
def start_notification(flask_report, id_): notification = Notification(flask_report, id_) def _closure(environ): def _push_notification(): with flask_report.app.request_context(environ): flask_report.push_notification(id_) return _push_notification flask_report.sched.add_cron_job(_closure(request.environ), name='flask_report_notification' + str(id_), **notification.crontab._asdict()) notification.enabled = True notification.dump() return 'ok'