[open-ils-commits] r878 - in servres/trunk: . conifer conifer/custom conifer/syrup conifer/syrup/views conifer/templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon May 3 21:48:24 EDT 2010
Author: gfawcett
Date: 2010-05-03 21:48:22 -0400 (Mon, 03 May 2010)
New Revision: 878
Added:
servres/trunk/conifer/BRANCH-TODO.org
servres/trunk/conifer/custom/README
servres/trunk/conifer/integration/
Removed:
servres/trunk/conifer/custom/course_codes.py
servres/trunk/conifer/custom/course_sections.py
Modified:
servres/trunk/.gitignore
servres/trunk/conifer/settings.py
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/views/courses.py
servres/trunk/conifer/templates/edit_course_permissions.xhtml
Log:
Merged 2010-02-campus-integration-reorg branch changes r797:849 into trunk
Modified: servres/trunk/.gitignore
===================================================================
--- servres/trunk/.gitignore 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/.gitignore 2010-05-04 01:48:22 UTC (rev 878)
@@ -8,3 +8,4 @@
xsip
TAGS
private_local_settings.py
+/conifer/.dired
Copied: servres/trunk/conifer/BRANCH-TODO.org (from rev 877, servres/branches/2010-02-campus-integration-reorg/conifer/BRANCH-TODO.org)
===================================================================
--- servres/trunk/conifer/BRANCH-TODO.org (rev 0)
+++ servres/trunk/conifer/BRANCH-TODO.org 2010-05-04 01:48:22 UTC (rev 878)
@@ -0,0 +1,38 @@
+* Tasks for the =2010-02-campus-integration-reorg= branch
+
+ The goal of this branch is to reorganize and document the two major
+ integration points in Syrup: the library systems and the campus
+ information systems. Both of these integrations existed prior to the
+ branch, but were undocumented and messy.
+
+** The Evergreen-or-not question.
+ - Prepare to sync with the =eg-schema-experiment= branch
+ - "in evergreen database" vs. "other database with OpenSRF calls"
+
+** Enumerate the ways that campus integration is currently used.
+ Put this in the campus-integration documentation.
+
+** A Library Integration module which is readable and documented
+ - integrate via local_settings.py
+ - Prepare to sync with the =eg-schema-experiment= branch
+
+** How much of the integration data belongs in the database?
+ Should the Django ADMINS list be pulled from the db? What about
+ Z39.50 targets? What are the deciding principles when figuring out
+ where to store config data?
+
+** Campus integration for departments.
+ - how to address the faculty/campus/dept/etc. hierarchy?
+ - list of departments
+ - look up department based on course-code
+ - instructors in a given department
+
+** question: Campus integration for terms?
+ Even just a "feed of terms you might not yet know about?"
+
+** question: when looking up membership info, always update membership table?
+ Should just asking an external campus system, 'What sections is
+ John in?' automatically add membership records for John, for
+ course-sites related to those sections? Should it also (only during
+ the active period of a term) drop John from current sections that
+ he's no longer part of?
Copied: servres/trunk/conifer/custom/README (from rev 877, servres/branches/2010-02-campus-integration-reorg/conifer/custom/README)
===================================================================
--- servres/trunk/conifer/custom/README (rev 0)
+++ servres/trunk/conifer/custom/README 2010-05-04 01:48:22 UTC (rev 878)
@@ -0,0 +1,4 @@
+This directory is going away.
+
+Default integrations are being moved to 'conifer.integration'. The
+active integration modules are to be specified in local_settings.
Deleted: servres/trunk/conifer/custom/course_codes.py
===================================================================
--- servres/trunk/conifer/custom/course_codes.py 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/conifer/custom/course_codes.py 2010-05-04 01:48:22 UTC (rev 878)
@@ -1,140 +0,0 @@
-# Validation and lookup of course codes.
-
-# This modules specifies an "course-code interface" and a null
-# implementation of that interface. If your local system has rules for
-# valid course codes, and a mechanism for looking up details of these
-# codes, you can implement the interface according to your local
-# rules.
-
-
-# ------------------------------------------------------------
-# Overview and definitions
-
-# A course code identifies a specific course offering. Course codes
-# map 1:N onto formal course titles: by looking up a code, we can
-# derive a formal title (in theory, though it may not be possible for
-# external reasons).
-
-# A course code is insufficient to specify a class list: we need a
-# course section for that. A section ties a course code and term to an
-# instructor(s) and a list of students.
-
-# Course codes may have cross-listings, i.e., other codes which refer
-# to the same course, but which appear under a different department
-# for various academic purposes. In our system, we make no attempt to
-# subordinate cross-listings to a "primary" course code.
-
-
-#------------------------------------------------------------
-# Notes on the interface
-#
-# The `course_code_is_valid` function will be used ONLY if
-# course_code_list() returns None (it is a null implementation). If a
-# course-list is available, the system will use a membership test for
-# course-code validity.
-#
-# `course_code_lookup_title` will be used ONLY if `course_code_list`
-# is implemented.
-#
-#
-# "types" of the interface members
-#
-# course_code_is_valid (string) --> boolean.
-# course_code_example : a string constant.
-# course_code_list () --> list of strings
-# course_code_lookup_title (string) --> string, or None.
-# course_code_cross_listings (string) --> list of strings
-#
-# For each member, you MUST provide either a valid implementation, or
-# set the member to None. See the null implementation below.
-
-#------------------------------------------------------------
-# Implementations
-
-# ------------------------------------------------------------
-# Here is a 'null implementation' of the course-code interface. No
-# validation is done, nor are lookups.
-#
-# course_code_is_valid = None # anything is OK;
-# course_code_example = None # no examples;
-# course_code_lookup_title = None # no codes to list;
-# course_code_cross_listings = None # no cross lists.
-
-# ------------------------------------------------------------
-# This one specifies a valid course-code format using a regular
-# expression, and offers some example codes, but does not have a
-# lookup system.
-#
-# import re
-#
-# def course_code_is_valid(course_code):
-# pattern = re.compile(r'^\d{2}-\d{3}$')
-# return bool(pattern.match(course_code))
-#
-# course_code_example = '55-203; 99-105'
-#
-# course_code_list = None
-# course_code_lookup_title = None
-# course_code_cross_listings = None
-
-
-
-# ------------------------------------------------------------
-# This is a complete implementation, based on a hard-coded list of
-# course codes and titles, and two cross-listed course codes.
-#
-# _codes = [('ENG100', 'Introduction to English'),
-# ('ART108', 'English: An Introduction'),
-# ('FRE238', 'Modern French Literature'),
-# ('WEB203', 'Advanced Web Design'),]
-#
-# _crosslists = set(['ENG100', 'ART108'])
-#
-# course_code_is_valid = None
-# course_code_example = 'ENG100; FRE238'
-#
-# def course_code_list():
-# return [a for (a,b) in _codes]
-#
-# def course_code_lookup_title(course_code):
-# return dict(_codes).get(course_code)
-#
-# def course_code_cross_listings(course_code):
-# if course_code in _crosslists:
-# return list(_crosslists - set([course_code]))
-
-
-# ------------------------------------------------------------
-# Provide your own implementation below.
-
-
-#_codes = [('ENG100', 'Introduction to English'),
-# ('ART108', 'English: An Introduction'),
-# ('FRE238', 'Modern French Literature'),
-# ('LIB201', 'Intro to Library Science'),
-# ('WEB203', 'Advanced Web Design'),]
-
-_codes = [('ART99-100', 'Art History'),
- ('BIOL55-350', 'Molecular Cell Biology'),
- ('CRIM48-567', 'Current Issues in Criminology'),
- ('ENGL26-280', 'Contemporary Literary Theory'),
- ('ENGL26-420', 'Word and Image: The Contemporary Graphic Novel'),
- ('SOCWK47-457', 'Advanced Social Work Research'),]
-
-_crosslists = set(['ENGL26-280', 'ENGL26-420'])
-
-
-course_code_is_valid = None
-
-course_code_example = 'BIOL55-350; SOCWK47-457'
-
-def course_code_list():
- return [a for (a,b) in _codes]
-
-def course_code_lookup_title(course_code):
- return dict(_codes).get(course_code)
-
-def course_code_cross_listings(course_code):
- if course_code in _crosslists:
- return list(_crosslists - set([course_code]))
-
Deleted: servres/trunk/conifer/custom/course_sections.py
===================================================================
--- servres/trunk/conifer/custom/course_sections.py 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/conifer/custom/course_sections.py 2010-05-04 01:48:22 UTC (rev 878)
@@ -1,153 +0,0 @@
-# Operations on course-section identifiers
-
-# A course section is an instance of a course offered in a term.
-
-# A section is specified by a 'section-id', a 3-tuple (course-code,
-# term, section-code), where section-code is usually a short
-# identifier (e.g., "1" representing "section 1 in this term"). Note
-# that multiple sections of the same course are possible in a given
-# term.
-
-# Within the reserves system, a course-site can be associated with
-# zero or more sections, granting access to students in those
-# sections. We need two representations of a section-id.
-
-# The section_tuple_delimiter must be a string which will never appear
-# in a course-code, term, or section-code in your database. It may be
-# a nonprintable character (e.g. NUL or CR). It is used to delimit
-# parts of the tuples in a course's database record.
-
-#------------------------------------------------------------
-# Notes on the interface
-#
-# 'sections_taught_by(username)' returns a set of sections for which
-# username is an instructor. It is acceptable if 'sections_taught_by'
-# only returns current and future sections: historical information is
-# not required by the reserves system.
-#
-# It is expected that the reserves system will be able to resolve any
-# usernames into user records. If there are students on a section-list
-# which do not resolve into user accounts, they will probably be
-# ignored and will not get access to their course sites. So if you're
-# updating your users and sections in a batch-run, you might want to
-# update your users first.
-#
-#------------------------------------------------------------
-# Implementations
-
-# The reserves system will work with a null-implementation of the
-# course-section interface, but tasks related to course-sections will
-# be unavailable.
-
-# ------------------------------------------------------------
-# The null implementation:
-#
-# sections_tuple_delimiter = None
-# sections_taught_by = None
-# students_in = None
-# instructors_in = None
-# sections_for_code_and_term = None
-
-# ------------------------------------------------------------
-#
-# The minimal non-null implementation. At the least you must provide
-# sections_tuple_delimiter and students_in. Lookups for instructors
-# may be skipped. Note that sections passed to students_in are
-# (term, course-code, section-code) tuples (string, string, string).
-#
-# sections_tuple_delimiter = '|'
-#
-# def students_in(*sections):
-# ...
-# return set_of_usernames
-#
-# instructors_in = None
-# sections_for_code_and_term = None
-
-# ------------------------------------------------------------
-# A complete implementation, with a static database.
-
-# sections_tuple_delimiter = '|'
-#
-# _db = [
-# ('fred', ('2009W', 'ENG203', '1'), 'jim joe jack ellen ed'),
-# ('fred', ('2009W', 'ENG327', '1'), 'ed paul bill'),
-# ('bill', ('2009S', 'BIO323', '1'), 'alan june jack'),
-# ('bill', ('2009S', 'BIO323', '2'), 'emmet'),
-# ]
-#
-# def sections_taught_by(username):
-# return set([s[1] for s in _db if s[0] == username])
-#
-# def students_in(*sections):
-# def inner():
-# for instr, sec, studs in _db:
-# if sec in sections:
-# for s in studs.split(' '):
-# yield s
-# return set(inner())
-#
-# def instructors_in(*sections):
-# def inner():
-# for instr, sec, studs in _db:
-# if sec in sections:
-# yield instr
-# return set(inner())
-#
-# def sections_for_code_and_term(code, term):
-# return [(t, c, s) for (instr, (t, c, s), ss) in _db \
-# if c == code and t == term]
-#
-
-
-# ------------------------------------------------------------
-# Provide your own implementation below.
-
-sections_tuple_delimiter = None
-sections_taught_by = None
-students_in = None
-instructors_in = None
-sections_for_code_and_term = None
-
-
-
-# ------------------------------------------------------------
-# a temporary implementation, while I write up the UI.
-
-sections_tuple_delimiter = '|'
-
-# For any of the students to actually appear in a course site, they
-# must also exist as Django users (or be in an authentication backend
-# that supports 'maybe_initialize_user'; see auth_evergreen.py).
-
-_db = [
- #(instructor, (term, code, sec-code), 'student1 student2 ... studentN'),
- ('fred', ('2009W', 'ENG203', '1'), 'jim joe jack ellen ed'),
- ('fred', ('2009W', 'ENG327', '1'), 'ed paul bill'),
- ('art', ('2009W', 'LIB201', '1'), 'graham bill ed'),
- ('graham', ('2009S', 'ART108', '1'), 'alan june jack'),
- ('graham', ('2009S', 'ART108', '2'), 'emmet'),
- ('graham', ('2009S', 'ART108', '3'), 'freda hugo bill'),
-]
-
-def sections_taught_by(username):
- return set([s[1] for s in _db if s[0] == username])
-
-def students_in(*sections):
- def inner():
- for instr, sec, studs in _db:
- if sec in sections:
- for s in studs.split(' '):
- yield s
- return set(inner())
-
-def instructors_in(*sections):
- def inner():
- for instr, sec, studs in _db:
- if sec in sections:
- yield instr
- return set(inner())
-
-def sections_for_code_and_term(code, term):
- return [(t, c, s) for (instr, (t, c, s), ss) in _db \
- if c == code and t == term]
Copied: servres/trunk/conifer/integration (from rev 877, servres/branches/2010-02-campus-integration-reorg/conifer/integration)
Modified: servres/trunk/conifer/settings.py
===================================================================
--- servres/trunk/conifer/settings.py 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/conifer/settings.py 2010-05-04 01:48:22 UTC (rev 878)
@@ -8,12 +8,8 @@
DEBUG = False
-ADMINS = (
- # ('Your Name', 'your_email at domain.com'),
-)
+ADMINS = []
-MANAGERS = ADMINS
-
DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
@@ -97,6 +93,8 @@
'django.contrib.auth.backends.ModelBackend'
]
+CAMPUS_INTEGRATION_MODULE = 'conifer.integration.default'
+
#---------------------------------------------------------------------------
# local_settings.py
@@ -115,9 +113,22 @@
# Further settings that depend upon local_settings.
TEMPLATE_DEBUG = DEBUG
+MANAGERS = ADMINS
+#----------
+
if EVERGREEN_AUTHENTICATION:
- AUTHENTICATION_BACKENDS.extend(
- ['conifer.custom.auth_evergreen.EvergreenAuthBackend',
- ])
+ AUTHENTICATION_BACKENDS.append(
+ 'conifer.custom.auth_evergreen.EvergreenAuthBackend')
+#----------
+
+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)
+
+#----------
+
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/conifer/syrup/models.py 2010-05-04 01:48:22 UTC (rev 878)
@@ -5,14 +5,17 @@
from datetime import datetime
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
from django.utils import simplejson
from conifer.middleware import genshi_locals
+# campus and library integration
+from django.conf import settings
+campus = settings.CAMPUS_INTEGRATION
+from conifer.custom import lib_integration # fixme, not sure if conifer.custom is a good parent.
+
+
def highlight(text, phrase,
highlighter='<strong class="highlight">\\1</strong>'):
''' This may be a lame way to do this, but will want to highlight matches somehow
@@ -262,7 +265,7 @@
break
def sections(self):
- delim = course_sections.sections_tuple_delimiter
+ delim = campus.sections_tuple_delimiter
if not delim:
return []
else:
@@ -302,16 +305,16 @@
def _merge_sections(secs):
- delim = course_sections.sections_tuple_delimiter
+ delim = campus.sections_tuple_delimiter
return delim.join(delim.join(sec) for sec in secs)
def section_decode_safe(secstring):
if not secstring:
return None
- return tuple(secstring.decode('base64').split(course_sections.sections_tuple_delimiter))
+ return tuple(secstring.decode('base64').split(campus.sections_tuple_delimiter))
def section_encode_safe(section):
- return course_sections.sections_tuple_delimiter.join(section).encode('base64').strip()
+ return campus.sections_tuple_delimiter.join(section).encode('base64').strip()
class Member(m.Model):
class Meta:
Modified: servres/trunk/conifer/syrup/views/courses.py
===================================================================
--- servres/trunk/conifer/syrup/views/courses.py 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/conifer/syrup/views/courses.py 2010-05-04 01:48:22 UTC (rev 878)
@@ -12,7 +12,7 @@
def clean_code(self):
v = (self.cleaned_data.get('code') or '').strip()
- is_valid_func = models.course_codes.course_code_is_valid
+ is_valid_func = models.campus.course_code_is_valid
if (not is_valid_func) or is_valid_func(v):
return v
else:
@@ -20,12 +20,12 @@
# if we have course-code lookup, hack lookup support into the new-course form.
-COURSE_CODE_LIST = bool(models.course_codes.course_code_list)
-COURSE_CODE_LOOKUP_TITLE = bool(models.course_codes.course_code_lookup_title)
+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.course_codes.course_code_list()
+ course_list = models.campus.course_code_list()
choices = [(a,a) for a in course_list]
choices.sort()
empty_label = u'---------'
@@ -52,7 +52,7 @@
if is_add:
instance = models.Course()
current_access_level = not is_add and instance.access or None
- example = models.course_codes.course_code_example
+ example = models.campus.course_code_example
if request.method != 'POST':
form = NewCourseForm(instance=instance)
return g.render('edit_course.xhtml', **locals())
@@ -81,7 +81,7 @@
# no access-control needed to protect title lookup.
def add_new_course_ajax_title(request):
course_code = request.GET['course_code']
- title = models.course_codes.course_code_lookup_title(course_code)
+ title = models.campus.course_code_lookup_title(course_code)
return HttpResponse(simplejson.dumps({'title':title}))
@instructors_only
@@ -96,7 +96,7 @@
(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'))]
- if models.course_sections.sections_tuple_delimiter is None:
+ if models.campus.sections_tuple_delimiter is None:
# no course-sections support? Then STUDT cannot be an option.
del choices[1]
choose_access = django.forms.Select(choices=choices)
@@ -172,7 +172,7 @@
for name in POST \
if name.startswith('remove_section_')]
course.drop_sections(*to_remove)
- student_names = models.course_sections.students_in(*course.sections())
+ student_names = models.campus.students_in(*course.sections())
for name in student_names:
user = models.maybe_initialize_user(name)
if user:
Modified: servres/trunk/conifer/templates/edit_course_permissions.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_course_permissions.xhtml 2010-04-30 21:22:32 UTC (rev 877)
+++ servres/trunk/conifer/templates/edit_course_permissions.xhtml 2010-05-04 01:48:22 UTC (rev 878)
@@ -66,8 +66,8 @@
<h3>Course section numbers</h3>
<?python
current_sections = course.sections()
- my_sections = [s for s in models.course_sections.sections_taught_by(user.username) if not s in current_sections]
- ct_sections = [s for s in models.course_sections.sections_for_code_and_term(course.code, course.term.code) \
+ my_sections = [s for s in models.campus.sections_taught_by(user.username) if not s in current_sections]
+ ct_sections = [s for s in models.campus.sections_for_code_and_term(course.code, course.term.code) \
if not s in current_sections]
encode = lambda t,c,s: models.section_encode_safe((t,c,s))
?>
More information about the open-ils-commits
mailing list