def _search(self, session_id, wfile, values): sort_by = values.pop("sort_by", "bug_id") order = values.pop("order", "ascending") criteria = {} columns = ["bug_id", "title"] for key, value in values.items(): if value: if key.endswith("_column"): columns.append(key[:-len("_column")]) else: criteria[key] = value search = application.Search(columns, sort_by, order, **criteria) try: self.application.search(session_id, search) templates.title(wfile, "Search result (%d)" % len(search.rows)) self._pretty_print_search(wfile, criteria, values) if search.rows: url = lib.join_url(self.path, values) templates.table_of_bugs(wfile, url, search) else: templates.paragraph( wfile, "No bugs match these criteria!") except application.InvalidSearchException, e: templates.title(wfile, "Invalid search criteria!") templates.paragraph( wfile, "Use the back-button of your browser " "to correct your search.") templates.paragraph( wfile, "Malformed regex expressions are a probable cause. " "For example, mismatched parentheses.")
def _show_new(self, session_id, wfile, sort_by, order): if not sort_by: sort_by = "category" if not order: order = "ascending" search = application.Search( ("bug_id", "category", "reported_in", "title"), sort_by, order, status="new") self.application.search(session_id, search) templates.title(wfile, "All new bugs (%d)" % len(search.rows)) if search.rows: templates.bullets( wfile, "Bugs that are new and need to be reviewed.") url = lib.join_url(self.path, {"status": "new"}) templates.table_of_bugs(wfile, url, search) else: templates.paragraph(wfile, "There are no new bugs.")
def test_table_of_bugs(self): """Check table of bugs""" class MockRow: bug_id = "334" status = "new" titles = ["title1", "title2"] variables = ["variable1", "variable2"] sorted_by = "variable2" ordered = "descending" def get(self): return [("variable1", "value1"), ("variable2", "value2")] wfile = self.get_wfile() templates.table_of_bugs(wfile, "a path", [MockRow()]) self.assert_(self.is_well_formed(wfile))
def _show_closed(self, session_id, wfile, sort_by, order): if not sort_by: sort_by = "tested_ok_in" if not order: order = "ascending" search = application.Search( ("bug_id", "priority", "resolution", "category", "tested_ok_in", "title"), sort_by, order, status="closed") self.application.search(session_id, search) templates.title(wfile, "All closed bugs (%d)" % len(search.rows)) if search.rows: templates.bullets( wfile, "Bugs which require no further action.") url = lib.join_url(self.path, {"status": "closed"}) templates.table_of_bugs(wfile, url, search) else: templates.paragraph(wfile, "There are no closed bugs.")
def _show_reviewed(self, session_id, wfile, sort_by, order): if not sort_by: sort_by = "priority" if not order: order = "descending" search = application.Search( ("bug_id", "priority", "category", "reported_in", "title"), sort_by, order, status="reviewed") self.application.search(session_id, search) templates.title(wfile, "All reviewed bugs (%d)" % len(search.rows)) if search.rows: templates.bullets( wfile, "Bugs that are ready to be scheduled.") url = lib.join_url(self.path, {"status": "reviewed"}) templates.table_of_bugs(wfile, url, search) else: templates.paragraph(wfile, "There are no bugs in the reviewed state.")