def control_createcommishprice_(request): form = request.web_input(title="", classid="", min_amount="", max_amount="", currency="", settings="") price = orm.CommishPrice() price.title = form.title.strip() price.classid = define.get_int(form.classid) price.amount_min = commishinfo.convert_currency(form.min_amount) price.amount_max = commishinfo.convert_currency(form.max_amount) commishinfo.create_price(request.userid, price, currency=form.currency, settings=form.settings) raise HTTPSeeOther(location="/control/editcommissionprices")
def control_editcommishprice_(request): form = request.web_input(priceid="", title="", min_amount="", max_amount="", edit_settings="", currency="", settings="") price = orm.CommishPrice() price.title = form.title.strip() price.priceid = define.get_int(form.priceid) price.amount_min = commishinfo.convert_currency(form.min_amount) price.amount_max = commishinfo.convert_currency(form.max_amount) edit_prices = bool(price.amount_min or price.amount_max) commishinfo.edit_price(request.userid, price, currency=form.currency, settings=form.settings, edit_prices=edit_prices, edit_settings=form.edit_settings) raise HTTPSeeOther(location="/control/editcommissionprices")
def control_createcommishclass_(request): form = request.web_input(title="", titlepreset="", price_title="", min_amount="", max_amount="", currency="") title = form.title or form.titlepreset form.currency = form.currency.replace("$", "") classid = commishinfo.create_commission_class(request.userid, title.strip()) # Try to create a base price for it. If we fail, try to clean up the class. try: price = orm.CommishPrice() price.title = form.price_title.strip() price.classid = classid price.amount_min = commishinfo.parse_currency(form.min_amount) price.amount_max = commishinfo.parse_currency(form.max_amount) commishinfo.create_price(request.userid, price, currency=form.currency) except WeasylError as we: commishinfo.remove_class(request.userid, classid) raise we raise HTTPSeeOther(location="/control/editcommissionsettings")
def POST(self): form = web.input(title="", classid="", min_amount="", max_amount="", currency="", settings="") price = orm.CommishPrice() price.title = form.title.strip() price.classid = define.get_int(form.classid) price.amount_min = commishinfo.convert_currency(form.min_amount) price.amount_max = commishinfo.convert_currency(form.max_amount) commishinfo.create_price(self.user_id, price, currency=form.currency, settings=form.settings) raise web.seeother("/control/editcommissionprices")
def create_commish_searchable_user(username, commish_status='o', commishclass='badge', minprice="10.00", maxprice="15.00", currency='', submittime=arrow.get(1)): user = db_utils.create_user(username=username) profile.edit_profile_settings( userid=user, set_commission=profile.get_exchange_setting(profile.EXCHANGE_TYPE_COMMISSION, commish_status) ) commishinfo.create_commission_class(user, commishclass) classid = commishinfo.select_list(user)["class"][0]["classid"] assert classid price = orm.CommishPrice() price.title = "test price" price.classid = classid price.amount_min = commishinfo.parse_currency(minprice) price.amount_max = commishinfo.parse_currency(maxprice) commishinfo.create_price(user, price, currency) db_utils.create_submission(user, unixtime=submittime) return user