From: artunit Date: Mon, 11 May 2009 02:32:18 +0000 (+0000) Subject: working out instructors more field X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ede6ffa67f865c7efda22a70411302e244bb6089;p=syrup%2Fmasslnc.git working out instructors more field git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@467 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/custom/course_codes.py b/conifer/custom/course_codes.py index 7c34d35..41cfc2d 100644 --- a/conifer/custom/course_codes.py +++ b/conifer/custom/course_codes.py @@ -108,18 +108,24 @@ # Provide your own implementation below. -_codes = [('ENG100', 'Introduction to English'), - ('ART108', 'English: An Introduction'), - ('FRE238', 'Modern French Literature'), - ('LIB201', 'Intro to Library Science'), - ('WEB203', 'Advanced Web Design'),] +#_codes = [('ENG100', 'Introduction to English'), +# ('ART108', 'English: An Introduction'), +# ('FRE238', 'Modern French Literature'), +# ('LIB201', 'Intro to Library Science'), +# ('WEB203', 'Advanced Web Design'),] -_crosslists = set(['ENG100', 'ART108']) +_codes = [('BIOL55-350', 'Molecular Cell Biology'), + ('CRIM48-567', 'Current Issues in Criminology'), + ('ENGL26-280', 'Contemporary Literary Theory'), + ('ENGL26-420', 'Word and Image: The Contemporary Graphic Novel'), + ('SOCWK47-457', 'Advanced Social Work Research'),] + +_crosslists = set(['ENGL26-280', 'ENGL26-420']) course_code_is_valid = None -course_code_example = 'ENG100; FRE238' +course_code_example = 'BIOL55-350; SOCWK47-457' def course_code_list(): return [a for (a,b) in _codes] diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index db5f854..66c50f5 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -22,6 +22,7 @@ urlpatterns = patterns('conifer.syrup.views', (r'^zsearch/$', 'zsearch'), #MARK: propose we kill instructors, we have browse (r'^instructors/$', 'instructors'), + (r'^instructors/search/(?P.*)$', 'instructor_search'), #MARK: propose we kill departments, we have browse (r'^departments/$', 'departments'), (r'^course/(?P\d+)/$', 'course_detail'), diff --git a/conifer/syrup/views/general.py b/conifer/syrup/views/general.py index 0c3a0c4..9ca9ed1 100644 --- a/conifer/syrup/views/general.py +++ b/conifer/syrup/views/general.py @@ -1,5 +1,6 @@ from _common import * from django.utils.translation import ugettext as _ +from search import * #----------------------------------------------------------------------------- @@ -30,6 +31,9 @@ def instructors(request): page_num=page_num, count=count) +def instructor_search(request, instructor): + return search(request, with_instructor=instructor) + # MARK: propose we get rid of this. We have browse. def departments(request): raise NotImplementedError diff --git a/conifer/syrup/views/search.py b/conifer/syrup/views/search.py index 33d1799..c21588a 100644 --- a/conifer/syrup/views/search.py +++ b/conifer/syrup/views/search.py @@ -39,18 +39,22 @@ def get_query(query_string, search_fields): #----------------------------------------------------------------------------- # Search and search support -def search(request, in_course=None): +def search(request, in_course=None, with_instructor=None): ''' Need to work on this, the basic idea is - put an entry point for instructor and course listings - page through item entries If in_course is provided, then limit search to the contents of the specified course. + If with_instructor is provided, then limit search to instructors ''' + + print("in_couse is %s" % in_course) + print("with_instructor is %s" % with_instructor) found_entries = None page_num = int(request.GET.get('page', 1)) count = int(request.GET.get('count', 5)) norm_query = '' query_string = '' - + #TODO: need to block or do something useful with blank query (seems dumb to do entire list) #if ('q' in request.GET) and request.GET['q']: @@ -82,16 +86,20 @@ def search(request, in_course=None): metadata__name='syrup:barcode', metadata__value=query_string) else: - # Textual (non-numeric) queries. - item_query = get_query(query_string, ['title', 'metadata__value']) + if not with_instructor: + # Textual (non-numeric) queries. + item_query = get_query(query_string, ['title', 'metadata__value']) #need to think about sort order here, probably better by author (will make sortable at display level) - results_list = models.Item.objects.filter(item_query) + results_list = models.Item.objects.filter(item_query) if in_course: # For an in-course search, we know the user has # permissions to view the course; no need for # user_filter_for_items. results_list = results_list.filter(course=in_course) + elif with_instructor: + print("in instructor") + results_list = results_list.filter(instructor=with_instructor) else: results_list = results_list.filter(user_filter_for_items) diff --git a/conifer/templates/search_results.xhtml b/conifer/templates/search_results.xhtml index d64dd0c..e34163a 100644 --- a/conifer/templates/search_results.xhtml +++ b/conifer/templates/search_results.xhtml @@ -32,14 +32,16 @@ courses = course_list + + - - + -
Instructors
${Markup(instructor.instr_name_hl(norm_query))}${instructor.user.first_name} ${Markup(instructor.instr_name_hl(norm_query))}, + ${instructor.user.first_name}
(${instr_len - count} more...)