From 4b9ab78a82ded932086589968d2e862b785100c5 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Thu, 15 Jul 2010 00:55:56 +0000 Subject: [PATCH] moved marcxml to conifer.libsystems; removed refs to old campus integration module; cleanup. I've left some of the campus refs, in code that I know is getting an overhaul soon. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@922 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/integration/uwindsor.py | 2 +- conifer/libsystems/{z3950 => }/marcxml.py | 0 conifer/libsystems/z3950/pyz3950_search.py | 2 +- conifer/libsystems/z3950/yaz_search.py | 2 +- conifer/local_settings.py.example | 21 ++++++----- conifer/settings.py | 11 ------ conifer/syrup/models.py | 21 +++++------ conifer/syrup/urls.py | 1 - conifer/syrup/views/_common.py | 5 +-- conifer/syrup/views/admin.py | 1 - conifer/syrup/views/genshi_namespace.py | 45 +++++++----------------- conifer/syrup/views/items.py | 8 ++--- conifer/syrup/views/search.py | 5 --- conifer/syrup/views/sites.py | 26 ++------------ conifer/templates/auth/login.xhtml | 5 +-- conifer/templates/generic/index.xhtml | 5 +++ conifer/templates/item/item_add_cat_search.xhtml | 4 +-- conifer/templates/paginate.xhtml | 2 +- conifer/templates/phys/circlist_for_term.xhtml | 2 +- 19 files changed, 55 insertions(+), 113 deletions(-) rename conifer/libsystems/{z3950 => }/marcxml.py (100%) diff --git a/conifer/integration/uwindsor.py b/conifer/integration/uwindsor.py index 651485d..bcc137c 100644 --- a/conifer/integration/uwindsor.py +++ b/conifer/integration/uwindsor.py @@ -1,7 +1,7 @@ from datetime import date from django.conf import settings from conifer.libsystems.evergreen.support import initialize, E1 -from conifer.libsystems.z3950 import marcxml as M +from conifer.libsystems import marcxml as M from conifer.libsystems.evergreen import item_status as I from conifer.libsystems.z3950 import pyz3950_search as PZ from xml.etree import ElementTree as ET diff --git a/conifer/libsystems/z3950/marcxml.py b/conifer/libsystems/marcxml.py similarity index 100% rename from conifer/libsystems/z3950/marcxml.py rename to conifer/libsystems/marcxml.py diff --git a/conifer/libsystems/z3950/pyz3950_search.py b/conifer/libsystems/z3950/pyz3950_search.py index e8b1909..d77a4f9 100644 --- a/conifer/libsystems/z3950/pyz3950_search.py +++ b/conifer/libsystems/z3950/pyz3950_search.py @@ -7,7 +7,7 @@ import warnings import re import sys -from marcxml import marcxml_to_dictionary +from ..marcxml import marcxml_to_dictionary from xml.etree import ElementTree as ET try: diff --git a/conifer/libsystems/z3950/yaz_search.py b/conifer/libsystems/z3950/yaz_search.py index 3eb1f74..dbff493 100644 --- a/conifer/libsystems/z3950/yaz_search.py +++ b/conifer/libsystems/z3950/yaz_search.py @@ -8,7 +8,7 @@ import warnings import re import pexpect import sys -from marcxml import marcxml_to_dictionary +from ..marcxml import marcxml_to_dictionary LOG = None # for pexpect debugging, try LOG = sys.stderr YAZ_CLIENT = 'yaz-client' diff --git a/conifer/local_settings.py.example b/conifer/local_settings.py.example index 659612b..adbe698 100644 --- a/conifer/local_settings.py.example +++ b/conifer/local_settings.py.example @@ -3,6 +3,8 @@ import os from here import HERE +DEBUG = False + #---------------------------------------------------------------------- # You may need to set the PYTHON_EGG_CACHE directory, depending on how # you installed Syrup. @@ -19,7 +21,6 @@ DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. #---------------------------------------------------------------------- -DEBUG = False ADMINS = ( # ('Your Name', 'your_email@domain.com'), @@ -31,12 +32,8 @@ SECRET_KEY = 'replace-with-your-own-super-random-key-@vv(tuvt2+yu2r-$dxs$s7=iqjz #---------------------------------------------------------------------- -EVERGREEN_AUTHENTICATION = False - -#---------------------------------------------------------------------- -#Campus integration - -CAMPUS_INTEGRATION_MODULE = 'conifer.integration.default' +EVERGREEN_AUTHENTICATION = False # Evergreen ILS authentication +LINKTOOL_AUTHENTICATION = False # Sakai LMS Linktool authentication #---------------------------------------------------------------------- # Stuff that probably belongs in a config table in the database, with @@ -44,5 +41,11 @@ CAMPUS_INTEGRATION_MODULE = 'conifer.integration.default' EVERGREEN_GATEWAY_SERVER = 'www.concat.ca' Z3950_CONFIG = ('zed.concat.ca', 210, 'OWA') #OWA,OSUL,CONIFER -SIP_HOST = ('localhost', 8080) -SIP_CREDENTIALS = ('sipclient', 'c0n1fi3', 'graham home workstation') + +#---------------------------------------------------------------------- +# INTEGRATION_MODULE: name of a module to import after the database +# models have been initialized. This can be used for defining 'hook' +# functions, and other late initializations. +# See the 'conifer.syrup.integration' module for more information. + +INTEGRATION_MODULE = 'name.of.our.integration.module' diff --git a/conifer/settings.py b/conifer/settings.py index 1f0c6c7..2494d06 100644 --- a/conifer/settings.py +++ b/conifer/settings.py @@ -94,8 +94,6 @@ AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend' ] -CAMPUS_INTEGRATION_MODULE = 'conifer.integration.default' - #--------------------------------------------------------------------------- # local_settings.py @@ -124,12 +122,3 @@ if EVERGREEN_AUTHENTICATION: #---------- -try: - exec 'import %s as CAMPUS_INTEGRATION' % CAMPUS_INTEGRATION_MODULE -except: - raise Exception('There is an error in your campus integration module (%s)! ' - 'Please investigate and repair.' % CAMPUS_INTEGRATION_MODULE, - sys.exc_value) - -#---------- - diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index a4abd6b..98b0529 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -1,22 +1,17 @@ -import re import random +import re -from django.db import models as m -from django.db.models import Q -from django.contrib.auth.models import User -from django.contrib.auth.models import AnonymousUser -from datetime import datetime -from genshi import Markup -from django.utils.translation import ugettext as _ -from django.utils import simplejson +from conifer.libsystems import marcxml as MX from conifer.plumbing.genshi_support import get_request - -# campus and library integration from conifer.plumbing.hooksystem import * +from datetime import datetime from django.conf import settings -campus = settings.CAMPUS_INTEGRATION -import conifer.libsystems.z3950.marcxml as MX +from django.contrib.auth.models import AnonymousUser, User +from django.db import models as m +from django.db.models import Q from django.utils import simplejson as json +from django.utils.translation import ugettext as _ +from genshi import Markup #---------------------------------------------------------------------- diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index f8d36a7..21687b3 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -10,7 +10,6 @@ urlpatterns = patterns('conifer.syrup.views', (r'^$', 'welcome'), (r'^site/$', 'my_sites'), (r'^site/new/$', 'add_new_site'), - (r'^site/new/ajax_title$', 'add_new_site_ajax_title'), (r'^site/invitation/$', 'site_invitation'), (r'^browse/$', 'browse'), (r'^browse/(?P.*)/$', 'browse'), diff --git a/conifer/syrup/views/_common.py b/conifer/syrup/views/_common.py index 43981d6..04c63d8 100644 --- a/conifer/syrup/views/_common.py +++ b/conifer/syrup/views/_common.py @@ -20,6 +20,7 @@ import sys import warnings import pdb +from conifer.integration.hooksystem import gethook, callhook, callhook_required from conifer.syrup import models from datetime import datetime from django.contrib.auth import authenticate, login, logout @@ -37,8 +38,8 @@ from django.utils import simplejson from django.utils.translation import ugettext as _ from _generics import * # TODO: should not import-star -from conifer.libsystems.z3950.marcxml import (marcxml_to_dictionary, - marcxml_dictionary_to_dc) +from conifer.libsystems.marcxml import (marcxml_to_dictionary, + marcxml_dictionary_to_dc) #----------------------------------------------------------------------------- diff --git a/conifer/syrup/views/admin.py b/conifer/syrup/views/admin.py index fa21299..490159c 100644 --- a/conifer/syrup/views/admin.py +++ b/conifer/syrup/views/admin.py @@ -1,6 +1,5 @@ from _common import * from django.utils.translation import ugettext as _ -from conifer.plumbing.hooksystem import * from datetime import date #----------------------------------------------------------------------------- diff --git a/conifer/syrup/views/genshi_namespace.py b/conifer/syrup/views/genshi_namespace.py index f9e2d5b..728cbd6 100644 --- a/conifer/syrup/views/genshi_namespace.py +++ b/conifer/syrup/views/genshi_namespace.py @@ -1,38 +1,17 @@ -# genshi_namespace +# genshi_namespace: toplevel definitions in this module will be +# available when rendering a Genshi template. In addition, the Genshi +# template will have access to: -# Toplevel definitions in this module will be available in when -# rendering a Genshi template. +# request: the current request object +# user: the current user +# ROOT: the SCRIPT_NAME of the root directory of this application. +# errors: either None, or a list of errors related to the current page. -from conifer.integration._hooksystem import gethook, callhook -import itertools -from itertools import cycle -from conifer.syrup import models import django.forms -from django.utils import translation - -_ = translation.ugettext - -# this probably ought to be a method on User, or another model class. -def instructor_url(instructor, suffix=''): - return '/instructor/%d/%s' % (instructor.id, suffix) - -# added to make department browse -def department_url(department, suffix=''): - return '/department/%d/%s' % (department.id, suffix) - - -def call_or_value(obj, dflt=None): - # This is used by the generics templates. - if callable(obj): - return obj() or dflt - else: - return obj or dflt +import itertools +from conifer.integration.hooksystem import gethook, callhook +from conifer.syrup import models +from django.utils import translation -def instructs(user, site): - try: - mbr = models.Member.objects.get(user=user, site=site) - return mbr.role in ('INSTR', 'PROXY') - except: - return False - +_ = translation.ugettext diff --git a/conifer/syrup/views/items.py b/conifer/syrup/views/items.py index 5c9d417..179a2e5 100644 --- a/conifer/syrup/views/items.py +++ b/conifer/syrup/views/items.py @@ -1,9 +1,7 @@ -from _common import * +from _common import * +from conifer.syrup import integration from django.utils.translation import ugettext as _ -from xml.etree import ElementTree as ET -from conifer.syrup import integration -from conifer.plumbing.hooksystem import * - +from xml.etree import ElementTree as ET @members_only def item_detail(request, site_id, item_id): diff --git a/conifer/syrup/views/search.py b/conifer/syrup/views/search.py index 79cc6ed..517a770 100644 --- a/conifer/syrup/views/search.py +++ b/conifer/syrup/views/search.py @@ -95,8 +95,6 @@ def _search(query_string, for_site=None, for_owner=None, user=None): site_filter = Q(site=for_site) if for_site else Q() _items = models.Item.objects.select_related() - print (term_filter & user_filter & - site_filter & owner_filter) items = _items.filter(term_filter & user_filter & site_filter & owner_filter) @@ -139,9 +137,6 @@ def search(request, in_site=None, for_owner=None): this instructor. ''' - print("in_site is %s" % in_site) - print("for_owner is %s" % for_owner) - query_string = request.GET.get('q', '').strip() if not query_string: # empty query? diff --git a/conifer/syrup/views/sites.py b/conifer/syrup/views/sites.py index b635f59..3485b2d 100644 --- a/conifer/syrup/views/sites.py +++ b/conifer/syrup/views/sites.py @@ -12,7 +12,7 @@ class NewSiteForm(ModelForm): def clean_code(self): v = (self.cleaned_data.get('code') or '').strip() - is_valid_func = models.campus.course_code_is_valid + is_valid_func = gethook('course_code_is_valid') if (not is_valid_func) or is_valid_func(v): return v else: @@ -26,22 +26,6 @@ class NewSiteForm(ModelForm): super(NewSiteForm, self).__init__(*args, **kwargs) -# if we have course-code lookup, hack lookup support into the new-course form. - -COURSE_CODE_LIST = bool(models.campus.course_code_list) -COURSE_CODE_LOOKUP_TITLE = bool(models.campus.course_code_lookup_title) - -# if COURSE_CODE_LIST: -# from django.forms import Select -# course_list = models.campus.course_code_list() -# choices = [(a,a) for a in course_list] -# choices.sort() -# empty_label = u'---------' -# choices.insert(0, ('', empty_label)) -# NewSiteForm.base_fields['code'].widget = Select( -# choices = choices) -# NewSiteForm.base_fields['code'].empty_label = empty_label - #-------------------- @login_required @@ -60,7 +44,6 @@ def _add_or_edit_site(request, instance=None): if is_add: instance = models.Site() current_access_level = not is_add and instance.access or None - example = models.campus.course_code_example if request.method != 'POST': form = NewSiteForm(instance=instance) return g.render('edit_site.xhtml', **locals()) @@ -82,12 +65,6 @@ def _add_or_edit_site(request, instance=None): else: return HttpResponseRedirect('../') # back to main view. -# no access-control needed to protect title lookup. -def add_new_site_ajax_title(request): - course_code = request.GET['course_code'] - title = models.campus.course_code_lookup_title(course_code) - return HttpResponse(simplejson.dumps({'title':title})) - @instructors_only def edit_site_permissions(request, site_id): site = get_object_or_404(models.Site, pk=site_id) @@ -100,6 +77,7 @@ def edit_site_permissions(request, site_id): (u'STUDT', _(u'Students in my course -- I will provide section numbers')), (u'INVIT', _(u'Students in my course -- I will share an Invitation Code with them')), (u'LOGIN', _(u'All Reserves patrons'))] + # TODO: fixme, campus module no longer exists. if models.campus.sections_tuple_delimiter is None: # no course-sections support? Then STUDT cannot be an option. del choices[1] diff --git a/conifer/templates/auth/login.xhtml b/conifer/templates/auth/login.xhtml index 2d723df..14fb03d 100644 --- a/conifer/templates/auth/login.xhtml +++ b/conifer/templates/auth/login.xhtml @@ -1,5 +1,5 @@ -

Please log in.

+

${title}

+

You must log in to access this resource.

${err}
diff --git a/conifer/templates/generic/index.xhtml b/conifer/templates/generic/index.xhtml index 819129a..9d04c17 100644 --- a/conifer/templates/generic/index.xhtml +++ b/conifer/templates/generic/index.xhtml @@ -1,6 +1,11 @@
- +
${pagehead()} diff --git a/conifer/templates/phys/circlist_for_term.xhtml b/conifer/templates/phys/circlist_for_term.xhtml index ffc64d7..4bfed5a 100644 --- a/conifer/templates/phys/circlist_for_term.xhtml +++ b/conifer/templates/phys/circlist_for_term.xhtml @@ -1,6 +1,6 @@