示例#1
0
文件: views.py 项目: gmist/solostyle
def index():
    form = CountryForm()
    if request.method == 'POST' and form.validate_on_submit():
        country = Country()
        form.populate_obj(country)
        fill_map(form, country)
        country.put()
        return redirect(url_for('country.admin.index'))
    countries = Country.query()
    return render_template('country/admin/index.html',
        form=form,
        countries=countries)
示例#2
0
文件: views.py 项目: gmist/solostyle
def edit(key_id):
    country = Country.retrieve_by_id(key_id)
    if not country:
        return redirect(url_for('country.admin.index'))
    form = CountryForm(obj=country)
    get_form(country, form)
    if request.method == 'POST':
        if 'delete_country' in request.form:
            country.key.delete()
            return redirect(url_for('country.admin.index'))
    if request.method == 'POST' and form.validate_on_submit():
        form.populate_obj(country)
        fill_map(form, country)
        country.put()
        return redirect(url_for('country.admin.index'))
    return render_template(
        'country/admin/edit.html',
        form=form,
        country=country
    )