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)
def pages(key_id): country = Country.retrieve_by_id(key_id) sections = CountrySection.query(CountrySection.country_key == country.key) if not country: return redirect(url_for('country.admin.index')) return render_template( 'country/admin/pages.html', country=country, sections=sections )
def get_country(key_id): country = Country.retrieve_by_id(key_id) if not country: return redirect(url_for('country.index')) sections = CountrySection.query(CountrySection.country_key == country.key) return render_template( 'country/get.html', html_class='country_page', country=country, sections=sections, active_country_id=country.key.id() )
def add_section(key_id): country = Country.retrieve_by_id(key_id) if not country: return redirect(url_for('country.admin.index')) form = SectionForm() if form.validate_on_submit(): section = CountrySection(country_key=country.key) form.populate_obj(section) section.put() return redirect(url_for('country.admin.pages', key_id=key_id)) return render_template( 'country/admin/add_section.html', country=country, form=form )
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 )
def get_page(key_id, section_id, page_id): country = Country.retrieve_by_id(key_id) if not country: return redirect(url_for('country.index')) section = CountrySection.retrieve_by_id(section_id) if not section: return redirect(url_for('country.get', key_id=key_id)) for i, p in enumerate(section.pages): if p.uid == page_id: break else: return redirect(url_for('country.get', key_id=key_id)) sections = CountrySection.query(CountrySection.country_key == country.key) return render_template( 'country/get_page.html', html_class='country_page', country=country, section=section, sections=sections, active_page=page_id, page=section.pages[i] )
def get_countries_side(active_country_id): countries = Country.query(Country.is_public == True).order(Country.name) return render_template("j_env/countries_side.html", active_country_id=active_country_id, countries=countries)
def get_countries_menu(in_country): countries = Country.query(Country.is_public == True).order(Country.name) return render_template("j_env/countries_menu.html", in_country=in_country, countries=countries)