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)
(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'),
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
#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]
<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>