예제 #1
0
def news_edit(res_id):

    res_tp = 'news'

    bb_cli = BigbroCache()
    nc = bb_cli.get_resource(res_type=res_tp, res_id=res_id)

    if request.method == 'GET':

        slz = {}
        slz['res_id'] = nc['res_id']
        for k in news_keys:
            slz[k] = nc['content'][k]

        return render_template('news_edit.html', news=slz)

    pre_cover = nc['content']['ncover']

    cnt = {}
    for k in news_keys:
        cnt[k] = request.form[k]

    nc['content'] = cnt
    nc['bb'] = request.username
    bb_cli.update_resource(nc)

    Resources.update_up(res_tp=res_tp,
                        res_id=res_id,
                        content=cnt,
                        update_bb=request.username)

    if pre_cover and pre_cover != nc['content']['ncover']:
        delete_resource(pre_cover)

    return render_template('news_create.html')
예제 #2
0
def project_edit(res_id):

    res_tp = 'project'

    bb_cli = BigbroCache()
    pc = bb_cli.get_resource(res_type=res_tp, res_id=res_id)

    if request.method == 'GET':

        slz = {}
        slz['res_id'] = pc['res_id']
        for k in project_keys:
            slz[k] = pc['content'][k]

        return render_template('project_edit.html', project=slz)

    pre_cover = pc['content']['pcover']

    cnt = {}
    for k in project_keys:
        cnt[k] = request.form[k]

    pc['content'] = cnt
    pc['bb'] = request.username
    bb_cli.update_resource(pc)

    if pre_cover and pre_cover != pc['content']['pcover']:
        delete_resource(pre_cover)

    return render_template('project_create.html')
예제 #3
0
def news_unit():

    act = request.form.get('act')
    nid = request.form.get('nid')
    rtp = 'news'

    if not (act and nid):
        return 'thx_for_request_0'

    bb_cli = BigbroCache()
    nc = bb_cli.get_resource(res_type=rtp, res_id=nid)
    if not nc:
        return 'thx_for_request'

    if act in ['on', 'off']:
        nc['online'] = act
        bb_cli.update_resource(nc)
    elif act == 'fst':
        bb_cli.top_resource(res_type=rtp, res_id=nid)
    elif act == 'del':
        bb_cli.rem_resource_id(res_type=rtp, res_id=nid)
        Resources.bb_delete(res_tp=rtp, res_id=nid, update_bb=request.username)
        if nc['content']['ncover']:
            delete_resource(nc['content']['ncover'])

    return 'ok'
예제 #4
0
def project_unit():

    act = request.form.get('act')
    proid = request.form.get('proid')
    rtp = 'project'

    if not (act and proid):
        return 'thx_for_request_0'

    bb_cli = BigbroCache()
    pc = bb_cli.get_resource(res_type=rtp, res_id=proid)
    if not pc:
        return 'thx_for_request'

    if act in ['on', 'off']:
        pc['online'] = act
        bb_cli.update_resource(pc)
    elif act == 'fst':
        bb_cli.top_resource(res_type=rtp, res_id=proid)
    elif act == 'del':
        bb_cli.rem_resource_id(res_type=rtp, res_id=proid)
        Resources.bb_delete(res_tp=rtp,
                            res_id=proid,
                            update_bb=request.username)
        if pc['content']['pcover']:
            delete_resource(pc['content']['pcover'])

    return 'ok'
예제 #5
0
def banner_edit(res_id):

    res_tp = 'banner'

    bb_cli = BigbroCache()
    bc = bb_cli.get_resource(res_type=res_tp, res_id=res_id)

    if request.method == 'GET':

        slz = {}
        slz['res_id'] = bc['res_id']
        for k in banner_keys:
            slz[k] = bc['content'][k]

        return render_template('banner_edit.html', b=slz)

    pre_cover = bc['content']['bcover']

    for k in banner_keys:
        bc['content'][k] = request.form[k]
    bc['bb'] = request.username

    if pre_cover and pre_cover != bc['content']['bcover']:
        delete_resource(pre_cover)

    bb_cli.update_resource(bc)

    Resources.update_up(res_tp=res_tp,
                        res_id=res_id,
                        content=bc['content'],
                        update_bb=request.username)

    return render_template('banner_create.html')
예제 #6
0
def banner():

    act = request.form.get('act')
    bid = request.form.get('bid')
    rtp = 'banner'

    if not (act and bid):
        return 'thx_for_request_0'

    bb_cli = BigbroCache()
    bc = bb_cli.get_resource(res_type=rtp, res_id=bid)
    if not bc:
        return 'thx_for_request'

    if act in ['on', 'off']:
        bc['online'] = act
        bb_cli.update_resource(bc)
    elif act == 'fst':
        bb_cli.top_resource(res_type=rtp, res_id=bid)
    elif act == 'del':
        bb_cli.rem_resource_id(res_type=rtp, res_id=bid)
        Resources.bb_delete(res_tp=rtp, res_id=bid, update_bb=request.username)
        if bc['content']['bcover']:
            delete_resource(bc['content']['bcover'])

    return 'ok'
