@staff_member_required<EOL>def enqueue_job(request, queue_index, job_id):
queue_index = int(queue_index)<EOL>queue = get_queue_by_index(queue_index)<EOL>job = Job.fetch(job_id, connection=queue.connection)<EOL>if request.method == '<STR_LIT:POST>':<EOL><INDENT>queue.enqueue_job(job)<EOL>if job.get_status() == JobStatus.DEFERRED:<EOL><INDENT>registry = DeferredJobRegistry(queue.name, queue.connection)<EOL>registry.remove(job)<EOL><DEDENT>elif job.get_status() == JobStatus.FINISHED:<EOL><INDENT>registry = FinishedJobRegistry(queue.name, queue.connection)<EOL>registry.remove(job)<EOL><DEDENT>messages.info(request, '<STR_LIT>' % job.id)<EOL>return redirect('<STR_LIT>', queue_index, job_id)<EOL><DEDENT>context_data = {<EOL>'<STR_LIT>': queue_index,<EOL>'<STR_LIT>': job,<EOL>'<STR_LIT>': queue,<EOL>}<EOL>return render(request, '<STR_LIT>', context_data)<EOL>
Enqueue deferred jobs