def accept(): import common if common.not_is_local(): raise HTTP(200, T('ERROR')) id = request.args(0) shop_add = id and db.shops_add[id] res = CAT() if not shop_add: res = SQLFORM.smartgrid(db.shops_add) return dict(res=res) res = SQLFORM(db.shops_add, shop_add) if res.accepts(request.vars, session): #response.flash = T('new record inserted') # берем ИД новой записи new_shop_id = res.vars.id shop = db(db.shops.name == res.vars.name).select().first() shop = shop or db(db.shops.url == res.vars.url).select().first() shop = shop or db(db.shops.email == res.vars.email).select().first() if shop: raise HTTP( 500, T('Запись с такими данными уже есть, обратитесь к администратору для решения вопроса.' )) pars = res.vars.copy() id_old = pars['id'] # удалим лишние поля! for k in ['id', 'CMS']: _ = pars.pop(k) addr1 = pars.pop('wallet_BTC') addr2 = pars.pop('wallet_LTC') print pars new_shop_id = db.shops.insert(**pars) # теперь добавим кошельки import db_common if addr1: _, xcurr, _ = db_common.get_currs_by_addr(db, addr1) db.shops_xwallets.insert(shop_id=new_shop_id, xcurr_id=xcurr.id, addr=addr1) if addr2: _, xcurr, _ = db_common.get_currs_by_addr(db, addr2) db.shops_xwallets.insert(shop_id=new_shop_id, xcurr_id=xcurr.id, addr=addr2) del db.shops_add[id_old] print 'accepted' response.flash = ' ACCEPTED!' # надо сбросить параметр - редиректом redirect(URL('accept')) return dict(res=res)
# coding: utf8 import common # запустим сразу защиту от внешних вызов #print request.function #if request.function not in ['list', 'download'] and common.not_is_local(): raise HTTP(200, T('ERROR')) if common.not_is_local(): raise HTTP(200, T('ERROR')) #import datetime #import json #import db_common #import db_client ############################################# def last(): so = db(((db.shop_orders.payed_soft > 0) | (db.shop_orders.payed_hard > 0) | (db.shop_orders.payed_true > 0)) & (db.shop_orders.price > 0)).select(orderby=~db.shop_orders.id, limitby=(0, 20)) tab = CAT() for r in so: sh = db.shops[r.shop_id] cr = db.currs[r.curr_id] tab += DIV(sh.url or sh.name, ' ', r.payed_soft + r.payed_hard + r.payed_true, cr.abbrev) return tab