From 470f8e265dfb368848dc8891c4a95f5b3b261236 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Sun, 5 Apr 2009 19:18:07 +0000 Subject: [PATCH] physical item view: check and display item-status git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@277 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/TODO | 3 +++ conifer/custom/lib_integration.py | 2 ++ conifer/static/main.css | 6 ++++-- conifer/syrup/models.py | 15 ++++++++++++++- conifer/syrup/views.py | 17 +++++++++++++++-- conifer/templates/item_add_cat_search.xhtml | 5 ++++- conifer/templates/item_metadata.xhtml | 22 +++++++++++++++------- 7 files changed, 57 insertions(+), 13 deletions(-) diff --git a/conifer/TODO b/conifer/TODO index 1a4a07e..d61f768 100644 --- a/conifer/TODO +++ b/conifer/TODO @@ -2,6 +2,9 @@ CRITICAL: IMPORTANT: +* finish the physical-item received workflow. + * how to model 'received' in the database? + * does 'move to new heading' show up in the right places? Should be like 'edit'. * a short-number for physical items. Sort of a barcode, but intended diff --git a/conifer/custom/lib_integration.py b/conifer/custom/lib_integration.py index 4c155c7..3b0c218 100644 --- a/conifer/custom/lib_integration.py +++ b/conifer/custom/lib_integration.py @@ -41,10 +41,12 @@ from conifer.libsystems.z3950 import yaz_search from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary +@caching('itemstatus', timeout=300) @SIP def patron_info(conn, barcode): return conn.patron_info(barcode) +@caching('itemstatus', timeout=300) @SIP def item_status(conn, barcode): return conn.item_info(barcode) diff --git a/conifer/static/main.css b/conifer/static/main.css index 32f787c..1ac2339 100644 --- a/conifer/static/main.css +++ b/conifer/static/main.css @@ -54,7 +54,7 @@ tbody td, tbody th { vertical-align: top; } /* heading sizes and colours. */ h1 { font-size: 150%; } -h2 { font-size: 135%; } +h2 { font-size: 125%; } h3 { font-size: 120%; } h1 { color: navy; } @@ -226,7 +226,8 @@ p.todo, div.todo { background-color: #fdd; padding: 6; margin: 12; border-left: { float: right; font-size: 95%; margin: 8 0; clear: both; text-align: right; } -.breadcrumbs { margin: 8 8 8 0; } +.breadcrumbs { margin: 8 8 8 0; width: 800; + text-indent: -24; padding-left: 24; } .errorlist { float: right; } .errorlist li { color: red; font-size: 90%; } @@ -273,3 +274,4 @@ li.sort_item:hover { background-color: #eee; } ul.heading_tree li { list-style: none; } ul.heading_tree { margin: 0; padding-left: 0; } ul.heading_tree ul { margin: 0; padding-left: 25; } + diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index ade38fa..03eb491 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -7,6 +7,7 @@ from genshi import Markup from django.utils.translation import ugettext as _ from conifer.custom import course_codes # fixme, not sure if conifer.custom is a good parent. from conifer.custom import course_sections # fixme, not sure if conifer.custom is a good parent. +from conifer.custom import lib_integration import re import random @@ -461,7 +462,19 @@ class Item(m.Model): else: return self.course.course_url() - + def describe_physical_item_status(self): + """Return a (bool,str) tuple: whether the item is available, + and a friendly description of the physical item's status""" + if self.item_type != 'PHYS': + return False, _('(Not a physical item)') + + #fixme: just having barcode in item-metadata doesn't mean 'in Reserves' + bc = self.barcode() + if not bc: + return False, _('On order') + else: + status = lib_integration.item_status(bc) + return status['available'], _(status['status']) metadata_attributes = { 'dc:contributor': _('Contributor'), diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 0b77000..133311c 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -710,8 +710,20 @@ def item_add(request, course_id, item_id): @instructors_only def item_add_cat_search(request, course_id, item_id): + # this chunk stolen from item_add(). Refactor. + parent_item_id = item_id + if parent_item_id=='0': + parent_item = None + course = get_object_or_404(models.Course, pk=course_id) + else: + parent_item = get_object_or_404(models.Item, pk=parent_item_id, course__id=course_id) + assert parent_item.item_type == 'HEADING', _('You can only add items to headings!') + course = parent_item.course + #---------- + if request.method != 'POST': - return g.render('item_add_cat_search.xhtml', results=[], query='') + return g.render('item_add_cat_search.xhtml', results=[], query='', + course=course, parent_item=parent_item) # POST handler query = request.POST.get('query','').strip() @@ -721,7 +733,8 @@ def item_add_cat_search(request, course_id, item_id): assert query, 'must provide a query.' results = lib_integration.cat_search(query) return g.render('item_add_cat_search.xhtml', - results=results, query=query) + results=results, query=query, + course=course, parent_item=parent_item) else: # User has selected an item; add it to course site. #fixme, this block copied from item_add. refactor. diff --git a/conifer/templates/item_add_cat_search.xhtml b/conifer/templates/item_add_cat_search.xhtml index ed6f011..b41f1fe 100644 --- a/conifer/templates/item_add_cat_search.xhtml +++ b/conifer/templates/item_add_cat_search.xhtml @@ -9,6 +9,7 @@ dc_keys = ['dc:title', 'dc:creator', 'dc:publisher', 'dc:date'] xmlns:py="http://genshi.edgewall.org/"> + ${title} -

${title}

+ ${course_banner(course)} + ${nested_title(parent_item)} +

${title}

diff --git a/conifer/templates/item_metadata.xhtml b/conifer/templates/item_metadata.xhtml index 9ce7f75..7121660 100644 --- a/conifer/templates/item_metadata.xhtml +++ b/conifer/templates/item_metadata.xhtml @@ -13,6 +13,10 @@ is_editor = course.can_edit(request.user) ${title} + ${course_banner(course)} @@ -28,18 +32,22 @@ is_editor = course.can_edit(request.user) + + +
- - - - - - + + + + + +
- +

Additional metadata

-- 2.11.0