Ejemplo n.º 1
0
def search_(request):
    form = request.web_input(q="",
                             min="",
                             max="",
                             currency="",
                             pc="",
                             c="",
                             o="")
    limit = 30
    offset = define.get_int(form.o)
    commishclass = form.pc if form.pc else form.c
    commishclass = commishclass.lower()

    results = commishinfo.select_commissionable(
        request.userid,
        form.q,
        commishclass,
        commishinfo.parse_currency(form.min),
        commishinfo.parse_currency(form.max),
        form.currency,
        offset,
        limit * 2,
    )
    rcount = len(results)
    results = results[0:limit]
    media.populate_with_user_media(results)
    prev_index = None if offset == 0 else offset - limit if offset - limit > 0 else 0
    next_index = offset + limit if rcount - limit > 0 else None
    return Response(
        define.webpage(request.userid, "etc/marketplace.html", [
            results, form, commishinfo.CURRENCY_CHARMAP,
            commishinfo.PRESET_COMMISSION_CLASSES, prev_index, next_index
        ]))
Ejemplo n.º 2
0
def control_createcommishprice_(request):
    form = request.web_input(title="", classid="", min_amount="", max_amount="", currency="", settings="")
    form.currency = form.currency.replace("$", "")

    price = orm.CommishPrice()
    price.title = form.title.strip()
    price.classid = define.get_int(form.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,
                             settings=form.settings)
    raise HTTPSeeOther(location="/control/editcommissionsettings")
Ejemplo n.º 3
0
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")
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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