def create_harvest_job(self, request, queryset): job_batch_id = JobInterval.Manually.job_batch_id() result = None failed_objects = [] for publish in queryset: result = JobStatemachine.create_job(publish.id, JobInterval.Manually, job_batch_id) if not result[0]: failed_objects.append( ("{0}:{1}".format(publish.workspace.name, publish.name), result[1])) if failed_objects: messages.warning( request, mark_safe( "Create job failed for some selected publishs:<ul>{0}</ul>" .format("".join([ "<li>{0} : {1}</li>".format(o[0], o[1]) for o in failed_objects ])))) else: messages.success( request, "Create job successfully for all selected publishs")
def handle(self, *args, **options): # Parse the days argument as an integer. if options['interval_choice']: if options['publish_id'] or options['publish_name'] : raise Exception("Three options cannot be used together.") else: interval = JobInterval.get_interval(options['interval_choice']) JobStatemachine.create_jobs(interval) elif options['publish_id']: if options['publish_name']: raise Exception("Three options cannot be used together.") else: JobStatemachine.create_job(options['publish_id'],Manually.instance()) elif options['publish_name']: JobStatemachine.create_job_by_name(options['publish_name'],Manually.instance()) else: raise Exception("No option is specified") return 0
def handle(self, *args, **options): # Parse the days argument as an integer. if options['interval_choice']: if options['publish_id'] or options['publish_name']: raise Exception("Three options cannot be used together.") else: interval = JobInterval.get_interval(options['interval_choice']) JobStatemachine.create_jobs(interval) elif options['publish_id']: if options['publish_name']: raise Exception("Three options cannot be used together.") else: JobStatemachine.create_job(options['publish_id'], Manually.instance()) elif options['publish_name']: JobStatemachine.create_job_by_name(options['publish_name'], Manually.instance()) else: raise Exception("No option is specified") return 0
def create_harvest_job(self,request,queryset): job_batch_id = Manually.instance().job_batch_id result = None failed_objects = [] for publish in queryset: result = JobStatemachine.create_job(publish.id,Manually.instance(),job_batch_id) if not result[0]: failed_objects.append(("{0}:{1}".format(publish.workspace.name,publish.name),result[1])) if failed_objects: messages.warning(request, mark_safe("Create job failed for some selected publishs:<ul>{0}</ul>".format("".join(["<li>{0} : {1}</li>".format(o[0],o[1]) for o in failed_objects])))) else: messages.success(request, "Create job successfully for all selected publishs")