From: gfawcett Date: Fri, 20 Mar 2009 02:05:16 +0000 (+0000) Subject: refactored the Browse features. Marked methods proposed for deletion. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6e4344e0f815b3260ab4e2668c584df0485e21f7;p=syrup%2Fmasslnc.git 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". git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@207 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index cb01746..e1338cd 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -133,7 +133,7 @@ class Term(m.Model): 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 diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 35890ab..a4e9d5a 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -12,14 +12,17 @@ urlpatterns = patterns('conifer.syrup.views', (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_courses'), + (r'^browse/$', 'browse'), + (r'^browse/(?P.*)/$', '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\d+)/$', 'course_detail'), (r'^instructor/(?P.*)/$', 'instructor_detail'), diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 6df874b..4a99a33 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -185,6 +185,7 @@ def welcome(request): 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 @@ def open_courses(request): 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 @@ def instructors(request): page_num=page_num, count=count) - +# MARK: propose we get rid of this. We have browse. def departments(request): raise NotImplementedError @@ -235,34 +236,29 @@ def z3950_test(request): 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)) - - if browse_option == 'instructors': - paginator = Paginator(models.User.active_instructors(), - count) - - return g.render('instructors.xhtml', paginator=paginator, - page_num=page_num, - count=count) - + count = int(request.GET.get('count', 5)) + + 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) - - return g.render('courses.xhtml', paginator=paginator, - page_num=page_num, - count=count) + queryset = models.Course.objects.all() + template = 'courses.xhtml' - return g.render('browse_courses.xhtml') + paginator = queryset and Paginator(queryset, count) or None # index has no queryset. + return g.render(template, paginator=paginator, + page_num=page_num, + count=count) @login_required def my_courses(request): diff --git a/conifer/templates/browse_courses.xhtml b/conifer/templates/browse_courses.xhtml deleted file mode 100644 index 95d40c4..0000000 --- a/conifer/templates/browse_courses.xhtml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - ${title} - - -

${title}

- (Note: some course materials may require you - to log in) -

Choose from one of the options below:

- -
- - diff --git a/conifer/templates/browse_index.xhtml b/conifer/templates/browse_index.xhtml new file mode 100644 index 0000000..95d40c4 --- /dev/null +++ b/conifer/templates/browse_index.xhtml @@ -0,0 +1,25 @@ + + + + + ${title} + + +

${title}

+ (Note: some course materials may require you + to log in) +

Choose from one of the options below:

+ +
+ +