[open-ils-commits] r297 - in servres/trunk/conifer: . syrup templates (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 6 22:08:59 EDT 2009


Author: gfawcett
Date: 2009-04-06 22:08:57 -0400 (Mon, 06 Apr 2009)
New Revision: 297

Modified:
   servres/trunk/conifer/settings.py
   servres/trunk/conifer/syrup/models.py
   servres/trunk/conifer/syrup/views.py
   servres/trunk/conifer/templates/master.xhtml
   servres/trunk/conifer/templates/tabbar.xhtml
   servres/trunk/conifer/urls.py
Log:
work in progress: fixing absolute /syrup/ root references.

Sorry for checking in partially-working code, but I don't want to list this.

Some /syrup/ root-prefixes are fixed; some are not. Note, this commit
will almost certainly break if running as './manage.py
runserver'. Using mod_python, it should still work:

<Location "/syrup/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE conifer.settings
    PythonOption django.root /syrup
    PythonDebug Off
    PythonPath "['/home/graham/projects/evergreen/servres/'] + sys.path"
</Location>


Modified: servres/trunk/conifer/settings.py
===================================================================
--- servres/trunk/conifer/settings.py	2009-04-07 01:42:22 UTC (rev 296)
+++ servres/trunk/conifer/settings.py	2009-04-07 02:08:57 UTC (rev 297)
@@ -121,14 +121,13 @@
     AUTHENTICATION_BACKENDS.append(
         'conifer.custom.auth_evergreen.EvergreenAuthBackend')
 
-# stuff that I really ought not check into svn...
-#SIP_HOST = ('hostname', 9999)
-#SIP_CREDENTIALS = ('userid', 'password', 'location')
-
 try:
     # Graham has this right now; it's not official Syrup. Nothing to see here.
     from private_local_settings import SIP_HOST, SIP_CREDENTIALS
 except:
+    # stuff that I really ought not check into svn...
+    #SIP_HOST = ('hostname', 9999)
+    #SIP_CREDENTIALS = ('userid', 'password', 'location')
     pass
 
 #CACHE_BACKEND = 'memcached://127.0.0.1:11211/'

Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py	2009-04-07 01:42:22 UTC (rev 296)
+++ servres/trunk/conifer/syrup/models.py	2009-04-07 02:08:57 UTC (rev 297)
@@ -11,6 +11,7 @@
 import re
 import random
 from django.utils import simplejson
+from conifer.middleware import genshi_locals
 
 def highlight(text, phrase,
               highlighter='<strong class="highlight">\\1</strong>'):
@@ -241,7 +242,9 @@
         return mbr.role in (u'INSTR', u'PROXY')
 
     def course_url(self, suffix=''):
-        return '/syrup/course/%d/%s' % (self.id, suffix)
+        req = genshi_locals.get_request()
+        prefix = req.META['SCRIPT_NAME']
+        return '%s/course/%d/%s' % (prefix, self.id, suffix)
 
     def generate_new_passkey(self):
         # todo: have a pluggable passkey algorithm.
@@ -465,15 +468,17 @@
         return self.item_type in ('ELEC', 'URL', 'PHYS')
 
     def item_url(self, suffix='', force_local_url=False):
+        req = genshi_locals.get_request()
+        prefix = req.META['SCRIPT_NAME']
         if self.item_type == 'ELEC' and suffix == '':
-            return '/syrup/course/%d/item/%d/dl/%s' % (
-                self.course_id, self.id, 
+            return '%s/course/%d/item/%d/dl/%s' % (
+                prefix, self.course_id, self.id, 
                 self.fileobj.name.split('/')[-1])
         if self.item_type == 'URL' and suffix == '' and not force_local_url:
             return self.url
-        else:
-            return '/syrup/course/%d/item/%d/%s' % (
-                self.course_id, self.id, suffix)
+        else: 
+            return '%s/course/%d/item/%d/%s' % (
+                prefix, self.course_id, self.id, suffix)
     
     def parent_url(self, suffix=''):
         if self.parent_heading:

Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2009-04-07 01:42:22 UTC (rev 296)
+++ servres/trunk/conifer/syrup/views.py	2009-04-07 02:08:57 UTC (rev 297)
@@ -37,6 +37,7 @@
 from conifer.custom import lib_integration
 from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary, marcxml_dictionary_to_dc
 from fuzzy_match import rank_pending_items
+from django.core.urlresolvers import reverse
 
 #-----------------------------------------------------------------------------
 # Z39.50 Support
@@ -78,9 +79,10 @@
 # Authentication
 
 def auth_handler(request, path):
+    default_url = reverse(welcome) #request.META['SCRIPT_NAME'] + '/'
     if path == 'login/':
         if request.method == 'GET':
-            next=request.GET.get('next', '/syrup/')
+            next=request.GET.get('next', default_url)
             if request.user.is_authenticated():
                 return HttpResponseRedirect(next)
             else:
@@ -106,10 +108,10 @@
                 except models.UserProfile.DoesNotExist:
                     profile = models.UserProfile.objects.create(user=user)
                     profile.save()
-                return HttpResponseRedirect(request.POST.get('next', '/syrup/'))
+                return HttpResponseRedirect(request.POST.get('next', default_url))
     elif path == 'logout':
         logout(request)
-        return HttpResponseRedirect('/syrup/')
+        return HttpResponseRedirect(default_url)
     else:
         return HttpResponse('auth_handler: ' + path)
 
@@ -134,7 +136,7 @@
 def _access_denied(request, message):
     if request.user.is_anonymous():
         # then take them to login screen....
-        dest = '/syrup/accounts/login/?next=' + request.environ['PATH_INFO']
+        dest = request.META['SCRIPT_NAME'] + '/accounts/login/?next=' + request.environ['PATH_INFO']
         return HttpResponseRedirect(dest)
     else:
         return simple_message(_('Access denied.'), message,
@@ -525,7 +527,7 @@
     course = get_object_or_404(models.Course, pk=course_id)
     if request.POST.get('confirm_delete'):
         course.delete()
-        return HttpResponseRedirect('/syrup/course/')
+        return HttpResponseRedirect(reverse('my_courses'))
     else:
         return HttpResponseRedirect('../')
 

Modified: servres/trunk/conifer/templates/master.xhtml
===================================================================
--- servres/trunk/conifer/templates/master.xhtml	2009-04-07 01:42:22 UTC (rev 296)
+++ servres/trunk/conifer/templates/master.xhtml	2009-04-07 02:08:57 UTC (rev 297)
@@ -2,6 +2,7 @@
 app_name = _('Syrup E-Reserve System')
 search = _('search...')
 import os
+rooted = lambda url: request.META['SCRIPT_NAME'] + url
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:py="http://genshi.edgewall.org/"
@@ -11,10 +12,10 @@
     <head py:attrs="select('@*')"
 	  py:with="t=list(select('title/text()'))">
       <title>${app_name}<py:if test="t">: ${t}</py:if></title>
-    <link rel="stylesheet" type="text/css" href="/syrup/static/main.css"/>
-    <script type="text/javascript" src="/syrup/static/jquery/js/jquery-1.3.2.min.js"/>
-    <script type="text/javascript" src="/syrup/static/jquery/js/jquery-ui-1.7.1.custom.min.js"/>
-    <script type="text/javascript" src="/syrup/static/jquery/js/jquery.tablesorter.min.js"/>
+    <link rel="stylesheet" type="text/css" href="${rooted('/static/main.css')}"/>
+    <script type="text/javascript" src="${rooted('/static/jquery/js/jquery-1.3.2.min.js')}"/>
+    <script type="text/javascript" src="${rooted('/static/jquery/js/jquery-ui-1.7.1.custom.min.js')}"/>
+    <script type="text/javascript" src="${rooted('/static/jquery/js/jquery.tablesorter.min.js')}"/>
     ${select('*[local-name()!="title"]')}
     </head>
   </py:match>
@@ -26,7 +27,7 @@
 	  ${os.getpid()}
 	  ${app_name}
 	</div>
-	<img src="/syrup/static/institution-logo.png" style="height: 50;"/>
+	<img src="${rooted('/static/institution-logo.png')}" style="height: 50;"/>
       </div>
         <!--
       <div id="header" py:if="user.is_authenticated()">
@@ -34,7 +35,7 @@
         -->
       <div id="header">
         <div id="search">
-            <form method="get" action="/syrup/search" 
+            <form method="get" action="${rooted('/search')}" 
                 onsubmit="if(q.value.replace(/^\s*/, '').replace(/\s*$/, '') =='') return false;"
             >
             <input id="q" name="q" maxlength="100" size="25" type="text" 
@@ -44,13 +45,13 @@
         </div>
       <span py:if="user.is_authenticated()">
 	<strong style="padding-right: 18;">Welcome, ${user.first_name or user.username}!</strong>
-	<a href="/syrup/accounts/logout">Log Out</a>
-	&bull; <a href="/syrup/prefs/">Preferences</a>
+	<a href="${rooted('/accounts/logout')}">Log Out</a>
+	&bull; <a href="${rooted('/prefs/')}">Preferences</a>
       </span>
       <span py:if="not user.is_authenticated()">
 	<strong style="padding-right: 18;">Welcome!</strong>
-	<a class="loginbutton" href="/syrup/accounts/login/">Log In</a>
-	&bull; <a href="/syrup/prefs/">Preferences</a>
+	<a class="loginbutton" href="${rooted('/accounts/login/')}">Log In</a>
+	&bull; <a href="${rooted('/prefs/')}">Preferences</a>
       </span>
     </div>
       <xi:include py:if="user.is_authenticated()" href="tabbar.xhtml"/>
@@ -60,15 +61,6 @@
       </div>
       <div id="footer">
 	<div> 
-    <!--
-        !We may eventually have a tab bar for non authenticated users,
-        but we definitely need a start over option for now. There is
-        probably a more elegant way of detecting whether we are on
-        the front page but this works for the short term
-    -->
-    <span py:if="not user.is_authenticated() and not request.META.PATH_INFO == '/syrup/'">
-        <a href="/syrup">Start Over</a>  -
-    </span>
     Syrup is a subproject of <a href="http://conifer.mcmaster.ca/">Project Conifer</a> &copy; 2009
     </div>
       </div>

Modified: servres/trunk/conifer/templates/tabbar.xhtml
===================================================================
--- servres/trunk/conifer/templates/tabbar.xhtml	2009-04-07 01:42:22 UTC (rev 296)
+++ servres/trunk/conifer/templates/tabbar.xhtml	2009-04-07 02:08:57 UTC (rev 297)
@@ -7,13 +7,13 @@
     use one for now
 -->
 <ul id="tabbar">
-  <li><a href="/syrup/">Home</a></li>
-  <li><a href="/syrup/browse/">Browse</a></li>
-  <li class="active"><a href="/syrup/course/">My Courses</a></li>
+  <li><a href="${rooted('/')}">Home</a></li>
+  <li><a href="${rooted('/browse/')}">Browse</a></li>
+  <li class="active"><a href="${rooted('/course/')}">My Courses</a></li>
   <div py:strip="True"
        py:if="request.user.is_staff">
-    <li><a href="/syrup/admin/">Admin Options</a></li>
-    <li><a href="/syrup/phys/">Physical Items</a></li>
+    <li><a href="${rooted('/admin/')}">Admin Options</a></li>
+    <li><a href="${rooted('/phys/')}">Physical Items</a></li>
   </div>
 </ul>
 </html>

Modified: servres/trunk/conifer/urls.py
===================================================================
--- servres/trunk/conifer/urls.py	2009-04-07 01:42:22 UTC (rev 296)
+++ servres/trunk/conifer/urls.py	2009-04-07 02:08:57 UTC (rev 297)
@@ -18,19 +18,19 @@
 
     # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
     # to INSTALLED_APPS to enable admin documentation:
-    (r'^syrup/djadmin/doc/', include('django.contrib.admindocs.urls')),
+    (r'^djadmin/doc/', include('django.contrib.admindocs.urls')),
 
     # Uncomment the next line to enable the admin:
-    (r'^syrup/djadmin/(.*)', admin.site.root),
-    (r'^syrup/djmedia/(.*)', 'django.views.static.serve',
+    (r'^djadmin/(.*)', admin.site.root),
+    (r'^djmedia/(.*)', 'django.views.static.serve',
         {'document_root': ADMIN_MEDIA_ROOT}),
-    (r'^syrup/static/(?P<path>.*)$', 'django.views.static.serve',
+    (r'^static/(?P<path>.*)$', 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT}),
-    (r'^syrup/accounts/(?P<path>.*)$', 'conifer.syrup.views.auth_handler'),
+    (r'^accounts/(?P<path>.*)$', 'conifer.syrup.views.auth_handler'),
 
 #    (r'^syrup/setlang', 'conifer.syrup.views.setlang'),
-    (r'^syrup/i18n/', include('django.conf.urls.i18n')),
-    (r'^syrup/', include('conifer.syrup.urls')),
+    (r'^i18n/', include('django.conf.urls.i18n')),
+    (r'', include('conifer.syrup.urls')),
 
 )
 



More information about the open-ils-commits mailing list