Exemplo n.º 1
0
def index():
    # is a search?
    if 'q' in request.args:
        res = []
        q = request.args.get('q', '')
        q = q.lower()
        sections = Section.query(Section.lname_searchable == q).fetch(10)
        for section in sections:
            r = {}
            r['value'] = section.key.urlsafe()
            r['section_name'] = section.name
            r['section_path'] = section.path
            res.append(r)
        return jsonify({'results': res})

    # sections_tree_ent = ndb.Key('SectionTree', g.language).get()
    # if sections_tree_ent:
    # 	sections_tree = sections_tree_ent.tree
    # else:
    # 	sections_tree = {}
    #
    # root_routes = get_root_routes()
    # return render_template(
    # 	'atuincms/pages/admin/index.html',
    # 	menuid='pages',
    # 	sections_tree=sections_tree,
    # 	root_routes=root_routes
    # )

    sections = get_sections_by_parent(None)
    root_routes = atuincms.router.get_root_routes()
    # menu_lang_form = MenuLangFormAdmin()
    section_form = SectionFormAdmin()

    return render_template('atuincms/sections/admin/index.html',
                           menuid='sections',
                           sections=sections,
                           root_routes=root_routes,
                           section_form=section_form)