[open-ils-commits] r253 - in servres/trunk/conifer: libsystems/sip syrup templates/phys (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Apr 3 19:30:33 EDT 2009
Author: gfawcett
Date: 2009-04-03 19:30:33 -0400 (Fri, 03 Apr 2009)
New Revision: 253
Modified:
servres/trunk/conifer/libsystems/sip/sipclient.py
servres/trunk/conifer/libsystems/sip/sipconstants.py
servres/trunk/conifer/syrup/views.py
servres/trunk/conifer/templates/phys/checkout.xhtml
Log:
on SIP checkout, display outcome prettily (with drill-down to SIP fields if desired)
Modified: servres/trunk/conifer/libsystems/sip/sipclient.py
===================================================================
--- servres/trunk/conifer/libsystems/sip/sipclient.py 2009-04-03 02:45:30 UTC (rev 252)
+++ servres/trunk/conifer/libsystems/sip/sipclient.py 2009-04-03 23:30:33 UTC (rev 253)
@@ -196,7 +196,7 @@
add(fld.name, good)
varposn.remove(fld)
else:
- raise 'FieldNotProcessed', (segment, lookup_constant(segment[:2]))
+ raise 'FieldNotProcessed: %s, %s' % (segment, lookup_constant(segment[:2]))
# Let's make sure that any "required" fields were not missing.
notpresent = set(f for f in varposn if not isinstance(f, optfield))
@@ -238,7 +238,7 @@
LOGIN_RESP : message(
LOGIN_RESP,
- charfield('okay', width=1)),
+ charfield('ok', width=1)),
SC_STATUS : message(
SC_STATUS,
@@ -343,6 +343,23 @@
field('item', FID_ITEM_ID),
),
+ CHECKOUT_RESP: message(
+ CHECKOUT_RESP,
+ charfield('ok', width=1),
+ yn('is_renewal'),
+ yn('is_magnetic'),
+ yn('desensitize'),
+ fld_localtime,
+ field('inst', FID_INST_ID),
+ field('patron', FID_PATRON_ID),
+ field('item', FID_ITEM_ID),
+ field('due', FID_DUE_DATE),
+ field('title', FID_TITLE_ID),
+ optfield('media_type_code', FID_MEDIA_TYPE),
+ optfield('is_valid_patron', FID_VALID_PATRON),
+ ofld_print_line,
+ ofld_screen_msg),
+
CHECKIN: message(
CHECKIN,
yn('is_retry'),
@@ -354,6 +371,31 @@
ofld_TERMINAL_PWD,
),
+ CHECKIN_RESP: message(
+ CHECKIN_RESP,
+ charfield('ok', width=1),
+ yn('resensitize'),
+ yn('is_magnetic'),
+ yn('alert'),
+ fld_localtime,
+ fld_INST_ID,
+ optfield('patron', FID_PATRON_ID),
+ field('item', FID_ITEM_ID),
+ field('title', FID_TITLE_ID),
+ optfield('media_type_code', FID_MEDIA_TYPE),
+ optfield('perm_locn', FID_PERM_LOCN),
+ optfield('due', FID_DUE_DATE),
+ ofld_print_line,
+ ofld_screen_msg,
+ ),
+# yn('is_retry'),
+# fld_localtime,
+# fld_localtime,
+# field('item', FID_ITEM_ID),
+# field('location', FID_CURRENT_LOCN),
+# ofld_TERMINAL_PWD,
+# ),
+
ITEM_INFORMATION : message(
ITEM_INFORMATION,
fld_localtime,
@@ -427,7 +469,7 @@
def login(self, uid, pwd, locn):
msg = self.send(LOGIN, LOGIN_RESP,
dict(uid=uid, pwd=pwd, locn=locn))
- return msg.get('okay') == '1'
+ return msg.get('ok') == '1'
def status(self):
return self.send(SC_STATUS, ACS_STATUS)
@@ -439,40 +481,28 @@
return msg
def checkout(self, patron, item, inst=''):
- msg = self.send(CHECKOUT, RAW, # fixme
+ msg = self.send(CHECKOUT, CHECKOUT_RESP,
{'patron':patron,
'inst': inst,
'item':item})
+ msg['media_type'] = MEDIA_TYPE_TABLE.get(msg.get('media_type_code'))
+ msg['success'] = msg.get('ok') == '1'
return msg
def checkin(self, item, institution='', location=''):
- msg = self.send(CHECKIN, RAW, # fixme
+ msg = self.send(CHECKIN, CHECKIN_RESP,
{'inst': institution,
'location':location,
'is_retry':False,
'item':item})
+ msg['success'] = msg.get('ok') == '1'
return msg
def item_info(self, barcode):
msg = self.send(ITEM_INFORMATION, ITEM_INFO_RESP,
{'item':barcode})
- decode_status = {
- '01': 'Other',
- '02': 'On order',
- '03': 'Available',
- '04': 'Charged',
- '05': 'Charged; not to be recalled until',
- '06': 'In process',
- '07': 'Recalled',
- '08': 'Waiting on hold shelf',
- '09': 'Waiting to be re-shelved',
- '10': 'In transit between library locations',
- '11': 'Claimed returned',
- '12': 'Lost',
- '13': 'Missing ',
- }
msg['available'] = msg['circstat'] == '03'
- msg['status'] = decode_status[msg['circstat']]
+ msg['status'] = ITEM_STATUS_TABLE[msg['circstat']]
return msg
@@ -533,10 +563,3 @@
'inst':'UWOLS'}))
-
-#checked out a book!
-#"{'raw': '121NNY20090402 220912AOconifer|AA21862000380830|AB31862017120995|AJNo great mischief|AH2009-07-31 00:00:00|CK001|\\r'}"
-
-#checked it back in:
-#"{'raw': '101YNN20090402 222519AO|AB31862017120995|AQLeddy Library|AJNo great mischief|AA21862000380830|CK001|\\r'}"
-
Modified: servres/trunk/conifer/libsystems/sip/sipconstants.py
===================================================================
--- servres/trunk/conifer/libsystems/sip/sipconstants.py 2009-04-03 02:45:30 UTC (rev 252)
+++ servres/trunk/conifer/libsystems/sip/sipconstants.py 2009-04-03 23:30:33 UTC (rev 253)
@@ -166,3 +166,37 @@
for k, v in constants:
if v == x:
return k
+
+
+#------------------------------------------------------------
+# Other lookups
+
+MEDIA_TYPE_TABLE = {
+ '000': 'Other',
+ '001': 'Book',
+ '002': 'Magazine',
+ '003': 'Bound journal',
+ '004': 'Audio tape',
+ '005': 'Video tape',
+ '006': 'CD/CDROM',
+ '007': 'Diskette',
+ '008': 'Book with diskette',
+ '009': 'Book with CD',
+ '010': 'Book with audio tape',
+ }
+
+ITEM_STATUS_TABLE = {
+ '01': 'Other',
+ '02': 'On order',
+ '03': 'Available',
+ '04': 'Charged',
+ '05': 'Charged; not to be recalled until',
+ '06': 'In process',
+ '07': 'Recalled',
+ '08': 'Waiting on hold shelf',
+ '09': 'Waiting to be re-shelved',
+ '10': 'In transit between library locations',
+ '11': 'Claimed returned',
+ '12': 'Lost',
+ '13': 'Missing',
+ }
Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py 2009-04-03 02:45:30 UTC (rev 252)
+++ servres/trunk/conifer/syrup/views.py 2009-04-03 23:30:33 UTC (rev 253)
@@ -1251,7 +1251,7 @@
return g.render('phys/checkout.xhtml', step=3,
patron=patron, item=item,
patron_descrip=post('patron_descrip'),
- checkout_result=msg['raw'],
+ checkout_result=msg,
item_descrip=item_descrip)
elif post('step') == '3':
# continue after checkout. Go to 'checkout another item'.
Modified: servres/trunk/conifer/templates/phys/checkout.xhtml
===================================================================
--- servres/trunk/conifer/templates/phys/checkout.xhtml 2009-04-03 02:45:30 UTC (rev 252)
+++ servres/trunk/conifer/templates/phys/checkout.xhtml 2009-04-03 23:30:33 UTC (rev 253)
@@ -12,6 +12,10 @@
<script>
$(function() { $('form:last input:visible:first').focus(); });
</script>
+ <style>
+ .success { background-color: #dfd; }
+ .failure { background-color: #fdd; }
+ </style>
</head>
<body>
<h1>${title}</h1>
@@ -22,7 +26,7 @@
<tr py:choose="defined('patron')">
<th>Patron Barcode</th>
<td py:when="False">
- <input type="text" id="patron" name="patron" style="width: 400;" value="${os.environ['ART']}"/>
+ <input type="text" id="patron" name="patron" style="width: 400;" value=""/>
</td>
<td py:when="True">
${patron}: ${Markup(patron_descrip)}
@@ -40,9 +44,19 @@
<input type="hidden" name="item" value="${item}"/>
</td>
</tr>
- <tr py:if="step==3">
+ <tr py:if="step==3" py:with="successful=checkout_result['success']">
<th/>
- <td><b>${checkout_result}</b></td>
+ <?python keys = checkout_result.keys(); keys.sort() ?>
+ <td class="${successful and 'success' or 'failure'}">
+ <p py:if="successful">The checkout was successful. Due Date: ${checkout_result['due']}</p>
+ <p py:if="not successful">The checkout failed.</p>
+ <p style="font-size: 85%;">
+ <a id="sdtog" href="javascript:$('#sip_details').toggle();$('#stog').hide();void(0);">Show details</a>
+ </p>
+ <table id="sip_details" style="font-size: 85%; display: none;"><tr py:for="k in keys">
+ <th>${k}</th><td>${checkout_result[k]}</td>
+ </tr></table>
+ </td>
</tr>
<tr>
<th/>
More information about the open-ils-commits
mailing list