Added bug searching
authorAaron Bentley <abentley@panoramicfeedback.com>
Fri, 31 Mar 2006 21:16:53 +0000 (16:16 -0500)
committerAaron Bentley <abentley@panoramicfeedback.com>
Fri, 31 Mar 2006 21:16:53 +0000 (16:16 -0500)
beweb/beweb/controllers.py
beweb/beweb/templates/bugs.kid

index 9379e24b26d71cee144d9c494f167130fd68e71d..6c43ecb0747fea8c8296cf65e5c3aba7cdd84098 100644 (file)
@@ -59,7 +59,8 @@ class Bug(PrestHandler):
             return self.index(bug_data['project'], bug)
 
     @turbogears.expose(html="beweb.templates.bugs")
-    def list(self, project, sort_by=None, show_closed=False, action=None):
+    def list(self, project, sort_by=None, show_closed=False, action=None, 
+             search=None):
         if action == "New bug":
             self.new_bug()
         if show_closed == "False":
@@ -75,6 +76,7 @@ class Bug(PrestHandler):
                 "project_name"    : projects[project][0],
                 "bugs"            : bugs,
                 "show_closed"     : show_closed,
+                "search"          : search,
                }
 
     @provide_action("action", "New bug")
@@ -123,10 +125,12 @@ def bug_url(project_id, bug_uuid=None):
         bug_url += "%s/" % bug_uuid
     return turbogears.url(bug_url)
 
-def bug_list_url(project_id, show_closed=False):
+def bug_list_url(project_id, show_closed=False, search=None):
     bug_url = "/project/%s/bug/?show_closed=%s" % (project_id, 
                                                    str(show_closed))
-    return turbogears.url(bug_url)
+    if search is not None:
+        bug_url = "%s&search=%s" % (bug_url, search)
+    return turbogears.url(str(bug_url))
 
 
 class Project(PrestHandler):
index 30004fc1e50879bcf8742a1f6aec99ab12f6db50..d4d783cbc1b8a4ab96a682098a7103c7d17423ce 100644 (file)
@@ -8,6 +8,15 @@ def row_class(bug):
         return "closed"
     else:
         return ""
+
+
+def match(bug, show_closed=False, search=None):
+    if not show_closed and not bug.active:
+        return False
+    elif search is None:
+        return True
+    else:
+        return search.lower() in bug.summary.lower()
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"
     py:extends="'master.kid'">
@@ -21,13 +30,18 @@ def row_class(bug):
 <h1>Bug list for ${project_name}</h1>
 <table>
 <tr><td>ID</td><td>Status</td><td>Severity</td><td>Assigned To</td><td>Comments</td><td>Summary</td></tr>
-<div py:for="bug in bugs" py:strip="True"><tr class="${row_class(bug)}" py:if="bug.active or show_closed"><td><a href="${bug_url(project_id, bug.uuid)}">${unique_name(bug, bugs[:])}</a></td><td>${bug.status}</td><td>${bug.severity}</td><td>${people.get(bug.assigned, bug.assigned)}</td><td>${len(list(bug.iter_comment_ids()))}</td><td>${bug.summary}</td></tr>
+<div py:for="bug in bugs" py:strip="True"><tr class="${row_class(bug)}" py:if="match(bug, show_closed, search)"><td><a href="${bug_url(project_id, bug.uuid)}">${unique_name(bug, bugs[:])}</a></td><td>${bug.status}</td><td>${bug.severity}</td><td>${people.get(bug.assigned, bug.assigned)}</td><td>${len(list(bug.iter_comment_ids()))}</td><td>${bug.summary}</td></tr>
 </div>
 </table>
 <a href="${project_url()}">Project list</a>
-<a href="${bug_list_url(project_id, not show_closed)}">Toggle closed</a>
+<a href="${bug_list_url(project_id, not show_closed, search)}">Toggle closed</a>
 <form action="${bug_list_url(project_id)}" method="post">
 <input type="submit" name="action" value="New bug"/>
 </form>
+<form action="${bug_list_url(project_id)}" method="get">
+<input type="hidden" name="show_closed" value="False" />
+<input name="search" />
+<input type="submit" name="action" value="Search" />
+</form>
 </body>
 </html>