Пример #1
0
def add(event_id):
    form = JobForm(request.form)

    if form.validate_on_submit():
        try:

            job = Job(
                name=form.name.data,
                hour=form.hour.data,
                minute=form.minute.data,
                second=form.second.data,
                event_id=event_id,
                weekdays_only=form.weekdays_only.data,
            )

            job_dao.create_job(job)
            flash("Job added.", "success")
            return redirect(url_for("job.view", event_id=event_id))

        except Exception as e:
            flash("Job add fail {}".format(e), "danger")
            print(e)
            return render_template("job/add_edit.html", form=form)

    return render_template("job/add_edit.html", form=form)
Пример #2
0
def edit(job_id):
    job = job_dao.get_job_by_id(job_id)
    form = JobForm(request.form, job)

    if form.validate_on_submit() and request.method == "POST":
        form.populate_obj(job)
        job_dao.update_job(job)
        flash("Job Edited", "success")
        return redirect(url_for("job.view", event_id=job.event_id))

    return render_template("job/add_edit.html", form=form, job_id=job_id)
Пример #3
0
def edit(job_id):
    job = job_dao.get_job_by_id(job_id)
    form = JobForm(request.form, job)

    if form.validate_on_submit() and request.method == 'POST':
        form.populate_obj(job)
        job_dao.update_job(job)
        flash("Job Edited", 'success')
        return redirect(url_for("job.view", event_id=job.event_id))

    return render_template('job/add_edit.html', form=form, job_id=job_id)
Пример #4
0
def add(event_id):
    form = JobForm(request.form)

    if form.validate_on_submit():
        try:

            job = Job(name=form.name.data,
                      hour=form.hour.data,
                      minute=form.minute.data,
                      second=form.second.data,
                      event_id=event_id,
                      weekdays_only=form.weekdays_only.data)

            job_dao.create_job(job)
            flash('Job added.', 'success')
            return redirect(url_for("job.view", event_id=event_id))

        except Exception as e:
            flash('Job add fail {}'.format(e), 'danger')
            print(e)
            return render_template('job/add_edit.html', form=form)

    return render_template('job/add_edit.html', form=form)