[open-ils-commits] r33 - in servres/trunk/conifer: static syrup templates

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Nov 19 22:26:03 EST 2008


Author: gfawcett
Date: 2008-11-19 22:26:01 -0500 (Wed, 19 Nov 2008)
New Revision: 33

Added:
   servres/trunk/conifer/templates/open_courses.xhtml
   servres/trunk/conifer/templates/paginate.xhtml
Modified:
   servres/trunk/conifer/static/main.css
   servres/trunk/conifer/syrup/views.py
   servres/trunk/conifer/templates/course_detail.xhtml
   servres/trunk/conifer/templates/welcome.xhtml
Log:
following Art's lead with a open_courses template


Modified: servres/trunk/conifer/static/main.css
===================================================================
--- servres/trunk/conifer/static/main.css	2008-11-20 03:25:59 UTC (rev 32)
+++ servres/trunk/conifer/static/main.css	2008-11-20 03:26:01 UTC (rev 33)
@@ -46,4 +46,17 @@
 #tabbar li { display: inline; }
 #tabbar li a { padding: 18 18 4 18; background-color: #ddf; color: black; text-decoration: none; }
 #tabbar li a:hover { background-color: #fc8; }
+/* 
 #tabbar li.active a { background-color: #fa6; font-weight: bold; }
+*/
+
+.pagination_controls {
+    text-align: center;
+}
+
+.pagination_controls .nums {
+    padding: 0 24; 
+}
+
+.pagetable td { border: #ddd 1px solid; padding: 4 8; }
+.pagetable thead th { font-size: smaller; text-align: left; padding: 2 8; }
\ No newline at end of file

Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2008-11-20 03:25:59 UTC (rev 32)
+++ servres/trunk/conifer/syrup/views.py	2008-11-20 03:26:01 UTC (rev 33)
@@ -34,17 +34,21 @@
     return g.render('welcome.xhtml')
 
 def open_courses(request):
-    pgstart = request.GET.get('start')
-    if not pgstart:
-        pgstart = 1
-    paginator = Paginator(models.Course.objects.filter(moderated=False), 5)
-    return g.render('open_courses.xhtml', paginator=paginator, pgstart=pgstart)
+    page_num = int(request.GET.get('page', 1))
+    count = int(request.GET.get('count', 5))
+    paginator = Paginator(models.Course.objects.filter(moderated=False), count)
+    return g.render('open_courses.xhtml', paginator=paginator,
+                    page_num=page_num,
+                    count=count)
 
 @login_required
 def my_courses(request):
     return g.render('my_courses.xhtml')
 
- at login_required
 def course_detail(request, course_id):
     course = get_object_or_404(models.Course, pk=course_id)
+    if course.moderated and request.user.is_anonymous():
+        #fixme, don't stop access just if anonymous, but rather if not
+        #allowed to access. We need to set up a permissions model.
+        return login_required(lambda *args: None)(request)
     return g.render('course_detail.xhtml', course=course)

Modified: servres/trunk/conifer/templates/course_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/course_detail.xhtml	2008-11-20 03:25:59 UTC (rev 32)
+++ servres/trunk/conifer/templates/course_detail.xhtml	2008-11-20 03:26:01 UTC (rev 33)
@@ -10,5 +10,8 @@
 </head>
 <body>
   <h1>${title}</h1>
+  <p>${course.department}</p>
+  <h2>Reserve Items</h2>
+  (not implemented yet)
 </body>
 </html>

Added: servres/trunk/conifer/templates/open_courses.xhtml
===================================================================
--- servres/trunk/conifer/templates/open_courses.xhtml	                        (rev 0)
+++ servres/trunk/conifer/templates/open_courses.xhtml	2008-11-20 03:26:01 UTC (rev 33)
@@ -0,0 +1,24 @@
+<?python
+title = 'Open Courses'
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      xmlns:py="http://genshi.edgewall.org/">
+<xi:include href="master.xhtml"/>
+<xi:include href="paginate.xhtml"/>
+<head>
+  <title>${title}</title>
+</head>
+<body>
+  <h1>${title}</h1>
+  <tr py:def="pageheader()">
+    <th>Term</th><th>Code</th><th>Title</th>
+  </tr>
+  <tr py:def="pagerow(item)">
+    <td>${item.term}</td>
+    <td><a href="../course/${item.id}/">${item.code}</a></td>
+    <td><a href="../course/${item.id}/">${item.title}</a></td>
+  </tr>
+  ${pagetable(paginator, start, count, pagerow, pageheader)}
+</body>
+</html>

Added: servres/trunk/conifer/templates/paginate.xhtml
===================================================================
--- servres/trunk/conifer/templates/paginate.xhtml	                        (rev 0)
+++ servres/trunk/conifer/templates/paginate.xhtml	2008-11-20 03:26:01 UTC (rev 33)
@@ -0,0 +1,32 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      py:strip="">
+<div py:def="pagetable(paginator, start, count, pagerow, pagehead=None)"
+     py:with="page = paginator.page(page_num)">
+  <table class="pagetable">
+    <thead py:if="pagehead">
+      ${pagehead()}
+    </thead>
+    <tbody>
+      <tr py:strip="True" py:for="item in page.object_list">
+	${pagerow(item)}
+      </tr>
+    </tbody>
+  </table>
+  <div class="pagination_controls" py:if="paginator.num_pages > 1">
+    <span py:if="page.has_previous()" class="prev">
+      <a href=".?page=${page.previous_page_number()}&amp;count=${count}">Previous</a>
+    </span>
+    <span class="nums">
+      <span py:for="pp in range(1, 1+paginator.num_pages)">
+	<a style="font-weight: ${pp == page_num and 'bold' or 'normal'}"
+	   href=".?page=${pp}&amp;count=${count}">${pp}</a>
+      </span>
+    </span>
+    <span py:if="page.has_next()" class="next">
+      <a href=".?page=${page.next_page_number()}&amp;count=${count}">Next</a>
+    </span>
+  </div>
+</div>
+</html>
\ No newline at end of file

Modified: servres/trunk/conifer/templates/welcome.xhtml
===================================================================
--- servres/trunk/conifer/templates/welcome.xhtml	2008-11-20 03:25:59 UTC (rev 32)
+++ servres/trunk/conifer/templates/welcome.xhtml	2008-11-20 03:26:01 UTC (rev 33)
@@ -10,7 +10,7 @@
 </head>
 <body>
   <div style="float: right; margin: 0 24; background-color: #feb; padding: 24;">
-    <p><a href="/accounts/login/?next=/syrup/">Log in</a></p>
+    <p py:if="not user.is_authenticated()"><a href="/accounts/login/?next=/syrup/">Log in</a></p>
     <p><a href="opencourse">Browse Open Courses</a></p>
     <p><a href="/public/search">Search the Reserves</a></p>
   </div>



More information about the open-ils-commits mailing list