Exemplo n.º 1
0
Arquivo: shop.py Projeto: alikzao/tao1
def list_filters(request, cls, filters):
	""" если чтото выбрали для фильтров
	"""
	from libs.sites.sites import get_pagination, get_full_docs, get_curr_img, get_full_doc
	from libs.files.files import get_nf
	db = request.db; clss = []
	parent_id = db.doc.find_one({'doc_type':'des:ware_class', 'doc.alias':cls})
	for doc in db.doc.find({'doc_type':'des:ware_class', 'parent':parent_id['_id']}).sort('doc.date', -1):
		proc_id = doc['doc_type']
		attachment = get_nf(proc_id, doc['_id'], 1)
		data = doc['doc']
		try:
			count = count_ware(doc['_id'])
		except: count='1'
		full_doc = {"_id":doc['_id'], "id": doc['_id'],
		            'count':count,
		            "doc": data,
		            "att": attachment, "img":get_curr_img(doc, attachment), 'proc_id':proc_id}
		clss.append(full_doc)

	pages= ''
	docs = set_filters( parent_id['_id'], filters )

	filter = get_filters(parent_id['_id'])

	seo = db.doc.find_one({'doc.alias':'class_seo'}, {'doc.description':1, 'doc.tags':1, 'doc.body':1, 'doc.footer':1, 'doc.add_title':1 })
	seo = seo if 'doc' in seo else ''
	return templ('list_class', request, {'result':'ok', 'cls_docs':clss, 'cls':cls, 'docs':docs, 'proc_id':'des:ware', 'pages':pages,
	                            'path':get_navigate(parent_id['_id']), 'parent_doc':get_full_doc(parent_id['_id']), 'filter':filter, 'seo':seo})
Exemplo n.º 2
0
Arquivo: shop.py Projeto: snjypl/tao1
def first_cls(request):
    """ выводит корневые категории, в основном для главной страницы """
    from libs.sites.sites import get_full_docs, get_curr_img
    from libs.files.files import get_nf
    db = request.db
    docs = []
    for doc in db.doc.find({
            'doc_type': 'des:ware_class',
            'parent': '_'
    }).sort('doc.date', -1):
        proc_id = doc['doc_type']
        attachment = get_nf(proc_id, doc['_id'], 1)
        data = doc['doc']
        try:
            count = count_ware(doc['_id'])
        except:
            count = '1'
        full_doc = {
            "_id": doc['_id'],
            "id": doc['_id'],
            'count': count,
            "doc": data,
            "att": attachment,
            "img": get_curr_img(doc, attachment),
            'proc_id': proc_id
        }
        docs.append(full_doc)

    return docs
Exemplo n.º 3
0
Arquivo: shop.py Projeto: alikzao/tao1
def list_class(request, cls):
	""" показывает список вложеных категорий и товаров для категорий
	"""
	from libs.sites.sites import get_pagination, get_full_docs, get_curr_img, get_full_doc
	from libs.files.files import get_nf
	db = request.db; clss = []
	parent_id = db.doc.find_one({'doc_type':'des:ware_class', 'doc.alias':cls})
	for doc in db.doc.find({'doc_type':'des:ware_class', 'parent':parent_id['_id']}).sort('doc.date', -1):
		proc_id = doc['doc_type']
		d_img = doc['default_img'] if 'default_img' in doc and doc['default_img'] else None
		attachment = get_nf(proc_id, doc['_id'], 1)
		data = doc['doc']
		try:
			count = count_ware(doc['_id'])
		except: count='1'
		full_doc = {"_id":doc['_id'], "id": doc['_id'],
		            'count':count,
		            "doc": data,
		            "att": attachment, "img":get_curr_img(doc, attachment), 'default_img':d_img, 'proc_id':proc_id}
		clss.append(full_doc)
	pages= ''
	docs = get_full_docs(db.doc.find({'doc_type':'des:ware', 'doc.class':parent_id['_id']}).sort('doc.date', -1))
	# docs = get_full_docs(req).sort('doc.date', -1)
	filter = get_filters(parent_id['_id'])
	# filter = get_ware_cls(cls)
	parent_doc = get_full_doc(parent_id['_id'])
	# seo = db.doc.find_one({'doc.alias':'class_seo'}, {'doc.title':1, 'doc.tags':1, 'doc.body':1, 'doc.footer':1, 'doc.add_title':1 })
	seo = db.doc.find_one({'_id':parent_id['_id']}, {'doc.description':1, 'doc.tags':1, 'doc.footer':1 })
	# seo = seo if 'doc' in seo else ''
	return templ('list_class', request, dict(cls_docs = clss, cls=cls, docs = docs, proc_id='des:ware', pages = pages,
	                                         path=get_navigate(parent_id['_id']), parent_doc=parent_doc, filter=filter, seo=seo) )
