Пример #1
0
def brand_edit(key_id):
    brand = Brand.retrieve_by_id(key_id)
    if not brand:
        return redirect(url_for('admin.product.brands'))
    form = SeriesForm(obj=brand)
    if request.method == 'POST' and 'delete_brand' in request.form:
        brand.key.delete()
        return redirect(url_for('admin.product.brands'))
    if form.is_submitted() and form.validate(is_edit=True):
        form.populate_obj(brand)
        brand.put()
        return redirect(url_for('admin.product.brands'))
    return render_template(
        'product/admin/brand/edit.html',
        brand=brand,
        form=form
    )
Пример #2
0
def series_edit(key_id):
    series = Series.retrieve_by_id(key_id)
    if not series:
        return redirect(url_for('admin.product.series'))
    form = SeriesForm(obj=series)
    if request.method == 'POST' and 'delete_series' in request.form:
        series.key.delete()
        return redirect(url_for('admin.product.series'))
    if form.is_submitted() and form.validate(is_edit=True):
        form.populate_obj(series)
        series.put()
        return redirect(url_for('admin.product.series'))
    return render_template(
        'product/admin/series/edit.html',
        series=series,
        form=form
    )
Пример #3
0
def brand_edit(key_id):
    brand = Brand.retrieve_by_id(key_id)
    if not brand:
        return redirect(url_for('admin.product.brands'))
    form = SeriesForm(obj=brand)
    if request.method == 'POST' and 'delete_brand' in request.form:
        brand.key.delete()
        return redirect(url_for('admin.product.brands'))
    if form.is_submitted() and form.validate(is_edit=True):
        form.populate_obj(brand)
        brand.put()
        return redirect(url_for('admin.product.brands'))
    return render_template('product/admin/brand/edit.html',
                           brand=brand,
                           form=form)
Пример #4
0
def series_edit(key_id):
    series = Series.retrieve_by_id(key_id)
    if not series:
        return redirect(url_for('admin.product.series'))
    form = SeriesForm(obj=series)
    if request.method == 'POST' and 'delete_series' in request.form:
        series.key.delete()
        return redirect(url_for('admin.product.series'))
    if form.is_submitted() and form.validate(is_edit=True):
        form.populate_obj(series)
        series.put()
        return redirect(url_for('admin.product.series'))
    return render_template('product/admin/series/edit.html',
                           series=series,
                           form=form)