From 524fa9351cb202ee8ed7856596f20c28db07daa1 Mon Sep 17 00:00:00 2001 From: Art Rhyno Date: Sun, 15 Jul 2012 18:34:01 -0400 Subject: [PATCH] fix few small bugs, add info for Django 1.4+ implementations --- conifer/integration/evergreen_site.py | 64 ++++++++++++++++++++--------------- conifer/local_settings.py.example | 10 ++++++ conifer/settings.py | 16 +++++++++ conifer/syrup/views/items.py | 11 +++++- 4 files changed, 72 insertions(+), 29 deletions(-) diff --git a/conifer/integration/evergreen_site.py b/conifer/integration/evergreen_site.py index 6d7e1e3..7cf4335 100644 --- a/conifer/integration/evergreen_site.py +++ b/conifer/integration/evergreen_site.py @@ -178,27 +178,27 @@ class EvergreenIntegration(object): circmod = sort_circmod alldues = sort_alldues try: - callprefix = '' - callsuffix = '' - if len(callno) == 0: - callno = callnum - - if prefix: - callno = prefix + callno - if suffix: - callno = callno + suffix - avail_here = stats.get(self.AVAILABLE, 0) - avail_here += stats.get(self.RESHELVING, 0) - anystatus_here = sum(stats.values()) - lib += anystatus_here - - # volume check - based on v.1, etc. in call number - voltest = re.search(r'\w*v\.\s?(\d+)', callnum) - - # attachment test - attachtest = re.search(self.IS_ATTACHMENT, callnum) - if loc in self.RESERVES_DESK_NAME: + callprefix = '' + callsuffix = '' + if len(callno) == 0: + callno = callnum + + if prefix: + callno = prefix + callno + if suffix: + callno = callno + suffix + avail_here = stats.get(self.AVAILABLE, 0) + avail_here += stats.get(self.RESHELVING, 0) + anystatus_here = sum(stats.values()) + lib += anystatus_here + + # volume check - based on v.1, etc. in call number + voltest = re.search(r'\w*v\.\s?(\d+)', callnum) + + # attachment test + attachtest = re.search(self.IS_ATTACHMENT, callnum) + desk += anystatus_here avail += avail_here dueinfo = '' @@ -216,7 +216,6 @@ class EvergreenIntegration(object): else: callno = prefix + callnum + suffix - # Another MassLNC variation, needs same refactoring as above if version >= 2.1: copyids = E1(OPENSRF_CN_CALL, bib_id, [prefix,callnum,suffix], org) else: @@ -355,16 +354,23 @@ class EvergreenIntegration(object): barcode = '' bibid = '' is_barcode = re.search('\d{14}', query) - if query.startswith(self.OPAC_URL): + results = [] # query is an Evergreen URL # snag the bibid at this point - params = dict([x.split("=") for x in query.split("&")]) - for key in params.keys(): - if key.find('?r') != -1: - bibid = params[key] + if "=" in query and "&" in query: + params = dict([x.split("=") for x in query.split("&")]) + for key in params.keys(): + if key.find('?r') != -1: + bibid = params[key] + results = M.marcxml_to_records(I.url_to_marcxml(query)) + else: + # likely template opac + url_nums = [int(s) for s in query.split('/') if s.isdigit()] + if len(url_nums) > 0: + bib_id = url_nums[len(url_nums) - 1] + results = M.marcxml_to_records(self.bib_id_to_marcxml(bib_id)) - results = M.marcxml_to_records(I.url_to_marcxml(query)) numhits = len(results) elif is_barcode: results = [] @@ -474,7 +480,9 @@ class EvergreenIntegration(object): codes and $u holds the URLs. """ # TODO: move this to local_settings - LIBCODE = 'OWA' # Leddy + LIBCODE = 'OWA' + if hasattr(settings, 'EVERGREEN_LIBCODE'): + LIBCODE = settings.EVERGREEN_OPAC_URL try: dct = M.marcxml_to_dictionary(marc_string) words = lambda string: re.findall(r'\S+', string) diff --git a/conifer/local_settings.py.example b/conifer/local_settings.py.example index 4a2ad04..eb25784 100644 --- a/conifer/local_settings.py.example +++ b/conifer/local_settings.py.example @@ -18,6 +18,15 @@ DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +# changes in Django 1.4+ to this syntax: +# DATABASES = { +# 'default': { +# 'ENGINE': 'django.db.backends.sqlite3', +# 'NAME': '/home/tesseract/src/syrup/git/Syrup/conifer/db/syrup' +# } +# } + + #---------------------------------------------------------------------- ADMINS = ( @@ -52,6 +61,7 @@ CAS_SERVER_URL = 'https://uwinid.uwindsor.ca/cas/' EVERGREEN_SERVER = 'www.concat.ca' EVERGREEN_VERSION = 2.1 +EVERGREEN_LIBCODE = 'OWA' # list of locations RESERVES_DESK_NAME = ['Leddy: Course Reserves - Main Bldng - 1st Flr - Reserve Counter at Circulation Desk', 'Leddy: Reserves 2'] diff --git a/conifer/settings.py b/conifer/settings.py index 6a49a4b..6089418 100644 --- a/conifer/settings.py +++ b/conifer/settings.py @@ -17,6 +17,8 @@ DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +# see local_settings.py.example for Django 1.4+ example + # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. @@ -52,6 +54,9 @@ MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". + +# use STATIC_URL for Django 1.4+ and comment out ADMIN_MEDIA_PREFIX +#STATIC_URL = '/syrup/djmedia/' ADMIN_MEDIA_PREFIX = '/syrup/djmedia/' # Make this unique, and don't share it with anybody. @@ -63,6 +68,13 @@ TEMPLATE_LOADERS = ( 'django.template.loaders.app_directories.load_template_source', ) +# for Django 1.4+, use this +#TEMPLATE_LOADERS = ( +# 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.filesystem.Loader', +#) + + MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', @@ -71,6 +83,8 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.locale.LocaleMiddleware', 'babeldjango.middleware.LocaleMiddleware', 'django.middleware.transaction.TransactionMiddleware', + # uncomment this for Django 1.4+ + # 'django.contrib.messages.middleware.MessageMiddleware', ) ROOT_URLCONF = 'conifer.urls' @@ -80,6 +94,8 @@ TEMPLATE_DIRS = [] INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', + # uncomment this for Django 1.4+ + # 'django.contrib.messages', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index 6fe90e7..7f8d863 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -271,9 +271,13 @@ def item_add_cat_search(request, site_id, item_id): return _access_denied(_('You are not an editor.')) if gethook('get_better_copy_of_marc'): + print "pick" pickitem_xml = callhook('get_better_copy_of_marc', raw_pickitem) + print "picked" raw_pickitem = unicode(ET.tostring(pickitem_xml)) + print "raw" pickitem = marcxml_to_dictionary(pickitem_xml) + print "dict" else: pickitem = marcxml_to_dictionary(raw_pickitem) dublin = marcxml_dictionary_to_dc(pickitem) @@ -388,6 +392,12 @@ def item_edit(request, site_id, item_id): del data['author2'] [setattr(item, k, v) for (k,v) in data.items()] + + suppress_option = request.POST.get('suppress_item') + # this is not always a problem but force just in case + if suppress_option is None: + item.suppress_item = False + if item.barcode and item.item_type == 'PHYS' and hasattr(settings, 'OPENSRF_STAFF_USERID'): # TODO: we need an explicit 'we do updates' flag update_option = request.POST.get('update_option') location_option = request.POST.get('location_option') @@ -395,7 +405,6 @@ def item_edit(request, site_id, item_id): prefix_option = request.POST.get('orig_prefix') callno_option = request.POST.get('orig_callno') suffix_option = request.POST.get('orig_suffix') - suppress_option = request.POST.get('suppress_item') update_status = False #only update the Catalogue -- 2.11.0