Exemplo n.º 4
0
Arquivo: shop.py Projeto: snjypl/tao1
def list_filters(request, cls, filters):
    """ если чтото выбрали для фильтров
	"""
    from libs.sites.sites import get_pagination, get_full_docs, get_curr_img, get_full_doc
    from libs.files.files import get_nf
    db = request.db
    clss = []
    parent_id = db.doc.find_one({
        'doc_type': 'des:ware_class',
        'doc.alias': cls
    })
    for doc in db.doc.find({
            'doc_type': 'des:ware_class',
            'parent': parent_id['_id']
    }).sort('doc.date', -1):
        proc_id = doc['doc_type']
        attachment = get_nf(proc_id, doc['_id'], 1)
        data = doc['doc']
        try:
            count = count_ware(doc['_id'])
        except:
            count = '1'
        full_doc = {
            "_id": doc['_id'],
            "id": doc['_id'],
            'count': count,
            "doc": data,
            "att": attachment,
            "img": get_curr_img(doc, attachment),
            'proc_id': proc_id
        }
        clss.append(full_doc)

    pages = ''
    docs = set_filters(parent_id['_id'], filters)

    filter = get_filters(parent_id['_id'])

    seo = db.doc.find_one({'doc.alias': 'class_seo'}, {
        'doc.description': 1,
        'doc.tags': 1,
        'doc.body': 1,
        'doc.footer': 1,
        'doc.add_title': 1
    })
    seo = seo if 'doc' in seo else ''
    return templ(
        'list_class', request, {
            'result': 'ok',
            'cls_docs': clss,
            'cls': cls,
            'docs': docs,
            'proc_id': 'des:ware',
            'pages': pages,
            'path': get_navigate(parent_id['_id']),
            'parent_doc': get_full_doc(parent_id['_id']),
            'filter': filter,
            'seo': seo
        })
Exemplo n.º 5
0
Arquivo: shop.py Projeto: alikzao/tao1
def first_cls(request):
	""" выводит корневые категории, в основном для главной страницы """
	from libs.sites.sites import get_full_docs, get_curr_img
	from libs.files.files import get_nf
	db = request.db; docs = []
	for doc in db.doc.find({'doc_type':'des:ware_class', 'parent':'_'}).sort('doc.date', -1):
		proc_id = doc['doc_type']
		attachment = get_nf(proc_id, doc['_id'], 1)
		data = doc['doc']
		try:
			count = count_ware(doc['_id'])
		except: count = '1'
		full_doc = {"_id":doc['_id'], "id": doc['_id'],
		            'count':count,
		            "doc": data,
		            "att": attachment, "img":get_curr_img(doc, attachment), 'proc_id':proc_id}
		docs.append(full_doc)

	return docs
