From 4b44316927a03ffe8ef1a1bee0c0606d15ec41c6 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Thu, 30 Dec 2010 16:28:04 +0000 Subject: [PATCH] Simplify the Sakai integration somewhat: no 'create/revive site' options. Instructors can choose to link to an existing reserves list with which they are associated. If they do so, instructors and students visiting from Sakai will be taken directly to the linked site. If the instructor chooses not to link a reserves list, then visitors from Sakai will be taken to the generic "Browse" page. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1153 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/integration/linktool/app.py | 18 ++++++++++-------- conifer/integration/linktool/templates/associate.xhtml | 4 +++- conifer/integration/uwindsor.py | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/conifer/integration/linktool/app.py b/conifer/integration/linktool/app.py index 4619418..ee95124 100644 --- a/conifer/integration/linktool/app.py +++ b/conifer/integration/linktool/app.py @@ -25,6 +25,7 @@ def linktool_welcome(request): extsite = request.session['clew-site'] = request.GET['site'] related_sites = list(models.Site.objects.filter(group__external_id=extsite)) + if len(related_sites) == 1: site_url = related_sites[0].site_url() html = ("" @@ -45,8 +46,10 @@ def linktool_welcome(request): extsite = ExternalSiteInfo(request) return g.render('associate.xhtml', **locals()) else: - # TODO: implement me - return g.render('choose_dest.xhtml', **locals()) + # redirect the toplevel window to the 'browse' page + html = ("") + return HttpResponse(html) class ExternalSiteInfo(object): def __init__(self, request): @@ -60,19 +63,16 @@ class ExternalSiteInfo(object): course = models.Course.objects.get(code=self.coursecode) except models.Course.DoesNotExist: course = None - course = models.Course.objects.all()[0] try: term = models.Term.objects.get(code=self.termcode) except models.Term.DoesNotExist: term = None - term = models.Term.objects.order_by('-start')[0] self.course_obj = course self.term_obj = term def is_currentish(self): today = date.today() - return self.course_obj is not None and \ - self.term_obj and self.term_obj.midpoint() >= today + return not (self.term_obj and self.term_obj.midpoint() < today) def linktool_new_site(request): extrole = request.session['clew-role'] @@ -81,11 +81,13 @@ def linktool_new_site(request): 'Sorry, but you are not allowed to create sites.' extsite = ExternalSiteInfo(request) extgroups = callhook('external_memberships', request.user.username) + desk = models.ServiceDesk.default() site = models.Site.objects.create( course = extsite.course_obj, - term = extsite.term_obj, + start_term = extsite.term_obj, + end_term = extsite.term_obj, owner = request.user, - service_desk = models.ServiceDesk.default()) + service_desk = desk) group = models.Group.objects.create( site = site, external_id = extsite.group) diff --git a/conifer/integration/linktool/templates/associate.xhtml b/conifer/integration/linktool/templates/associate.xhtml index 78917b2..293d81a 100644 --- a/conifer/integration/linktool/templates/associate.xhtml +++ b/conifer/integration/linktool/templates/associate.xhtml @@ -17,7 +17,7 @@ options:

  1. -
    Link to one of my current reserves list
    +
    Link this course site to one of my current reserves list
    • None available.
    • @@ -25,6 +25,7 @@
  2. +

Or, you can just browse the reserves.

diff --git a/conifer/integration/uwindsor.py b/conifer/integration/uwindsor.py index 9aa3ba0..31f51c8 100644 --- a/conifer/integration/uwindsor.py +++ b/conifer/integration/uwindsor.py @@ -223,10 +223,10 @@ def external_memberships(userid): """ memberships = uwindsor_campus_info.call('membership_ids', userid) for m in memberships: - m['role'] = _decode_role(m['role']) + m['role'] = decode_role(m['role']) return memberships -def _decode_role(role): +def decode_role(role): if role == 'Instructor': return 'INSTR' else: -- 2.11.0