From b500c5073012a3a3e0fd02bfcdd0bb61a8122858 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Fri, 3 Apr 2009 23:30:33 +0000 Subject: [PATCH] on SIP checkout, display outcome prettily (with drill-down to SIP fields if desired) git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@253 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/libsystems/sip/sipclient.py | 79 ++++++++++++++++++++++------------ conifer/libsystems/sip/sipconstants.py | 34 +++++++++++++++ conifer/syrup/views.py | 2 +- conifer/templates/phys/checkout.xhtml | 20 +++++++-- 4 files changed, 103 insertions(+), 32 deletions(-) diff --git a/conifer/libsystems/sip/sipclient.py b/conifer/libsystems/sip/sipclient.py index a7cf93e..7b192e9 100644 --- a/conifer/libsystems/sip/sipclient.py +++ b/conifer/libsystems/sip/sipclient.py @@ -196,7 +196,7 @@ def decode_msg(msg, bytes): 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 @@ MESSAGES = { LOGIN_RESP : message( LOGIN_RESP, - charfield('okay', width=1)), + charfield('ok', width=1)), SC_STATUS : message( SC_STATUS, @@ -343,6 +343,23 @@ MESSAGES = { 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 @@ MESSAGES = { 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 @@ class SipClient(object): 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 @@ class SipClient(object): 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 @@ if __name__ == '__main__': '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'}" - diff --git a/conifer/libsystems/sip/sipconstants.py b/conifer/libsystems/sip/sipconstants.py index db46694..8e23488 100644 --- a/conifer/libsystems/sip/sipconstants.py +++ b/conifer/libsystems/sip/sipconstants.py @@ -166,3 +166,37 @@ def lookup_constant(x): 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', + } diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 3102082..a471a32 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -1251,7 +1251,7 @@ def phys_checkout(request): 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'. diff --git a/conifer/templates/phys/checkout.xhtml b/conifer/templates/phys/checkout.xhtml index d73805f..3f82874 100644 --- a/conifer/templates/phys/checkout.xhtml +++ b/conifer/templates/phys/checkout.xhtml @@ -12,6 +12,10 @@ title = _('Patron Checkout of Item') +

${title}

@@ -22,7 +26,7 @@ title = _('Patron Checkout of Item') Patron Barcode - + ${patron}: ${Markup(patron_descrip)} @@ -40,9 +44,19 @@ title = _('Patron Checkout of Item') - + - ${checkout_result} + + +

The checkout was successful. Due Date: ${checkout_result['due']}

+

The checkout failed.

+

+ Show details +

+ + + + -- 2.11.0