Exemplo n.º 6
0
Arquivo: shop.py Projeto: snjypl/tao1
def list_class(request, cls):
    """ показывает список вложеных категорий и товаров для категорий
	"""
    from libs.sites.sites import get_pagination, get_full_docs, get_curr_img, get_full_doc
    from libs.files.files import get_nf
    db = request.db
    clss = []
    parent_id = db.doc.find_one({
        'doc_type': 'des:ware_class',
        'doc.alias': cls
    })
    for doc in db.doc.find({
            'doc_type': 'des:ware_class',
            'parent': parent_id['_id']
    }).sort('doc.date', -1):
        proc_id = doc['doc_type']
        d_img = doc['default_img'] if 'default_img' in doc and doc[
            'default_img'] else None
        attachment = get_nf(proc_id, doc['_id'], 1)
        data = doc['doc']
        try:
            count = count_ware(doc['_id'])
        except:
            count = '1'
        full_doc = {
            "_id": doc['_id'],
            "id": doc['_id'],
            'count': count,
            "doc": data,
            "att": attachment,
            "img": get_curr_img(doc, attachment),
            'default_img': d_img,
            'proc_id': proc_id
        }
        clss.append(full_doc)
    pages = ''
    docs = get_full_docs(
        db.doc.find({
            'doc_type': 'des:ware',
            'doc.class': parent_id['_id']
        }).sort('doc.date', -1))
    # docs = get_full_docs(req).sort('doc.date', -1)
    filter = get_filters(parent_id['_id'])
    # filter = get_ware_cls(cls)
    parent_doc = get_full_doc(parent_id['_id'])
    # seo = db.doc.find_one({'doc.alias':'class_seo'}, {'doc.title':1, 'doc.tags':1, 'doc.body':1, 'doc.footer':1, 'doc.add_title':1 })
    seo = db.doc.find_one({'_id': parent_id['_id']}, {
        'doc.description': 1,
        'doc.tags': 1,
        'doc.footer': 1
    })
    # seo = seo if 'doc' in seo else ''
    return templ(
        'list_class', request,
        dict(cls_docs=clss,
             cls=cls,
             docs=docs,
             proc_id='des:ware',
             pages=pages,
             path=get_navigate(parent_id['_id']),
             parent_doc=parent_doc,
             filter=filter,
             seo=seo))
Exemplo n.º 7
0
def sort_body(request, proc_id, meta_table, docs_table):
	"""
	проодит по всем документам, если документ переводной то переводит
	И в зависимости от типа документа рисует соотвествующее значение в ячейке
	:param proc_id:
	:param meta_table:
	:param docs_table:
	:return:
	"""
	from libs.files.files import get_nf
	out_docs = []
	for res in docs_table: #проходим по всем документам
		doc = res['doc']
		for field in meta_table:
			if field['id'] in doc and 'is_translate' in field and field['is_translate']:
				lang = cur_lang(request)
				doc[field['id']] = ct(request, doc[field['id']], lang )
		doc_id = res['_id']; sorted_doc = []; parent = '_'; child= []
		if 'parent' in res and res['parent']: parent = res['parent']
		if 'child' in res and res['child']: child = res['child']
		for key in meta_table:
			if key['id'] in doc:
				select_id = doc[key['id']]
				if 'type' in key and key['type'] == 'checkbox':
					edit_value = doc[key['id']]
					icon = 'fa-check' if doc[key['id']] == 'true' else 'fa-close'
					color = 'green' if doc[key['id']] == 'true' else 'red'
					formatted = "<i style='color:"+color+"; font-size:16px' class='fa "+icon+"'></i>"
				elif 'type' in key and key['type'] == 'passw':
					edit_value = '*****'; formatted = '*****'
				elif 'type' in key and key['type'] == 'html':
					edit_value = ''; formatted = doc[key['id']][:100]
				elif 'type' in key and key['type'] == 'rich_edit':
					edit_value = ''
					formatted = cgi.escape(doc[key['id']][:100], True)
				elif 'type' in key and key['type'] == 'select':
					sel = request.db.doc.find_one({'_id':select_id})
					if sel:
						edit_value = doc[key['id']]
						formatted = cgi.escape(get_doc_title(request, sel, '[%s]' % edit_value))
						edit_value = cgi.escape(edit_value, True)
					else:
						edit_value = ''; formatted = '-'
				else:
					edit_value = html.escape(str(doc[key['id']]), True)
					formatted = html.escape(str(doc[key['id']]))
			else:
				edit_value = ''; formatted = ''
			sorted_doc.append({"id":key['id'], "edit_value":edit_value, "formatted":formatted})

		out_docs.append({"id":doc_id, "doc":sorted_doc, "parent":parent, "child":child, "imgs": get_nf(request, proc_id, doc_id, 2)})
	return out_docs