working out instructors more field
authorartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Mon, 11 May 2009 02:32:18 +0000 (02:32 +0000)
committerartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Mon, 11 May 2009 02:32:18 +0000 (02:32 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@467 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/custom/course_codes.py
conifer/syrup/urls.py
conifer/syrup/views/general.py
conifer/syrup/views/search.py
conifer/templates/search_results.xhtml

index 7c34d35..41cfc2d 100644 (file)
 # 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]
index db5f854..66c50f5 100644 (file)
@@ -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>.*)$', 'instructor_search'),
     #MARK: propose we kill departments, we have browse
     (r'^departments/$', 'departments'),
     (r'^course/(?P<course_id>\d+)/$', 'course_detail'),
index 0c3a0c4..9ca9ed1 100644 (file)
@@ -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
index 33d1799..c21588a 100644 (file)
@@ -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)
 
index d64dd0c..e34163a 100644 (file)
@@ -32,14 +32,16 @@ courses = course_list
         <td py:if="instructors" valign="top" class="topbox">
         <table class="topheading">
         <tr>
+        <!--
         <th>Last Name</th><th>First Name</th>
+        -->
+        <th>Instructors</th>
         </tr>
         <tr py:for="instructor in instructors">
-            <td>${Markup(instructor.instr_name_hl(norm_query))}</td>
-            <td>${instructor.user.first_name}</td>
+            <td> ${Markup(instructor.instr_name_hl(norm_query))},
+            ${instructor.user.first_name}</td>
         </tr>
         <tr py:if="instr_len > count">
-        <td></td>
         <!-- will tap into open list here -->
         <td>(${instr_len - count} more...)</td>
         </tr>