def column(class_id): if not session.get('is_login', False): return redirect(URL_BASE + '/login') user = model(ident=session['username'], pwd=session['password']) if request.method == 'POST': print request.form datas = json.loads(request.form['datas']) fuc = request.form['fuc'] return user.method(mod_name='ContentMod', fuc_name=fuc, params={'class_id': class_id}, datas=datas) elif request.method == 'GET': print request.args column_info = CMS.column_info({'class_id': class_id}) temp = CMS.setting_info('content')['content_default'][column_info['type']]['data'] if column_info['type'] + '.html' in user.base.get_column_html(BASE_DIR): content_page = '/column/' + column_info['type'] + '.html' else: content_page = '/column_content.html' search_data = dict(limit=int(request.args['limit']) if 'limit' in request.args else 10, skip=int(request.args['skip']) if 'skip' in request.args else 0, ident=request.args['ident'] if 'ident' in request.args and json.loads(request.args['ident']) != {} else {}) search_data['ident'].update({'class_id': class_id}) list_data = user.method(mod_name='ContentMod', fuc_name='get_list', **search_data) return render_template('backstage/column.html', list_data=list_data, class_id=class_id, temp=temp, father=column_info['father'], content_title='内容管理: ' + CMS.column_info({'class_id': class_id})['title'], content_power=user.frame.content_fuc(class_id), content_page=content_page, **frame_data(user))
def __get_column(self): if self.user.group == 'super': column = CMS.setting_info('system')['all_column'] else: column = [] for n in [ 'ContentMod#insert', 'ContentMod#modify', 'ContentMod#remove', 'ContentMod#search' ]: if n in self.user.permission.keys(): column.extend(self.user.permission[n]) column = list(set(column)) from collections import defaultdict tree = lambda: defaultdict(tree) data = tree() def add(t, keys, v=None): if v is None: v = [] if len(keys) > 1: for n in range(len(keys)): if n == len(keys) - 1: t[keys[n]] = v else: t = t[keys[n]] for n in column: info = CMS.column_info({'class_id': n}) addr = info['address'].split('/') if info['type'] != 'column': if self.user.group == 'super': permission = [ 'ContentMod#insert', 'ContentMod#modify', 'ContentMod#remove', 'ContentMod#search', 'ContentMod#review' ] else: permission = [] for m in [ 'ContentMod#insert', 'ContentMod#modify', 'ContentMod#remove', 'ContentMod#search', 'ContentMod#review' ]: if m in self.user.permission.keys(): permission.append(m) add(data, addr, permission) import json data = json.loads(json.dumps(data)) sorted(data.iteritems(), key=lambda x: x[1]) return data
def get_column_name(column_id): return CMS.column_info({'class_id': column_id})['type']
def data_format(self, form_data, class_id): from core import CMS data = json.loads(json.dumps(form_data)) tmp = CMS.setting_info('content')[CMS.column_info( {'class_id': class_id})['type']]