def process(req):
     args = req.args
     ps = dict()
     if u'app' in args:
         ps[u'app'] = args.get(u'app')
     validate_params(SCHEMA, ps)
     ctx = context(req)
     return publisher_services.get_app_products(ctx, ps.get(u'app'))
 def process(req):
     args = req.args
     ps = dict()
     if u'app' in args:
         ps[u'app'] = args.get(u'app')
     validate_params(SCHEMA, ps)
     ctx = context(req)
     return publisher_services.get_app_products(ctx, ps.get(u'app'))
def list_products_page():
    ctx = context(flask.request)
    if not ctx.has_borqs_id():
        return redirect_to_signin()

    app = flask.request.args.get(u'app')
    if not app:
        app = flask.session.get(u'current_app')
        if app:
            return flask.redirect(u'/publisher/products/list.html?app=' + app)
        else:
            return _redirect_to_index()

    all_apps = publisher_services.get_all_apps(ctx)
    if not all_apps:
        return _redirect_to_index()

    categories = publisher_services.get_app_categories(ctx, app)
    products = publisher_services.get_app_products(ctx, app)
    category_products = []
    for c in categories:
        c1 = {
            u'app': c[u'app_id'],
            u'category': c[u'category'],
            u'category_name': c[u'category_name'],
            u'products': []
        }
        for p in products:
            if p[u'category'] == c[u'category']:
                c1[u'products'].append(p)
        category_products.append(c1)

    flask.session[u'current_app'] = app
    resp = flask.render_template(
        u'publisher_product_list.jinja2',
        page_title=u'Edit product',
        app_id=app,
        all_apps=all_apps,
        category_products=category_products,
        ticket=flask.session.get(u'ticket', u''),
        nav_paths=[],
    )
    return resp
def list_products_page():
    ctx = context(flask.request)
    if not ctx.has_borqs_id():
        return redirect_to_signin()

    app = flask.request.args.get(u'app')
    if not app:
        app = flask.session.get(u'current_app')
        if app:
            return flask.redirect(u'/publisher/products/list.html?app=' + app)
        else:
            return _redirect_to_index()

    all_apps = publisher_services.get_all_apps(ctx)
    if not all_apps:
        return _redirect_to_index()

    categories = publisher_services.get_app_categories(ctx, app)
    products = publisher_services.get_app_products(ctx, app)
    category_products = []
    for c in categories:
        c1 = {
            u'app': c[u'app_id'],
            u'category': c[u'category'],
            u'category_name': c[u'category_name'],
            u'products': []
        }
        for p in products:
            if p[u'category'] == c[u'category']:
                c1[u'products'].append(p)
        category_products.append(c1)

    flask.session[u'current_app'] = app
    resp = flask.render_template(u'publisher_product_list.jinja2',
                                 page_title=u'Edit product',
                                 app_id=app,
                                 all_apps=all_apps,
                                 category_products=category_products,
                                 ticket=flask.session.get(u'ticket', u''),
                                 nav_paths=[],
    )
    return resp