示例#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 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
    )
示例#3
0
文件: views.py 项目: gmist/solostyle
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()
    )
示例#4
0
文件: views.py 项目: gmist/solostyle
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
    )
示例#5
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
    )
示例#6
0
文件: views.py 项目: gmist/solostyle
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]
    )
示例#7
0
文件: menu.py 项目: gmist/solostyle
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)
示例#8
0
文件: menu.py 项目: gmist/solostyle
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)