@@ -0,0 +1,1190 @@
+import portality.scripts.anon_export as anon_export_core%0Afrom portality import background_helper%0Afrom portality.background import BackgroundTask%0Afrom portality.decorators import write_required%0Afrom portality.tasks.redis_huey import main_queue, schedule%0A%0A%0Aclass AnonExportBackgroundTask(BackgroundTask):%0A    __action__ = %22anon_export%22%0A%0A    def run(self):%0A        anon_export_core.anon_export()%0A        self.background_job.add_audit_message(%22Anon export completed%22)%0A%0A    def cleanup(self):%0A        pass%0A%0A    @classmethod%0A    def prepare(cls, username, **kwargs):%0A        return background_helper.create_job(username=username,%0A                                            action=cls.__action__)%0A%0A    @classmethod%0A    def submit(cls, background_job):%0A        background_job.save()%0A        anon_export.schedule(args=(background_job.id,), delay=10)%0A%0A%0A@main_queue.periodic_task(schedule(AnonExportBackgroundTask.__action__))%0A@write_required(script=True)%0Adef scheduled_anon_export():%0A    background_helper.submit_task_basic(AnonExportBackgroundTask)%0A%0A%0A@main_queue.task()%0A@write_required(script=True)%0Adef anon_export(job_id):%0A    background_helper.execute_by_job_id(job_id, AnonExportBackgroundTask)%0A

add tasks anon_export