Exemplo n.º 1
0
def getNavs():
    '''
    获取菜单
    '''
    category_data = getCategory()
    navs_data = [v for v in category_data if v.is_nav == 1]
    return build_tree(navs_data, 0, 0)
Exemplo n.º 2
0
def article_list():
    category_id = None
    page = 1
    search = ''
    if request.args.get('category_id'):
        category_id = int(request.args.get('category_id'))
    if request.args.get('page'):
        page = int(request.args.get('page'))
    if request.args.get('search'):
        search = request.args.get('search')
    #产品可用标签
    tag_data = Crud.get_data(Tag)
    #栏目树
    category_data = Crud.get_data(Category, Category.sort.desc())
    category_tree = build_tree(category_data, 0, 0)
    #产品栏目
    article_category = [v  for v in category_tree if v['type'] == 2 or v['type'] == 3 ]
    if category_id == None:
        article_data = Crud.search_data_paginate(Article,Article.title.like("%" + search + "%"),Article.sort.desc(),page,10)
    else:
        article_data = Crud.search_data_paginate(Article,and_(Article.category_id == category_id,Article.title.like("%" + search + "%")),Article.sort.desc(),page,10)
    return render_template("admin/article/article_list.html",
                           category_id=category_id,
                           article_data=article_data,
                           article_category = article_category,
                           tag_data = tag_data,
                           )
Exemplo n.º 3
0
def tpl_extra():
    menu_data = Crud.get_data(Menu, Menu.sort.desc())
    rule = str(request.url_rule)
    #用户权限列表
    auth_urls = []
    if  hasattr(current_user, 'id') and current_user.id != 1:
        auth_urls = session.get('auth_urls')
    # 如果有分页,去掉分页标签
    has_pagination = rule.find("<")
    if has_pagination>0:
        rule = rule[0:has_pagination-1]
    #获取当前菜单信息,用于页面展示
    active_menu = Menu.query.filter(Menu.url == rule).first()
    #配置项
    conf_model_data = Crud.get_data(Conf, Conf.sort.desc())
    conf_data,webconfig = [],{}
    for v in conf_model_data:
        conf = object_to_dict(v)
        if conf['optional_values']:
            conf['optional_values'] = (conf['optional_values']).split(',')
        conf_data.append(conf)
        webconfig[conf['ename']] = conf['default_value']
    data = dict(
            online_time= datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
            menu_tree=build_tree(menu_data, 0, 0),
            rule = rule,
            active_menu = active_menu,
            conf_data = conf_data,
            webconfig = webconfig,
            auth_urls = auth_urls
    )
    return data
Exemplo n.º 4
0
def reptile_list():
    request_id = request.args.get('request_id')
    if request_id:
        request_id = int(request_id)
    if request.args.get('page'):
        page = int(request.args.get('page'))
    else:
        page = 1
    request_data = Crud.get_data(ReptileRequest,
                                 ReptileRequest.create_time.desc())
    if request_id:
        page_data = Crud.search_data_paginate(
            ReptileList, ReptileList.request_id == request_id,
            ReptileList.create_time.desc(), page, 20)
    else:
        page_data = Crud.get_data_paginate(ReptileList,
                                           ReptileList.create_time.desc(),
                                           page, 20)
    category_data = Crud.get_data(Category, Category.sort.desc())
    category_tree = build_tree(category_data, 0, 0)
    return render_template("admin/reptile/reptile_list.html",
                           request_data=request_data,
                           page_data=page_data,
                           category_tree=category_tree,
                           request_id=request_id)
Exemplo n.º 5
0
def interface(model_name=None):
    data = {}
    if model_name =='category':
        category_data = Crud.get_data(Category,Category.sort.desc())
        data = build_tree(category_data, 0, 0)
    elif model_name == 'adspace':
        adspace_data = Crud.get_data(Adspace,Adspace.create_time.desc())
        data = [ object_to_dict(v) for v in adspace_data]
    return jsonify(data)
Exemplo n.º 6
0
def template_list(nav_id=None):
    data = Crud.get_data(Category, Category.sort.desc())
    nav_tree = build_tree(data, 0, 0)
    if nav_id == None:
        template_data = Crud.get_data(Template, Template.sort.desc())
    else:
        template_data = Crud.search_data(Template, Template.nav_id == nav_id,
                                         Template.sort.desc())
    return render_template("admin/template/template_list.html",
                           nav_tree=nav_tree,
                           template_data=template_data,
                           nav_id=nav_id)
Exemplo n.º 7
0
def product_list():
    category_id = None
    page = 1
    search = ''
    if request.args.get('category_id'):
        category_id = int(request.args.get('category_id'))
    if request.args.get('page'):
        page = int(request.args.get('page'))
    if request.args.get('search'):
        search = request.args.get('search')
    #产品可用标签
    tag_data = Crud.get_data(Tag)
    #栏目树
    category_data = Crud.get_data(Category, Category.sort.desc())
    category_tree = build_tree(category_data, 0, 0)
    #产品栏目
    product_category = [
        v for v in category_tree if v['type'] == 1 or v['type'] == 3
    ]
    if category_id == None:
        product_data = Crud.search_data_paginate(
            Product, Product.title.like("%" + search + "%"),
            Product.sort.desc(), page, 10)
    else:
        product_data = Crud.search_data_paginate(
            Product,
            and_(Product.category_id == category_id,
                 Product.title.like("%" + search + "%")), Product.sort.desc(),
            page, 10)
    return render_template(
        "admin/product/product_list.html",
        category_id=category_id,
        product_data=product_data,
        product_category=product_category,
        tag_data=tag_data,
    )