@admin_only # fixme, is this the right permission?
def phys_checkout(request):
- return g.render('phys/checkout.xhtml')
+ if request.method != 'POST':
+ return g.render('phys/checkout.xhtml', step=1)
+ else:
+ post = lambda k: request.POST.get(k, '').strip()
+ patron, item = post('patron'), post('item')
+ if post('step') == '1':
+ # patron entered, need item
+ patron_descrip = 'Fred Example, Jr.' # fixme, lookup
+ return g.render('phys/checkout.xhtml', step=2,
+ patron=patron,
+ patron_descrip=patron_descrip)
+ elif post('step') == '2':
+ # patron + item. do SIP calls.
+ # log the checkout in a local table.
+ patron_descrip = 'Fred Example, Jr.' # fixme, lookup
+ item_descrip = 'War and Peace (Reader\'s Digest edition)'
+ return g.render('phys/checkout.xhtml', step=3,
+ patron=patron, item=item,
+ patron_descrip=patron_descrip,
+ item_descrip=item_descrip)
+ elif post('step') == '3':
+ # continue after checkout. Go to 'checkout another item'.
+ patron_descrip = 'Fred Example, Jr.' # fixme, lookup
+ return g.render('phys/checkout.xhtml', step=2,
+ patron=patron,
+ patron_descrip=patron_descrip)
+
<head>
<title>${title}</title>
<script>
- $(function() { $('#patron').focus(); });
+ $(function() { $('form:last input:visible:nth(0)').focus(); });
</script>
</head>
<body>
<h1>${title}</h1>
<form action="." method="POST">
- <table>
- <tr>
+ <input type="hidden" name="step" value="${step}"/>
+ <div>
+ <table class="metadata_table">
+ <tr py:choose="defined('patron')">
<th>Patron Barcode</th>
- <td><input type="text" id="patron" name="patron" style="width: 400;"/></td>
+ <td py:when="False">
+ <input type="text" id="patron" name="patron" style="width: 400;"/>
+ </td>
+ <td py:when="True">
+ ${patron}: ${patron_descrip}
+ <input type="hidden" name="patron" value="${patron}"/>
+ </td>
</tr>
- <tr>
+ <tr py:if="step>1" py:choose="defined('item')">
<th>Item Barcode</th>
- <td><input type="text" name="item" style="width: 400;"/></td>
+ <td py:when="False">
+ <input type="text" id="item" name="item" style="width: 400;"/>
+ </td>
+ <td py:when="True">
+ ${item}: ${item_descrip}
+ <input type="hidden" name="item" value="${item}"/>
+ </td>
+ </tr>
+ <tr py:if="step==3">
+ <th/>
+ <td><b>Success: Item Checked Out.</b></td>
</tr>
<tr>
<th/>
- <td><input type="submit" value="Request Checkout"/></td>
+ <td><input type="submit" value="Continue"/></td>
</tr>
</table>
-
+ </div>
+
</form>
</body>