idlist = make_obj_string(ids)
return self._item_status(item.bib_id, item.barcode, bclist, idlist)
+ #in general, you want to cache this for a few minutes
+ #but bump this value to 0 or something low for debugging
CACHE_TIME = 300
@memoize(timeout=CACHE_TIME)
due_callno = callno
due_callsuffix = callsuffix
- if (avail == 0 or bringfw) and copy.circs and len(copy.circs) > 0:
+ if copy.circs and len(copy.circs) > 0:
if len(dueinfo) == 0 or bringfw:
earlydue = duetime
due,due_callno,due_callprefix,due_callsuffix = get_dueinfo(callprefix,callsuffix,callno,
- earliestdue,attachtest,voltest,sort_callno,bringfw,dueinfo)
+ earlydue,attachtest,voltest,sort_callno,bringfw,dueinfo)
- if duetime < earlydue and not bringfw:
+ if (earlydue is None or duetime < earlydue) and not bringfw:
earlydue = duetime
due = time.strftime(self.DUE_FORMAT,earliestdue)
#pull together status information
def sort_out_status(barcode, sort_vol, counts, version, sort_lib, sort_desk, sort_avail,
- sort_callno, sort_dueinfo, sort_circmod, sort_allcalls, sort_alldues, prefix, suffix,
+ sort_callno, sort_dueid, sort_dueinfo, sort_circmod, sort_allcalls, sort_alldues, prefix, suffix,
bcs,ids):
vol = sort_vol
circmod = sort_circmod
allcalls = sort_allcalls
alldues = sort_alldues
+ dueid = sort_dueid
try:
if loc in self.RESERVES_DESK_NAME:
# we want to identify the copy that will be returned first if
# all are checked out
for copy in copies:
+ #this condition should only ever be true when a multipart is in full display
+ #in that case, the most available copy should be selected
+ if len(ids) == 1:
+ if ids[0][0] == '':
+ avail = 1
if copy.part_label:
#print "callno", callno
#print "sort_callno", sort_callno
+
callno = sort_callno + " " + copy.part_label
if copy.part_sort in copy_parts and len(copy_parts) > 0:
- allcalls[len(allcalls) - 1] = [callno,READY,copy.syrup_id,copy.part_label]
+ #leave alone if locked - otherwise mark as ready
+ if allcalls[len(allcalls) - 1][1] != LOCKED:
+ allcalls[len(allcalls) - 1] = [callno,READY,copy.syrup_id,copy.part_label]
+
else:
allcalls.append([callno,READY,copy.syrup_id,copy.part_label])
copy_parts.append(copy.part_sort)
#remove offset info, %z is flakey for some reason
rawdate = rawdate[:-5]
duetime = time.strptime(rawdate, self.TIME_FORMAT)
+ elif len(allcalls) == 0:
+ dueid = [copy.syrup_id,LOCKED]
#get due information - lots of extra pieces needed for embedded parts
dueinfo,callprefix,callno,callsuffix = deal_with_dues(duetime,avail,bringfw,copy,
alldisplay = callno + ' (Available)'
if copy.circs and isinstance(copy.circs, list):
- if len(allcalls) > 0 and (earliestdue is None or duetime < earliestdue):
+ if (earliestdue is None or duetime < earliestdue):
+ #print "SETTING earliest to", duetime
earliestdue = duetime
- alldisplay = '%s (DUE: %s)' % (callno,time.strftime(self.DUE_FORMAT,duetime))
+ dueinfo = time.strftime(self.DUE_FORMAT,earliestdue)
+ #will want the link to be to the earliest item if not multipart
+ if len(allcalls) == 0 and dueid[1] != LOCKED:
+ dueid = [copy.syrup_id,DUE]
+
+ alldisplay = '%s (DUE: %s)' % (callno,time.strftime(self.DUE_FORMAT,earliestdue))
if len(allcalls) > 0:
if allcalls[len(allcalls) - 1][1] != LOCKED:
allcalls[len(allcalls) - 1] = [alldisplay,DUE,copy.syrup_id,copy.part_label]
- avail -= 1
- else:
+ if avail >= 1:
+ avail -= 1
+ elif avail >= 1:
avail -= 1
elif len(allcalls) > 0:
print "*** print_exc:"
traceback.print_exc()
- return (vol, lib, desk, avail, callno, dueinfo, circmod, allcalls, alldues)
+ return (vol, lib, desk, avail, callno, dueid, dueinfo, circmod, allcalls, alldues)
#get lists of barcodes and ids
bcs = make_obj_list(bclist)
assert self.RESERVES_DESK_NAME, 'No RESERVES_DESK_NAME specified!'
lib = desk = avail = vol = anystatus_here = 0
+ dueid = ['',READY]
dueinfo = ''
callno = ''
circmod = ''
prefix += ' '
if len(suffix) > 0:
suffix = ' ' + suffix
- vol, lib, desk, avail, callno, dueinfo, circmod, allcalls, alldues = sort_out_status(barcode, vol, counts,
- version, lib, desk, avail, callno, dueinfo, circmod, allcalls, alldues, prefix, suffix, bcs,ids)
+ vol, lib, desk, avail, callno, dueid, dueinfo, circmod, allcalls, alldues = sort_out_status(barcode, vol, counts,
+ version, lib, desk, avail, callno, dueid, dueinfo, circmod, allcalls, alldues, prefix, suffix, bcs,ids)
else:
for org, callno, loc, stats in counts:
- vol, lib, desk, avail, callno, dueinfo, circmod, allcalls, alldues = sort_out_status(barcode, vol, counts,
- version, lib, desk, avail, callno, dueinfo, circmod, allcalls, alldues, bcs,ids)
+ vol, lib, desk, avail, callno, dueid, dueinfo, circmod, allcalls, alldues = sort_out_status(barcode, vol, counts,
+ version, lib, desk, avail, callno, dueid, dueinfo, circmod, allcalls, alldues, bcs,ids)
if len(allcalls) > 0:
cpname = 'volumes'
- return (cpname, lib, desk, avail, callno, dueinfo, circmod, allcalls, alldues)
+ return (cpname, lib, desk, avail, callno, dueid[0], dueinfo, circmod, allcalls, alldues)
stat = callhook('item_status', item, bcs, ids) if (item.item_type == 'PHYS') else None
valid = stat is not None
?>
- <span py:if="valid" py:with="(_cpname, _lib, _desk, _avail, _callno, _dueinfo, _circmod, _allcalls, _alldues) = stat">
+ <span py:if="valid" py:with="(_cpname, _lib, _desk, _avail, _callno, _dueid, _dueinfo, _circmod, _allcalls, _alldues) = stat">
<div class="availability" py:if="item.item_type == 'PHYS'">
<a href="${item.item_url()}">
<div class="${_avail > 0 and 'available' or 'unavailable'}"
<span py:if="k==0" class="unavailable">${j}</span>
<span py:if="k > 0">Ask for: <span class="standout">${j}</span></span>
</div>
- <div py:if="_dueinfo">NEXT DUE: ${_dueinfo}</div>
+ <div py:if="_avail == 0 and _dueinfo">NEXT DUE: ${_dueinfo}</div>
</div>
<div py:if="not valid" class="unavailable">
<div class="availability avail_nonphys" py:if="item.item_type != 'PHYS'">
</div>
<div class="mainline ${item.item_type=='HEADING' and 'headingmainline' or ''}">
- <span py:if="item.item_type=='ELEC' and not downloads_allowed">
- <img title="Sorry, this document is not available to you."
- src="${ROOT}/static/tango/lock.png"/></span>
- <a py:if="len(_allcalls) == 0 or (edit and user.is_staff)" href="${item.item_url()}" class="mainlink"
- py:strip="item.item_type=='ELEC' and not downloads_allowed">${item}</a>
- <span py:if="item.suppress_item">[additional copy - not displayed]</span>
- <span py:if="len(_allcalls) > 0 and not (edit and user.is_staff)">
<?python
site_url = item.item_url()
#get base of url without item number
elif len(m) > 0 or len(display_calls) == 0:
display_calls.append([site_url + str(l),item,part])
?>
+ <span py:if="item.item_type=='ELEC' and not downloads_allowed">
+ <img title="Sorry, this document is not available to you."
+ src="${ROOT}/static/tango/lock.png"/></span>
+ <span py:if="len(_allcalls) == 0 or (edit and user.is_staff)">
+ <a py:if="not _dueid" href="${item.item_url()}" class="mainlink"
+ py:strip="item.item_type=='ELEC' and not downloads_allowed">${item}</a>
+ <a py:if="_dueid" href="${site_url}${_dueid}" class="mainlink"
+ py:strip="item.item_type=='ELEC' and not downloads_allowed">${item}</a>
+ </span>
+ <span py:if="item.suppress_item">[additional copy - not displayed]</span>
+ <span py:if="len(_allcalls) > 0 and not (edit and user.is_staff)">
<div py:for="i,j,k in display_calls">
<a href="${i}" class="mainlink">${j}${k}</a>
</div>