Пример #1
0
def material_add():
    form = EditForm()
    if form.validate_on_submit():
        print("valid")
        if form.photo.data:
            form.photo.data.save(dir + '/app/static/img/material/%s_%s.png' % (form.photo.part, form.vendor.data))
        form.add_part()
        return redirect(url_for("material_list"))
    else:
        print(form.errors)
    return render_template('material/add.html', form=form)
Пример #2
0
def material_add():
    form = EditForm()
    if form.validate_on_submit():
        print("valid")
        if form.photo.data:
            form.photo.data.save(dir + '/app/static/img/material/%s_%s.png' %
                                 (form.photo.part, form.vendor.data))
        form.add_part()
        return redirect(url_for("material_list"))
    else:
        print(form.errors)
    return render_template('material/add.html', form=form)
Пример #3
0
def material_edit(part_name):
    part = Material.query.filter_by(part=part_name).first()

    form = EditForm()
    form.pitch.default = part.pitch
    form.pitch.process(request.form)

    form.type.default = part.type
    form.type.process(request.form)

    if form.is_submitted():
        print("submitted")
        if form.validate():
            print("valid")
            if form.photo.data:
                form.photo.data.save(dir +
                                     '/app/static/img/material/%s_%s.png' %
                                     (part.part, form.vendor.data))
            form.save_part()
        else:
            print(form.errors)

    if form.validate_on_submit():
        return redirect(url_for("material_list"))

    return render_template('material/edit.html', part=part, form=form)
Пример #4
0
def material_edit(part_name):
    part = Material.query.filter_by(part=part_name).first()

    form = EditForm()
    form.pitch.default = part.pitch
    form.pitch.process(request.form)

    form.type.default = part.type
    form.type.process(request.form)

    if form.is_submitted():
        print("submitted")
        if form.validate():
            print("valid")
            if form.photo.data:
                form.photo.data.save(dir + '/app/static/img/material/%s_%s.png' % (part.part, form.vendor.data))
            form.save_part()
        else:
            print(form.errors)

    if form.validate_on_submit():
        return redirect(url_for("material_list"))

    return render_template('material/edit.html', part=part, form=form)