added function to derive URLs for courses
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 11 Jan 2009 02:11:40 +0000 (02:11 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 11 Jan 2009 02:11:40 +0000 (02:11 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@100 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/genshi_namespace.py
conifer/templates/browse_courses.xhtml
conifer/templates/item_heading_detail.xhtml
conifer/templates/item_metadata.xhtml

index 8ce3c09..71dc9a8 100644 (file)
@@ -4,8 +4,14 @@
 # rendering a Genshi template.
 
 from itertools import cycle
-
 from conifer.syrup import models
 
+# Root-relative URLs Django has its own way of doing this, by doing
+# reverse lookups in urlpatterns. Is there a benefit to their
+# approach?
+
 def item_url(item, suffix=''):
     return '/syrup/course/%d/item/%d/%s' % (item.course_id, item.id, suffix)
+
+def course_url(course, suffix=''):
+    return '/syrup/course/%d/%s' % (course.id, suffix)
index 2dbd483..a128fca 100644 (file)
@@ -19,7 +19,7 @@ title = 'Browse Courses'
     <tbody>
       <tr py:for="c in models.Course.objects.all().order_by('code')">
        <td>${c.code}</td>
-       <td>${c.title}</td>
+       <td><a href="${course_url(c)}">${c.title}</a></td>
        <td>${c.term}</td>
       </tr>
     </tbody>
index cb29b0f..73d3549 100644 (file)
@@ -14,7 +14,7 @@ item_tree = course.item_tree(subtree=item)
   </head>
   <body>
     <h1>${title}</h1>
-    <p><a href="../../">${course_title}</a></p>
+    <p><a href="${course_url(course)}">${course_title}</a></p>
     <p>${course.department}</p>
     <p py:if="not item_tree">
       There are no items associated in this subheading.
index 327f46d..d65da40 100644 (file)
@@ -11,7 +11,7 @@ title = item.title
   </head>
   <body>
     <h1>${title}</h1>
-    <p><a href="../../">${course_title}</a></p>
+    <p><a href="${course_url(course)}">${course_title}</a></p>
     <p>${course.department}</p>
 
     <p>Title: ${item.title}</p>