Ejemplo n.º 1
0
async def get_list_rb_post(request):
	if not user_is_logged_in(request): return user_not_logged()
	all_view = []
	# type = get_post('type')
	for res in request.db.map.find({'type':'templ'}):
		title = ct(request, res['conf']['title'])
		if 'owner' in res['conf'] and res['conf']['owner'] != '_':
			mt = get_mt(request, res['conf']['owner'])
			if not mt: continue
			title = '%s: %s' % (ct(request, mt['conf']['title']), title)
		all_view.append({'_id':res['_id'], 'title':title })
	return response_json(request,  {"result":"ok", "list_rb":all_view})
Ejemplo n.º 2
0
def get_doc_title_cascad(request, doc, value = None):
	""" проверяем что есть поле title или name или value и что оно не равно 32 и в нем нет цыфр
	    это для того чтоб не попадало _id в выпадающий список
	"""
	# die(doc)
	title = ''
	if 'title' in doc['doc']:
		titl = ct(request, doc['doc']['title'])
		if (len(titl) != 32 or len(titl) != 34 ) and not is_str( titl ):
			title = ct(request,  doc['doc']['title'])
	elif 'name' in doc['doc']:
		name = ct(request,  doc['doc']['name'])
		if (len(name)  != 32 or len(name)  != 34 ) and not is_str( name ):
			title = ct(request,  doc['doc']['name'])
	elif 'value' in doc['doc']:
		val = ct(request,  doc['doc']['value'])
		if (len(val) != 32 or len(val)  != 34 ) and not is_str( val ):
	# elif 'value' in doc['doc']:
			title = ct(request, doc['doc']['value'])
	else:
		meta = get_mt(request, doc['doc_type'])
		if 'conf' in meta and 'is_doc' in meta['conf'] and meta['conf']['is_doc']:
			title = ct(request, meta['conf']['title'])+u' № - от -'
		else: # мы совсем не понимаем как так произошло, но...
			title = value
	return title
Ejemplo n.º 3
0
def get_doc_title(request, doc, value = None):
	""" проверяем что есть поле title или name или value и что оно не равно 32 и в нем нет цыфр
	    это для того чтоб не попадало _id в выпадающий список
	"""
	title = ''
	if 'title' in doc['doc']:
		title = ct(request,  doc['doc']['title'])
	elif 'name' in doc['doc']:
		title = ct(request,  doc['doc']['name'])
	elif 'value' in doc['doc']:
		title = ct(request,  doc['doc']['value'])
	else:
		meta = get_mt(request, doc['doc_type'])
		if 'conf' in meta and 'is_doc' in meta['conf'] and meta['conf']['is_doc']:
			title = ct(request, meta['conf']['title'])+u' № - от -'
		else: # мы совсем не понимаем как так произошло, но...
			title = value
	return title
Ejemplo n.º 4
0
def get_list_branch_post1(request):
	if not user_is_logged_in(request): return user_not_logged()
	proc_id = request.match_info.get('proc_id')
	branch = []
	doc = request.db.tree.find_one({'_id':'tree:'+proc_id})
	tree = doc['tree']
	branch.append({"id":"", "title":"-"})
	for res in tree:
		branch.append({"id":res, "title":ct(request, tree[res]['title'])})
	return response_json(request, {"result":"ok", "list_branch":branch })
Ejemplo n.º 5
0
async def get_list_cascad_doc_post(request):
	if not user_is_logged_in(request): return user_not_logged()
	# proc_id = get_post('proc_id')
	data = get_post(request)
	rel_field  = data['rel_field']
	doc_id     = data['doc_id']
	proc_id    = data['rb_id']
	docs = []

	doc = request.db.doc.find_one({'_id':doc_id})
	filter_name_id = ct(request, doc['doc'][rel_field])

	owner_id_ware_class = request.db.doc.find_one({'_id':filter_name_id})['owner']
	for res in request.db.doc.find({'doc_type':proc_id, 'owner':owner_id_ware_class, 'doc.title':filter_name_id}):
		title = get_doc_title(request, res, res['_id'])
		docs.append({ "id":res['_id'], "title":title })
	return response_json(request,  {"result":"ok", "list_doc":json.dumps(docs)})
Ejemplo n.º 6
0
Archivo: perm.py Proyecto: snjypl/tao1
async def users_group_post(request):
	""" Отображает список прав ролей для таблицы установки прав"""
	if not user_is_logged_in(request): return {"result": "fail", "error": "The session ended Login", "need_action":"login"}
	data = await request.post()
	filter = json.loads(data['filter'])
	data=[]
	roles = get_perm(request)
	condition = {'doc_type':'des:users'}

	if 'title' in filter['column'] and filter['column']['title']:
		regex = re.compile( str(filter['column']['title']['val']), re.I | re.UNICODE)
		condition['doc.name.'+cur_lang(request)] = regex

#	pages, req = get_pagination2(condition)

	count = 0
	for list_users in request.db.doc.find(condition):
		results = []
		skip = False
		for role in roles:
			val = list_users['_id'] in roles[role]
			if role in filter['column'] and filter['column'][role]:
				if filter['column'][role]['val'] == 't' and not val or filter['column'][role]['val'] == 'f' and val:
					skip = True
					continue
			results.append((role, ins_img(val), val))
		if skip: continue
		count += 1
		user_name = ct(request, list_users['doc']['name']) if 'name' in list_users['doc'] else 'no name'
		data.append( build_row_report_name(title=user_name, results=results, level=0, id=list_users['_id'], parent='_', child=[] ) )

	# cur_page = int(request.GET['page']) if 'page' in request.GET else 1
	cur_page = int(filter['page']['current']) if 'page' in filter else 1
	limit = int(get_const_value(request, 'doc_page_limit'))

	count = int(ceil(count/limit))

	data = data[(cur_page - 1) * limit : cur_page * limit]
	pages = {'count': count, 'current':cur_page, 'next': 0, 'prev':0}
	head = report_cons_head([('title', 'Пользователи')]+[(i, i) for i in roles], 'checkbox', 'true')

	# print( {"result":"ok", "head":head, "data":json.dumps( data ), "pages":json.dumps( pages)} )
	# print('data->', data)
	# return response_json(request, {"result":"ok", "head":head, "data":json.dumps( data ), "pages":json.dumps( pages)})
	print('heqd->', head)
	return response_json(request, {"result":"ok", "head":head, "data":data, "pages":pages })