示例#1
0
文件: views.py 项目: gmist/solostyle
def edit_page(section_id, page_uid):
    section = CountrySection.retrieve_by_id(section_id)
    if not section:
        return redirect(url_for('country.admin.index'))
    for i, p in enumerate(section.pages):
        if page_uid == p.uid:
            break
    else:
        return redirect(url_for('country.admin.view_section', section_id=section_id))
    if request.method == 'POST' and 'delete_page' in request.form:
        del section.pages[i]
        section.put()
        return redirect(url_for('country.admin.view_section', section_id=section_id))
    page = section.pages[i]
    form = SimplePageForm(obj=page)
    if form.validate_on_submit():
        form.populate_obj(section.pages[i])
        section.put()
        return redirect(url_for('country.admin.view_section', section_id=section_id))
    sections = CountrySection.query()
    country = section.country_key
    if country:
        country=country.get()
    return render_template(
        'country/admin/edit_page.html',
        form=form,
        country=country,
        section=section,
        sections=sections,
        cur_section=section_id
    )
示例#2
0
文件: views.py 项目: gmist/solostyle
def view_section(section_id):
    section = CountrySection.retrieve_by_id(section_id)
    if not section:
        return redirect(url_for('country.admin.index'))
    form = SectionForm(obj=section)
    country = section.country_key
    if request.method == 'POST' and 'delete_section' in request.form:
        section.key.delete()
        if country:
            return redirect(url_for('country.admin.pages', key_id=country.id()))
        return redirect(url_for('country.admin.index'))
    if form.validate_on_submit():
        form.populate_obj(section)
        section.put()
        return redirect(url_for('country.admin.view_section', section_id=section_id))
    sections = CountrySection.query()
    if country:
        country = country.get()
    return render_template(
        'country/admin/section_view.html',
        form=form,
        section=section,
        country=country,
        sections=sections,
        cur_section=section_id
    )
示例#3
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
    )
示例#4
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
    )
示例#5
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()
    )
示例#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
文件: views.py 项目: gmist/solostyle
def add_page(section_id):
    section = CountrySection.retrieve_by_id(section_id)
    if not section:
        return redirect(url_for('country.admin.index'))
    country = section.country_key
    if country:
        country = country.get()
    form = SimplePageForm()
    if form.validate_on_submit():
        page_ = SimplePage()
        page_.uid = uuid()
        form.populate_obj(page_)
        section.pages.append(page_)
        section.put()
        return redirect(url_for('country.admin.view_section', section_id=section_id))
    sections = CountrySection.query()
    return render_template(
        'country/admin/add_page.html',
        form=form,
        country=country,
        sections=sections,
        cur_section=section_id
    )