Exemple #1
0
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})
Exemple #2
0
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) )
Exemple #3
0
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
        })
Exemple #4
0
def ware_page(request, doc_id):
    u = urlparse(request.url)
    url = u.scheme + '://' + u.hostname + u.path
    data_tree = []
    from libs.sites.sites import get_pagination, get_full_doc, get_full_docs
    db = request.db
    doc = get_full_doc(doc_id, img_ctr=4)

    req_attr = db.doc.find({'doc_type': 'des:ware_attr', 'owner': doc['_id']})
    ware_attr = get_full_docs(
        db.doc.find({
            'doc_type': 'des:ware_attr',
            'owner': doc['_id']
        }))

    proc_id = doc['proc_id']
    title = ct(doc['doc']['title']) if 'title' in doc['doc'] else ''
    cls = doc['doc']['class']
    req = db.doc.find({
        'doc_type': 'des:ware',
        '_id': {
            '$ne': doc['_id']
        },
        'doc.class': cls
    }).limit(6)
    similar = get_full_docs(req)
    url1 = url
    seo = db.doc.find_one({'doc.alias': 'ware_page_seo'}, {
        'doc.description': 1,
        'doc.tags': 1,
        'doc.body': 1,
        'doc.footer': 1,
        'doc.add_title': 1
    })
    # if seo:
    # 	seo = seo
    # else: seo = ''
    return templ(
        'ware_page', request,
        dict(doc=doc,
             url=url1,
             doc_id=doc_id,
             proc_id=proc_id,
             similar=similar,
             seo=seo,
             tree=data_tree,
             page_title=title,
             ware_attr=ware_attr))  #news_map=news_map, captcha=raw, hash=hash,
Exemple #5
0
def ware_page(request, doc_id):
	u = urlparse(request.url)
	url = u.scheme + '://' + u.hostname + u.path
	data_tree = []
	from libs.sites.sites import get_pagination, get_full_doc, get_full_docs
	db = request.db
	doc = get_full_doc(doc_id, img_ctr=4)

	req_attr = db.doc.find({'doc_type':'des:ware_attr', 'owner':doc['_id']})
	ware_attr = get_full_docs( db.doc.find({'doc_type':'des:ware_attr', 'owner':doc['_id']}) )


	proc_id = doc['proc_id']
	title = ct(doc['doc']['title']) if 'title' in doc['doc'] else ''
	cls = doc['doc']['class']
	req = db.doc.find( {'doc_type':'des:ware', '_id':{'$ne':doc['_id']}, 'doc.class':cls} ).limit(6)
	similar = get_full_docs( req )
	url1 = url
	seo = db.doc.find_one({'doc.alias':'ware_page_seo'}, {'doc.description':1, 'doc.tags':1, 'doc.body':1, 'doc.footer':1, 'doc.add_title':1})
	# if seo:
	# 	seo = seo
	# else: seo = ''
	return templ('ware_page', request, dict(doc = doc, url = url1, doc_id=doc_id, proc_id=proc_id, similar = similar, seo=seo,
		tree = data_tree, page_title=title, ware_attr=ware_attr)) #news_map=news_map, captcha=raw, hash=hash,
Exemple #6
0
def user(request, u):
	db = request.db
	uu = u
	u_id    = db.doc.find_one({'doc_type':'des:users', '_id':'user:'******'doc_type':'des:users', 'doc.nickname':uu})
	u_name  = db.doc.find_one({'doc_type':'des:users', 'doc.name.ru':uu})

	if u_id:      u = u_id
	elif u_alias: u = u_alias
	elif u_name:  u = u_name
	dv = get_full_doc( u['_id'] )

	req = db.doc.find({'doc_type':'des:obj', 'doc.user':u['_id']})
	docs = get_full_docs(req)

	friends = json.loads(json.dumps(u['friends'])) if 'friends' in u else []
	followers = json.loads(json.dumps(u['followers'])) if 'followers' in u else []

	js_friends = json.dumps(u['friends']) if 'friends' in u else []
	js_followers = json.dumps(u['followers']) if 'followers' in u else []


	return templ('user_page', request, dict( doc = dv, docs=docs, doc_id=u['_id'], user_name=ct( u['doc']['name'] ), proc_id='des:users',
	             friends=friends, followers=followers, js_friends=js_friends, js_followers=js_followers) )
Exemple #7
0
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))
Exemple #8
0
def add_email(request):
	user = get_full_doc( get_current_user(True) )
	return templ('add_email', request, dict(user=user))