[open-ils-commits] r207 - in servres/trunk/conifer: syrup templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 19 22:05:17 EDT 2009
Author: gfawcett
Date: 2009-03-19 22:05:16 -0400 (Thu, 19 Mar 2009)
New Revision: 207
Added:
servres/trunk/conifer/templates/browse_index.xhtml
Removed:
servres/trunk/conifer/templates/browse_courses.xhtml
Modified:
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views.py
Log:
refactored the Browse features. Marked methods proposed for deletion.
We have some cruft in views.py and urls.py. I'm proposing to cut it
unless artunit can think of a good reason to keep it. I've marked the
methods and URLs with "MARK".
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2009-03-20 01:48:30 UTC (rev 206)
+++ servres/trunk/conifer/syrup/models.py 2009-03-20 02:05:16 UTC (rev 207)
@@ -133,7 +133,7 @@
class Department(m.Model):
abbreviation = m.CharField(max_length=8,db_index=True)
name = m.CharField(max_length=255)
- active = m.BooleanField(default=True)
+ active = m.BooleanField(default=True)
def __unicode__(self):
return self.name
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2009-03-20 01:48:30 UTC (rev 206)
+++ servres/trunk/conifer/syrup/urls.py 2009-03-20 02:05:16 UTC (rev 207)
@@ -12,14 +12,17 @@
(r'^course/new/$', 'add_new_course'),
(r'^course/new/ajax_title$', 'add_new_course_ajax_title'),
(r'^course/invitation/$', 'course_invitation'),
- (r'^browse/$', 'browse_courses'),
- (r'^browse/(?P<browse_option>.*)/$', 'browse_courses'),
+ (r'^browse/$', 'browse'),
+ (r'^browse/(?P<browse_option>.*)/$', 'browse'),
(r'^prefs/$', 'user_prefs'),
(r'^z3950test/$', 'z3950_test'),
+ #MARK: propose we kill open_courses, we have browse.
(r'^opencourse/$', 'open_courses'),
(r'^search/$', 'search'),
(r'^zsearch/$', 'zsearch'),
+ #MARK: propose we kill instructors, we have browse
(r'^instructors/$', 'instructors'),
+ #MARK: propose we kill departments, we have browse
(r'^departments/$', 'departments'),
(r'^course/(?P<course_id>\d+)/$', 'course_detail'),
(r'^instructor/(?P<instructor_id>.*)/$', 'instructor_detail'),
Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py 2009-03-20 01:48:30 UTC (rev 206)
+++ servres/trunk/conifer/syrup/views.py 2009-03-20 02:05:16 UTC (rev 207)
@@ -185,6 +185,7 @@
def setlang(request):
return g.render('setlang.xhtml')
+# MARK: propose we get rid of this. We already have a 'Courses' browser.
def open_courses(request):
page_num = int(request.GET.get('page', 1))
count = int(request.GET.get('count', 5))
@@ -192,7 +193,7 @@
return g.render('open_courses.xhtml', paginator=paginator,
page_num=page_num,
count=count)
-
+# MARK: propose we drop this too. We have a browse.
def instructors(request):
page_num = int(request.GET.get('page', 1))
count = int(request.GET.get('count', 5))
@@ -208,7 +209,7 @@
page_num=page_num,
count=count)
-
+# MARK: propose we get rid of this. We have browse.
def departments(request):
raise NotImplementedError
@@ -235,35 +236,30 @@
return g.render('z3950_test.xhtml', res_str=res_str)
-def browse_courses(request, browse_option=''):
+def browse(request, browse_option=''):
#the defaults should be moved into a config file or something...
page_num = int(request.GET.get('page', 1))
- count = int(request.GET.get('count', 5))
+ count = int(request.GET.get('count', 5))
- if browse_option == 'instructors':
- paginator = Paginator(models.User.active_instructors(),
- count)
-
- return g.render('instructors.xhtml', paginator=paginator,
- page_num=page_num,
- count=count)
-
+ if browse_option == '':
+ queryset = None
+ template = 'browse_index.xhtml'
+ elif browse_option == 'instructors':
+ queryset = models.User.active_instructors()
+ template = 'instructors.xhtml'
elif browse_option == 'departments':
- paginator = Paginator(models.Department.objects.filter(active=True), count)
-
- return g.render('departments.xhtml', paginator=paginator,
- page_num=page_num,
- count=count)
+ queryset = models.Department.objects.filter(active=True)
+ template = 'departments.xhtml'
elif browse_option == 'courses':
# fixme, course filter should not be (active=True) but based on user identity.
- paginator = Paginator(models.Course.objects.all(), count)
+ queryset = models.Course.objects.all()
+ template = 'courses.xhtml'
- return g.render('courses.xhtml', paginator=paginator,
- page_num=page_num,
- count=count)
+ paginator = queryset and Paginator(queryset, count) or None # index has no queryset.
+ return g.render(template, paginator=paginator,
+ page_num=page_num,
+ count=count)
- return g.render('browse_courses.xhtml')
-
@login_required
def my_courses(request):
return g.render('my_courses.xhtml')
Deleted: servres/trunk/conifer/templates/browse_courses.xhtml
===================================================================
--- servres/trunk/conifer/templates/browse_courses.xhtml 2009-03-20 01:48:30 UTC (rev 206)
+++ servres/trunk/conifer/templates/browse_courses.xhtml 2009-03-20 02:05:16 UTC (rev 207)
@@ -1,25 +0,0 @@
-<?python
-title = _('Browse the Reserves')
-?>
-<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"/>
-<head>
- <title>${title}</title>
-</head>
-<body>
- <h1>${title}</h1>
- (Note: some course materials may require you
- to <a href="/accounts/login/?next=/syrup/">log in</a>)
- <h2>Choose from one of the options below:</h2>
- <ul>
- <li><a href="courses">Browse by Course Name</a></li>
- <li><a
- href="instructors">Browse by Instructor</a></li>
- <li><a
- href="departments">Browse by Department</a></li>
- </ul>
- <div class="gap"/>
-</body>
-</html>
Copied: servres/trunk/conifer/templates/browse_index.xhtml (from rev 206, servres/trunk/conifer/templates/browse_courses.xhtml)
===================================================================
--- servres/trunk/conifer/templates/browse_index.xhtml (rev 0)
+++ servres/trunk/conifer/templates/browse_index.xhtml 2009-03-20 02:05:16 UTC (rev 207)
@@ -0,0 +1,25 @@
+<?python
+title = _('Browse the Reserves')
+?>
+<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"/>
+<head>
+ <title>${title}</title>
+</head>
+<body>
+ <h1>${title}</h1>
+ (Note: some course materials may require you
+ to <a href="/accounts/login/?next=/syrup/">log in</a>)
+ <h2>Choose from one of the options below:</h2>
+ <ul>
+ <li><a href="courses">Browse by Course Name</a></li>
+ <li><a
+ href="instructors">Browse by Instructor</a></li>
+ <li><a
+ href="departments">Browse by Department</a></li>
+ </ul>
+ <div class="gap"/>
+</body>
+</html>
More information about the open-ils-commits
mailing list