def sub(request, user, link, subject): #TODO do not expect the system to send all letters. admin = get_admin(True) mail = admin['doc']['mail'] if 'mail' in admin['doc'] else '' if not mail: return {"result": "ok"} db = request.db from libs.contents.contents import get_doc doc = get_doc(user) db.queue.mail.save({ "_id": uuid4().hex, "subject": subject, "to": admin['doc']['mail'], 'body': link }) users = doc['friends'] if doc and 'friends' in doc else {} for res in users: friend = get_doc(res) if friend['doc']['sub'] == 'true': db.queue.mail.save({ "_id": uuid4().hex, "subject": subject, "to": friend['doc']['mail'], 'body': link }) return {"result": "ok"}
def sub(request, user, link, subject): #TODO do not expect the system to send all letters. admin = get_admin(True) mail = admin['doc']['mail'] if 'mail' in admin['doc'] else '' if not mail: return {"result":"ok"} db = request.db from libs.contents.contents import get_doc doc = get_doc(user) db.queue.mail.save({"_id": uuid4().hex, "subject":subject, "to":admin['doc']['mail'], 'body': link}) users = doc['friends'] if doc and 'friends' in doc else {} for res in users: friend = get_doc(res) if friend['doc']['sub'] == 'true' : db.queue.mail.save({"_id": uuid4().hex, "subject":subject, "to":friend['doc']['mail'], 'body': link}) return {"result":"ok"}
def add_basket(ware, quantity): """получает id товара и количество берет подробности о нем и заносит в сесии""" s = session() doc = get_doc(ware) basket_check() if not ware in s['basket']: s['basket'][ware] = { 'title': ct(doc['doc']['title']), 'price': doc['doc']['price'], "amount": 0, 'quantity': 0, 'descr': doc['doc']['descr'], "_id": doc['_id'] } s['basket'][ware]['quantity'] += quantity # die(doc['doc']['count_opt']) if 'count_opt' in doc['doc'] and doc['doc']['count_opt'] and int( quantity) >= int(ct(doc['doc']['count_opt'])): amount = float(quantity * doc['doc']['price_opt']) s['basket'][ware]['amount'] = amount s.save() # die( s['basket'][ware]['amount'] ) else: amount = float(quantity * doc['doc']['price']) s['basket'][ware]['amount'] += amount s.save()
def subscribe_post(request): user = get_doc(request, get_current_user(request, True)) if not 'subscription' in user: user['subscription'] = {} channel = get_post('channel') status = get_post('status') user['subscription'][channel] = status request.db.doc.save(user) return {"result":"ok"}
def add_order(request, data): db = request.db proc_id = 'des:order'; table_id = 'ware' sub_data = basket_show() doc_id = create_empty_row_(proc_id, data) doc = get_doc(doc_id) for i in sub_data: new_id = doc['seq_id'] doc["seq_id"] = new_id+1 new_id = str(new_id) doc['tables'][table_id][new_id] = sub_data[i] db.doc.save(doc) return {"result":"ok"}
def add_order(request, data): db = request.db proc_id = 'des:order' table_id = 'ware' sub_data = basket_show() doc_id = create_empty_row_(proc_id, data) doc = get_doc(doc_id) for i in sub_data: new_id = doc['seq_id'] doc["seq_id"] = new_id + 1 new_id = str(new_id) doc['tables'][table_id][new_id] = sub_data[i] db.doc.save(doc) return {"result": "ok"}
def add_basket(ware, quantity): """получает id товара и количество берет подробности о нем и заносит в сесии""" s = session() doc = get_doc(ware) basket_check() if not ware in s['basket']: s['basket'][ware] = {'title': ct(doc['doc']['title']), 'price': doc['doc']['price'], "amount": 0, 'quantity': 0, 'descr': doc['doc']['descr'], "_id":doc['_id'] } s['basket'][ware]['quantity'] += quantity # die(doc['doc']['count_opt']) if 'count_opt' in doc['doc'] and doc['doc']['count_opt'] and int(quantity) >= int(ct(doc['doc']['count_opt'])): amount = float(quantity * doc['doc']['price_opt']) s['basket'][ware]['amount'] = amount s.save() # die( s['basket'][ware]['amount'] ) else: amount = float(quantity * doc['doc']['price']) s['basket'][ware]['amount'] += amount s.save()
def get_admin(request, full=False): from libs.contents.contents import get_doc name = 'user:'******'admin') or get_domain() ) if full: return get_doc(request, name) return name
def get_admin(request, full=False): from libs.contents.contents import get_doc name = 'user:'******'admin') or get_domain()) if full: return get_doc(request, name) return name
def subscribe(request): user = get_doc(request, get_current_user(request, True)) if not 'subscription' in user: user['subscription'] = {} return templ('subscribe', request, dict(subscribe = user['subscription']))