Exemple #1
0
def create():
    form = CreateTimesheetForm(request.form)
    if request.method == "POST" and form.validate():
        timesheet = Timesheet(title=form.title.data, month=form.month.data, year=form.year.data)
        timesheet.user_id = current_user.id
        db.session.add(timesheet)
        db.session.commit()
        flash("Your timesheet was created")
        return redirect(url_for("timesheet.index"))
    return render_template("timesheets/timesheet_create.html", form=form)
Exemple #2
0
def destroy(id):
    post = Timesheet.get_by_id(id)
    db.session.delete(post)
    db.session.commit()
    flash("deleted")

    return redirect(url_for("timesheet.index"))
Exemple #3
0
def update(id):
    timesheet = Timesheet.get_by_id(id)
    form = EditTimesheetForm(request.form, obj=timesheet)

    if form.validate_on_submit():
        form.populate_obj(obj=timesheet)
        db.session.commit()
        flash("timesheet updated")
        return redirect(url_for("timesheet.index"))
    return render_template("timesheets/timesheet_edit.html", form=form, timesheet=timesheet)
Exemple #4
0
def print(id):
    timesheet = Timesheet.get_by_id(id)

    return render_template("timesheets/timesheet_print.html", timesheet=timesheet)
Exemple #5
0
def edit(id):
    timesheet = Timesheet.get_by_id(id)
    form = EditTimesheetForm(request.form, obj=timesheet)
    form.populate_form(timesheet)
    return render_template("timesheets/timesheet_edit.html", form=form, timesheet=timesheet)
Exemple #6
0
def show(id):
    item = Timesheet.get_by_id(id)
    return render_template("timesheets/timesheet_detail.html", item=item)