git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@78 6d9bc8c9-1ec2-4278...
authorartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 9 Dec 2008 03:05:17 +0000 (03:05 +0000)
committerartunit <artunit@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 9 Dec 2008 03:05:17 +0000 (03:05 +0000)
conifer/syrup/models.py
conifer/templates/search_results.xhtml

index 964a2cd..6953894 100644 (file)
@@ -286,6 +286,23 @@ class Item(m.Model):
 
     date_created = m.DateTimeField(auto_now_add=True)
     last_modified = m.DateTimeField()
+
+    def title_hl(self, terms):
+        for term in terms:
+            hl_title = highlight(self.title,term)
+            if not hl_title == self.title:
+                return hl_title
+
+        return self.title
+
+    def author_hl(self, terms):
+        for term in terms:
+            hl_author = highlight(self.author,term)
+            if not hl_author == self.author:
+                return hl_author
+
+        return self.author
+
     
     def __unicode__(self):
         return self.title
index f1a6da3..84282a7 100644 (file)
@@ -16,24 +16,29 @@ instructors = instructor_list
 </head>
 <body>
   <h1>${title}</h1>
+    <h3>You searched: <i>${query_string}</i></h3>
+    <p style="font-size: large;">
+        No. of instructors: <i> ${instr_len}</i>
+    </p>
+    <p py:for="foo in instructors" style="font-size: large;">
+        <!--
+        there are a couple of options here
+        ${foo.instr_name()}<br/>
+        ${foo.user.last_name}<br/>
+        -->
     
-    <h3>${query_string}</h3>
-  <p py:for="foo in instructors" style="font-size: large;">
-    hey ${foo.instr_name()}<br/>
-    hey ${foo.user.last_name}<br/>
-    <!-- need to figure out how to unescape this -->
-    hey ${Markup(foo.instr_name_hl(norm_query))}<br/>
-  </p>
-  <tr py:def="pageheader()">
-    <th>Term</th><!-- <th>Code</th> --><th>Title</th>
-  </tr>
-  <span py:def="pagerow(item)">
-    <td>${item.author}</td>
-    <!--
-    <td><a href="../course/${item.id}/">${item.code}</a></td>
-    -->
-    <td>${item.title}</td>
-  </span>
-  ${pagetable(paginator, count, pagerow, pageheader)}
+        ${Markup(foo.instr_name_hl(norm_query))}<br/>
+    </p>
+  
+    <tr py:def="pageheader()">
+        <th>Author</th><th>Title</th>
+    </tr>
+  
+    <span py:def="pagerow(item)">
+        <td>${Markup(item.author_hl(norm_query))}</td>
+        <td>${Markup(item.title_hl(norm_query))}</td>
+    </span>
+    ${pagetable(paginator, count, pagerow, pageheader)}
+
 </body>
 </html>