git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@118 6d9bc8c9-1ec2-4278...
authorartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 25 Jan 2009 23:43:53 +0000 (23:43 +0000)
committerartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Sun, 25 Jan 2009 23:43:53 +0000 (23:43 +0000)
conifer/genshi_namespace.py
conifer/syrup/urls.py
conifer/syrup/views.py
conifer/templates/instructors.xhtml

index 6cb5f1d..3bd545d 100644 (file)
@@ -18,3 +18,9 @@ def item_url(item, suffix=''):
 
 def course_url(course, suffix=''):
     return '/syrup/course/%d/%s' % (course.id, suffix)
+
+def instructor_url(instructor, suffix=''):
+    return '/syrup/instructor/%d/%s' % (instructor.id, suffix)
+
+def department_url(department, suffix=''):
+    return '/syrup/department/%d/%s' % (department.id, suffix)
index 0c652ef..3cff76f 100644 (file)
@@ -16,6 +16,8 @@ urlpatterns = patterns('conifer.syrup.views',
     (r'^search/$', 'search'),
     (r'^instructors/$', 'instructors'),
     (r'^course/(?P<course_id>\d+)/$', 'course_detail'),
+    (r'^instructor/(?P<instructor_id>.*)/$', 'instructor_detail'),
+    (r'^department/(?P<department_id>.*)/$', 'department_detail'),
     (ITEM_PREFIX + r'$', 'item_detail'),
     (ITEM_PREFIX + r'dl/(?P<filename>.*)$', 'item_download'),
     (ITEM_PREFIX + r'meta/$', 'item_metadata'),
index 162f4a1..02f4b92 100644 (file)
@@ -118,6 +118,28 @@ def course_detail(request, course_id):
         return login_required(lambda *args: None)(request)
     return g.render('course_detail.xhtml', course=course)
 
+def instructor_detail(request, instructor_id):
+    page_num = int(request.GET.get('page', 1))
+    count = int(request.GET.get('count', 5))
+    paginator = Paginator(models.Course.objects.
+        filter(member__id=instructor_id).
+        filter(active=True).order_by('title'), count)
+
+    return g.render('courses.xhtml', paginator=paginator,
+            page_num=page_num,
+            count=count)
+
+def department_detail(request, department_id):
+    page_num = int(request.GET.get('page', 1))
+    count = int(request.GET.get('count', 5))
+    paginator = Paginator(models.Course.objects.
+        filter(department__id=department_id).
+        filter(active=True).order_by('title'), count)
+
+    return g.render('courses.xhtml', paginator=paginator,
+            page_num=page_num,
+            count=count)
+
 def item_detail(request, course_id, item_id):
     """Display an item (however that makes sense).""" 
     # really, displaying an item will vary based on what type of item
@@ -314,6 +336,8 @@ def search(request):
 
         #course search
         course_query = get_query(query_string, ['title', 'department__name'])
+        print 'course_query'
+        print course_query
         course_results = models.Course.objects.filter(course_query).filter(active=True)
         # course_list = models.Course.objects.filter(course_query).filter(active=True).order_by('title')[0:5]
         course_list = course_results.order_by('title')[0:5]
index 2907b88..2cc7341 100644 (file)
@@ -19,7 +19,7 @@ title = 'Instructors'
     <th>Name</th>
   </tr>
   <span py:def="pagerow(item)">
-    <td>${item.user.last_name}, ${item.user.first_name}</td>
+    <td><a href="${instructor_url(item.user)}">${item.user.last_name}, ${item.user.first_name}</a></td>
   </span>
   ${pagetable(paginator, count, pagerow, pageheader)}
 </body>