Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions weasyl/controllers/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@


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
offset = define.get_int(request.params.get('o', None))
pc = request.params.get('pc', '')
c = request.params.get('c', '')
commishclass = pc if pc else c
commishclass = commishclass.lower()
q = request.params.get('q', '')
min_value = request.params.get('min', '')
max_value = request.params.get('max', '')
currency = request.params.get('currency', '')

results = commishinfo.select_commissionable(request.userid,
form.q,
commishclass,
commishinfo.parse_currency(form.min),
commishinfo.parse_currency(form.max),
form.currency,
offset,
limit * 2,)
results = commishinfo.select_commissionable(userid=request.userid,
q=q,
commishclass=commishclass,
min_price=commishinfo.parse_currency(min_value),
max_price=commishinfo.parse_currency(max_value),
currency=currency,
offset=offset,
limit=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
form = {'pc': pc, 'c': c, 'q': q, 'min': min_value, 'max': max_value, 'currency': currency}
return Response(define.webpage(request.userid, "etc/marketplace.html",
[results, form, commishinfo.CURRENCY_CHARMAP, commishinfo.PRESET_COMMISSION_CLASSES,
prev_index, next_index]))
26 changes: 13 additions & 13 deletions weasyl/templates/etc/marketplace.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ <h3>Marketplace Search</h3>
<form id="marketplace-search" method="GET" class="form">
<label for="commission-class-preset">Type of Commission</label>
<select class="input last-input" name="pc" id="commission-class-preset">
<option value="" $:{selected(form.pc == "" and not form.c)}>Any</option>
<option value="" $:{selected(form['pc'] == "" and not form['c'])}>Any</option>
$for group_name, group_options in presets:
<optgroup label="${group_name}">
$for c in group_options:
<option value="${c}" $:{selected(form.pc == c)}>${c}</option>
<option value="${c}" $:{selected(form['pc'] == c)}>${c}</option>
</optgroup>
<option value="" $:{selected(form.pc == "" and form.c)} data-select-other="">Other</option>
<option value="" $:{selected(form['pc'] == "" and form['c'])} data-select-other="">Other</option>
</select>
<input name="c" type="text" class="input data-select-other" value="${form.c}" data-select="commission-class-preset" title="Other commission type" placeholder="Other commission type">
<input name="c" type="text" class="input data-select-other" value="${form['c']}" data-select="commission-class-preset" title="Other commission type" placeholder="Other commission type">

<label for="commission-type-tags">Content</label>
<input id="commission-type-tags" name="q" title="Commission Content"
type="text" class="input" value="${form.q}">
type="text" class="input" value="${form['q']}">

<div class="form-2up clear">
<div class="form-2up-1">
<label for="commission-min-price">Min. Price</label>
<input id="commission-min-price" name="min" type="number" step="any" min="0" class="input" value="${form.min}">
<input id="commission-min-price" name="min" type="number" step="any" min="0" class="input" value="${form['min']}">
</div>

<div class="form-2up-2">
<label for="commission-max-price">Max. Price</label>
<input id="commission-max-price" name="max" type="number" step="any" min="0" class="input" value="${form.max}">
<input id="commission-max-price" name="max" type="number" step="any" min="0" class="input" value="${form['max']}">
</div>
</div>

<label for="commish-currency">Display Currency</label>
<select class="input last-input" name="currency" id="commish-currency">
$for char, info in currencies.iteritems():
<option value="${char}" $:{selected(form.currency == char)}>${info.name}</option>
<option value="${char}" $:{selected(form['currency'] == char)}>${info.name}</option>
</select>

<button class="button">Search</button>
Expand Down Expand Up @@ -74,20 +74,20 @@ <h3>Artist Results</h3>
$if artist['pricemax'] and artist['pricemax'] != artist['pricemin']:
$# display high end of price range in artist's currency
<span>to ${SYMBOL(artist['pricesettings'])} ${PRICE(artist['pricemax'])}</span>
$if artist['pricesettings'] != form.currency and artist['localmin']:
$if artist['pricesettings'] != form['currency'] and artist['localmin']:
$if artist['localmax'] and artist['localmax'] != artist['localmin']:
$# display converted prices (range)
(<span>Approx. ${SYMBOL(form.currency)} ${PRICE(artist['localmin'])}</span>
<span>to ${SYMBOL(form.currency)} ${PRICE(artist['localmax'])}</span>)
(<span>Approx. ${SYMBOL(form['currency'])} ${PRICE(artist['localmin'])}</span>
<span>to ${SYMBOL(form['currency'])} ${PRICE(artist['localmax'])}</span>)
$else:
$# display converted price (single)
(<span>Approx. ${SYMBOL(form.currency)} ${PRICE(artist['localmin'])}</span>)
(<span>Approx. ${SYMBOL(form['currency'])} ${PRICE(artist['localmin'])}</span>)
$else:
Price not declared
</div>
$# matching commission classes
<div class="artist-classes">
<strong>${"Matched" if form.pc or form.c else "Types Available"}: ${artist['class']}</strong>
<strong>${"Matched" if form['pc'] or form['c'] else "Types Available"}: ${artist['class']}</strong>
</div>
$# commission description
<div class="formatted-content marketplace-desc-preview">
Expand Down