Example #1
0
def lists_index():
    #näytä kaikki listat adminille
    if current_user.admin == 1:
        return render_template("lists/listaus.html",
                               lists=Lists.query.all(),
                               jobs=Jobs.query.all(),
                               jform=JobForm())
    #muuten vain käyttäjän omat listat
    return render_template(
        "lists/listaus.html",
        lists=Lists.query.filter_by(account_id=current_user.id),
        jobs=Jobs.query.all(),
        jform=JobForm())
Example #2
0
def jobs_create():
    form = JobForm(request.form)
    if not form.validate():

        return render_template("jobs/new.html", form=form)

    j = Job(form.name.data, form.salary.data,
            form.description.data, current_user.id)

    db.session().add(j)
    db.session().commit()

    return redirect(url_for("jobs_index"))
Example #3
0
def jobs_create(list_id):

    jform = JobForm(request.form)

    if not jform.validate():
        flash("job name has to be at least one character")
        return redirect(url_for("lists_index"))
    j = Jobs(jform.name.data, jform.status.data)
    j.list_id = list_id

    db.session().add(j)
    db.session().commit()

    return redirect(url_for("lists_index"))
Example #4
0
def create_job(list_name, list_id):

    form = JobForm(request.form)

    if not form.validate():
        flash("job name has to be at least one character")
        return redirect(
            url_for("show_list", list_id=list_id, list_name=list_name))

    j = Jobs(form.name.data, form.status.data)
    j.list_id = list_id

    db.session().add(j)
    db.session().commit()

    return redirect(url_for("show_list", list_id=list_id, list_name=list_name))
Example #5
0
def jobs_edit(job_id):
    j = Job.query.get(job_id)

    if j.account_id != current_user.id and current_user.roles != 'ADMIN':

        return login_manager.unauthorized()
    form = JobForm(request.form)

    if not form.validate():

        return render_template("jobs/edit.html", job_id=job_id, form=form)

    j.name = form.name.data
    j.salary = form.salary.data
    j.description = form.description.data

    db.session().commit()
    return redirect(url_for("jobs_index"))
Example #6
0
def show_list(list_id, list_name):
    lista = Lists.query.get(list_id)

    if current_user.admin == 1 or lista.account_id == current_user.id:
        return render_template("lists/showlist.html",
                               list=Lists.query.get(list_id),
                               jobs=Jobs.query.filter_by(list_id=list_id),
                               form=JobForm())

    if lista.type == 1:
        flash("List does not exist or you do now have the rights to see it")
        return redirect(url_for("lists_index"))

    if lista.type == 2:
        return render_template("lists/readonly.html",
                               list=Lists.query.get(list_id),
                               jobs=Jobs.query.filter_by(list_id=list_id))

    if lista.type == 3:
        return render_template("lists/readwrite.html",
                               list=Lists.query.get(list_id),
                               jobs=Jobs.query.filter_by(list_id=list_id),
                               form=JobForm())
Example #7
0
def jobs_edit_form(job_id):
    return render_template("jobs/edit.html", job_id=job_id, form=JobForm())
Example #8
0
def jobs_form():
    return render_template("jobs/new.html", form=JobForm())