Exemple #1
0
def create():
    bed = {}
    if request.method == 'POST':
        bed['top_left_x'] = request.form['top_left_x']
        bed['top_left_y'] = request.form['top_left_y']
        bed['x_length'] = request.form['x_length']
        bed['y_length'] = request.form['y_length']
        create_bed(bed)
        make_beds_svg()
        return redirect(url_for('bed.index'))
    else:
        return render_template('bed/create.html')
Exemple #2
0
def update(id):
    if request.method == 'POST':
        bed = {}
        bed['top_left_x'] = request.form['top_left_x']
        bed['top_left_y'] = request.form['top_left_y']
        bed['x_length'] = request.form['x_length']
        bed['y_length'] = request.form['y_length']
        bed['id'] = id
        update_bed(bed)
        make_beds_svg()
        return redirect(url_for('bed.index'))
    else:
        bed = get_bed(id)
        return render_template('bed/update.html', bed=bed)
Exemple #3
0
def create(bed_id):
    if request.method == 'POST':
        planting = {}
        planting['top_left_x'] = request.form['top_left_x']
        planting['top_left_y'] = request.form['top_left_y']
        planting['x_length'] = request.form['x_length']
        planting['y_length'] = request.form['y_length']
        planting['plant_type'] = request.form['plant_type']
        planting['date_planted'] = request.form['date_planted']
        planting['date_harvested'] = request.form['date_harvested']
        planting['bed_id'] = bed_id
        create_planting(planting)
        make_beds_svg()
        # should probably have a make_bed_svg in here
        return redirect(url_for('bed.view', id=bed_id))
    else:
        return render_template('planting/create.html')
Exemple #4
0
def update(bed_id, planting_id):
    if request.method == 'POST':
        planting = {}
        planting['top_left_x'] = request.form['top_left_x']
        planting['top_left_y'] = request.form['top_left_y']
        planting['x_length'] = request.form['x_length']
        planting['y_length'] = request.form['y_length']
        planting['plant_type'] = request.form['plant_type']
        planting['date_planted'] = request.form['date_planted']
        planting['date_harvested'] = request.form['date_harvested']
        planting['id'] = planting_id
        update_planting(planting)
        make_beds_svg()
        bed = get_bed(bed_id)
        make_bed_svg(bed)
        plantings = get_plantings(bed_id)
        # would be better to show the planting here, but I haven't figured that out yet.
        return render_template('bed/view.html', bed=bed, plantings=plantings)

    else:
        planting = get_planting(planting_id)
        return render_template('planting/update.html', planting=planting)
    return None
Exemple #5
0
def delete(id):
    delete_bed(id)
    make_beds_svg()
    return redirect(url_for('bed.index'))