[open-ils-commits] r1153 - in servres/trunk/conifer/integration: . linktool linktool/templates (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Dec 30 11:28:07 EST 2010


Author: gfawcett
Date: 2010-12-30 11:28:04 -0500 (Thu, 30 Dec 2010)
New Revision: 1153

Modified:
   servres/trunk/conifer/integration/linktool/app.py
   servres/trunk/conifer/integration/linktool/templates/associate.xhtml
   servres/trunk/conifer/integration/uwindsor.py
Log:
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.

Modified: servres/trunk/conifer/integration/linktool/app.py
===================================================================
--- servres/trunk/conifer/integration/linktool/app.py	2010-12-29 19:45:28 UTC (rev 1152)
+++ servres/trunk/conifer/integration/linktool/app.py	2010-12-30 16:28:04 UTC (rev 1153)
@@ -25,6 +25,7 @@
         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     = ("<html><head/><body onload=\"top.location='%s';\">"
@@ -45,8 +46,10 @@
             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 = ("<html><head><script>window.onload=function() { "
+                    "top.location='../browse/'; }</script></head></html>")
+            return HttpResponse(html)
 
 class ExternalSiteInfo(object):
     def __init__(self, request):
@@ -60,19 +63,16 @@
             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 @@
         '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)

Modified: servres/trunk/conifer/integration/linktool/templates/associate.xhtml
===================================================================
--- servres/trunk/conifer/integration/linktool/templates/associate.xhtml	2010-12-29 19:45:28 UTC (rev 1152)
+++ servres/trunk/conifer/integration/linktool/templates/associate.xhtml	2010-12-30 16:28:04 UTC (rev 1153)
@@ -17,7 +17,7 @@
       options:</p>
       <ol>
 	<li>
-	  <div><b>Link to one of my current reserves list</b></div>
+	  <div><b>Link this course site to one of my current reserves list</b></div>
 	  <ul>
 	    <li py:if="not current">None available.</li>
 	    <li py:for="site in current">
@@ -25,6 +25,7 @@
 	    </li>
 	  </ul>
 	</li>
+<!--
 	<li>
 	  <div><b>Copy a reserves list I've used in the past</b></div>
 	  <ul>
@@ -37,6 +38,7 @@
 	<li>
 	  <div><b><a href="new_site">Start a new reserves list for this site</a></b></div>
 	</li>
+-->
       </ol>
       <p>Or, you can just <a href="${ROOT}/browse/">browse the reserves</a>.</p>
     </div>

Modified: servres/trunk/conifer/integration/uwindsor.py
===================================================================
--- servres/trunk/conifer/integration/uwindsor.py	2010-12-29 19:45:28 UTC (rev 1152)
+++ servres/trunk/conifer/integration/uwindsor.py	2010-12-30 16:28:04 UTC (rev 1153)
@@ -223,10 +223,10 @@
     """
     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:



More information about the open-ils-commits mailing list