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'))
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')
def about_edit(res_id): res_tp = 'about' bb_cli = BigbroCache() ac = bb_cli.get_resource(res_type=res_tp, res_id=res_id) if request.method == 'GET': slz = {} slz['res_id'] = ac['res_id'] for k in about_keys: slz[k] = ac['content'][k] return render_template('about_edit.html', about=slz) cnt = {} for k in about_keys: cnt[k] = request.form[k] cnt['lang'] = ac['content'].get('lang', 'zh') ac['content'] = cnt ac['bb'] = request.username bb_cli.update_resource(ac) Resources.update_up(res_tp=res_tp, res_id=res_id, content=cnt, update_bb=request.username) a = { 'res_id': ac['res_id'], 'bb': ac['bb'], 'created': timestamp_to_strftime(ac['created']), 'adetail': ac['content']['adetail'] } return render_template('hh_about.html', about=a)