Beispiel #1
0
def delete_multiple_jobs():
    job_ids = request.form.getlist("job_id")

    job_ids_to_delete = []
    for job_id in job_ids:
        job = Job.query.filter_by(id=job_id).first()
        if not job:
            return (render_template(
                        "pyfarm/error.html", error="Job %s not found" % job_id),
                    NOT_FOUND)

        job.to_be_deleted = True
        db.session.add(job)
        job_ids_to_delete.append(job.id)

        for child in job.children:
            child.to_be_deleted = True
            job_ids_to_delete.append(child.id)
            db.session.add(child)

    db.session.commit()

    for id_ in job_ids_to_delete:
        logger.info("Marking job %s for deletion", id_)
        delete_job.delay(id_)

    flash("Selected jobs will be deleted.")

    if "next" in request.args:
        return redirect(request.args.get("next"), SEE_OTHER)
    else:
        return redirect(url_for("jobs_index_ui"), SEE_OTHER)
def delete_multiple_jobs():
    job_ids = request.form.getlist("job_id")

    job_ids_to_delete = []
    for job_id in job_ids:
        job = Job.query.filter_by(id=job_id).first()
        if not job:
            return (render_template("pyfarm/error.html",
                                    error="Job %s not found" % job_id),
                    NOT_FOUND)

        job.to_be_deleted = True
        db.session.add(job)
        job_ids_to_delete.append(job.id)

        for child in job.children:
            child.to_be_deleted = True
            job_ids_to_delete.append(child.id)
            db.session.add(child)

    db.session.commit()

    for id_ in job_ids_to_delete:
        logger.info("Marking job %s for deletion", id_)
        delete_job.delay(id_)

    flash("Selected jobs will be deleted.")

    if "next" in request.args:
        return redirect(request.args.get("next"), SEE_OTHER)
    else:
        return redirect(url_for("jobs_index_ui"), SEE_OTHER)
Beispiel #3
0
def delete_single_job(job_id):
    job = Job.query.filter_by(id=job_id).first()
    if not job:
        return (render_template(
                    "pyfarm/error.html", error="Job %s not found" % job_id),
                NOT_FOUND)

    job.to_be_deleted = True
    db.session.add(job)

    child_job_ids = []
    for child in job.children:
        child.to_be_deleted = True
        child_job_ids.append(child.id)
        db.session.add(child)

    db.session.commit()

    for id_ in child_job_ids + [job_id]:
        logger.info("Marking job %s for deletion", id_)
        delete_job.delay(id_)

    flash("Job %s will be deleted." % job.title)

    if "next" in request.args:
        return redirect(request.args.get("next"), SEE_OTHER)
    else:
        return redirect(url_for("jobs_index_ui"), SEE_OTHER)
def delete_single_job(job_id):
    job = Job.query.filter_by(id=job_id).first()
    if not job:
        return (render_template("pyfarm/error.html",
                                error="Job %s not found" % job_id), NOT_FOUND)

    job.to_be_deleted = True
    db.session.add(job)

    child_job_ids = []
    for child in job.children:
        child.to_be_deleted = True
        child_job_ids.append(child.id)
        db.session.add(child)

    db.session.commit()

    for id_ in child_job_ids + [job_id]:
        logger.info("Marking job %s for deletion", id_)
        delete_job.delay(id_)

    flash("Job %s will be deleted." % job.title)

    if "next" in request.args:
        return redirect(request.args.get("next"), SEE_OTHER)
    else:
        return redirect(url_for("jobs_index_ui"), SEE_OTHER)