예제 #7
0
def webroll_edit(res_id):

    res_tp = 'webroll'

    bb_cli = BigbroCache()
    rc = bb_cli.get_resource(res_type=res_tp, res_id=res_id)

    if request.method == 'GET':

        slz = {}
        slz['res_id'] = rc['res_id']
        for k in webroll_keys:
            slz[k] = rc['content'].get(k, 50)

        return render_template('webroll_edit.html', r=slz)

    pre_logo = rc['content']['rlogo']

    for k in webroll_keys:
        rc['content'][k] = request.form[k]
    rc['bb'] = request.username

    if pre_logo and pre_logo != rc['content']['rlogo']:
        delete_resource(pre_logo)

    bb_cli.update_resource(rc)

    Resources.update_up(res_tp=res_tp,
                        res_id=res_id,
                        content=rc['content'],
                        update_bb=request.username)

    # return render_template('webroll_create.html')

    return redirect(url_for('.webrolls'))
예제 #8
0
def webroll():

    act = request.form.get('act')
    rid = request.form.get('rid')
    rtp = 'webroll'

    if not (act and rid):
        return 'thx_for_request_0'

    bb_cli = BigbroCache()
    rc = bb_cli.get_resource(res_type=rtp, res_id=rid)
    if not rc:
        return 'thx_for_request'

    if act in ['on', 'off']:
        rc['online'] = act
        bb_cli.update_resource(rc)
    elif act == 'fst':
        bb_cli.top_resource(res_type=rtp, res_id=rid)
    elif act == 'del':
        bb_cli.rem_resource_id(res_type=rtp, res_id=rid)
        Resources.bb_delete(res_tp=rtp, res_id=rid, update_bb=request.username)
        if rc['content']['rlogo']:
            delete_resource(rc['content']['rlogo'])

    return 'ok'
예제 #9
0
def remove_resource():

    res_key = request.form['key']
    try:
        delete_resource(res_key)
        rst = 'ok'
    except Exception as e:
        rst = str(e)
    finally:
        return rst
예제 #10
0
def movie_edit(res_id):

    res_tp = 'movie'

    bb_cli = BigbroCache()
    mc = bb_cli.get_resource(res_type=res_tp, res_id=res_id)

    if request.method == 'GET':

        slz = {}
        slz['res_id'] = mc['res_id']
        for k in movie_keys:
            slz[k] = mc['content'].get(k, '')
        slz['mlang'] = mc['content'].get('mlang', 'zh')

        return render_template('movie_edit.html', movie=slz)

    pre_cover = mc['content'].get('mcover', '')
    pre_lang = mc['content'].get('mlang', 'zh')

    cnt = {}
    for k in movie_keys:
        if k == 'clips':
            cnt[k] = request.form.getlist('clips[]')
        elif k == 'posters':
            cnt[k] = request.form.getlist('posters[]')
        elif k == 'videos':
            v_links = request.form.getlist('vdo_links[]')
            v_covers = request.form.getlist('vdo_covers[]')
            v_titles = request.form.getlist('vdo_titles[]')
            cnt[k] = []
            for l, c, t in zip(v_links, v_covers, v_titles):
                cnt[k].append({'vlink': l, 'vcover': c, 'vtitle': t})
        else:
            cnt[k] = request.form[k]
    cnt['mlang'] = request.form.get('mlang', 'zh')

    mc['content'] = cnt
    mc['bb'] = request.username
    bb_cli.update_resource(mc)

    Resources.update_up(res_tp=res_tp,
                        res_id=res_id,
                        content=cnt,
                        update_bb=request.username)

    if pre_lang != mc['content']['mlang']:
        bb_cli.rem_id_from_list(res_tp, res_id, pre_lang)
        bb_cli.add_resource_id(res_tp, res_id, mc['content']['mlang'])

    if pre_cover and pre_cover != mc['content']['mcover']:
        delete_resource(pre_cover)

    return render_template('movie_create.html')
예제 #11
0
def movie():

    act = request.form.get('act')
    mid = request.form.get('mid')
    rtp = 'movie'

    if not (act and mid):
        return 'thx_for_request_0'

    bb_cli = BigbroCache()
    mc = bb_cli.get_resource(res_type=rtp, res_id=mid)
    if not mc:
        return 'thx_for_request'

    if act in ['on', 'off']:
        mc['online'] = act
        bb_cli.update_resource(mc)
    elif act == 'fst':
        bb_cli.top_resource(res_type=rtp, res_id=mid)
    elif act == 'del':
        bb_cli.rem_resource_id(res_type=rtp, res_id=mid)
        Resources.bb_delete(res_tp=rtp, res_id=mid, update_bb=request.username)
        if mc['content']['posters']:
            for p in mc['content']['posters']:
                delete_resource(p)
        if mc['content']['clips']:
            for c in mc['content']['clips']:
                delete_resource(c)
        if mc['content']['mcover']:
            delete_resource(mc['content']['mcover'])
        if mc['content']['videos']:
            for v in mc['content']['videos']:
                delete_resource(v['vcover'])
    elif act == 'rcmd-on':
        bb_cli.set_recommend_movie(movie_id=mid,
                                   lang=mc['content'].get('mlang', 'zh'))
    elif act == 'rcmd-off':
        bb_cli.del_recommend_movie(lang=mc['content'].get('mlang', 'zh'))
    elif act == 'banner-on':
        bb_cli.add_resource_id(res_type='banner', res_id=mid)
    elif act == 'banner-off':
        bb_cli.rem_resource_id(res_type='banner', res_id=mid)

    return 'ok'