[Python-checkins] r82976 - in tracker: instances/python-dev/html/issue.search.html instances/python-dev/html/page.html roundup-src/roundup/cgi/templating.py
ezio.melotti
python-checkins at python.org
Mon Jul 19 19:19:04 CEST 2010
Author: ezio.melotti
Date: Mon Jul 19 19:19:02 2010
New Revision: 82976
Log:
#262: Ignore attachments content while searching. Also add a checkbox to enable/disable the option in the search page. Original patch by Daniel Diniz.
Modified:
tracker/instances/python-dev/html/issue.search.html
tracker/instances/python-dev/html/page.html
tracker/roundup-src/roundup/cgi/templating.py
Modified: tracker/instances/python-dev/html/issue.search.html
==============================================================================
--- tracker/instances/python-dev/html/issue.search.html (original)
+++ tracker/instances/python-dev/html/issue.search.html Mon Jul 19 19:19:02 2010
@@ -42,6 +42,15 @@
<td> </td>
</tr>
+<tr tal:define="name string:ignore">
+ <th i18n:translate="">Ignore attachments:</th>
+ <td><input type="checkbox" checked="checked"
+ name="ignore" id="ignore" value="file:content"/></td>
+ <td> </td>
+ <td> </td>
+ <td> </td>
+</tr>
+
<tr tal:define="name string:title">
<th i18n:translate="">Title:</th>
<td metal:use-macro="search_input"></td>
Modified: tracker/instances/python-dev/html/page.html
==============================================================================
--- tracker/instances/python-dev/html/page.html (original)
+++ tracker/instances/python-dev/html/page.html Mon Jul 19 19:19:02 2010
@@ -42,6 +42,7 @@
<input type="hidden" name="@sort" value="-activity" />
<input type="hidden" name="@filter" value="status"/>
<input type="hidden" name="@action" value="searchid"/>
+ <input type="hidden" name="ignore" value="file:content"/>
<input tal:attributes="value python:request.form.getvalue('@search_text') or nothing;"
class="input-text" id="search-text" name="@search_text" size="10" />
<input type="submit" id="submit" value="search" name="submit"
Modified: tracker/roundup-src/roundup/cgi/templating.py
==============================================================================
--- tracker/roundup-src/roundup/cgi/templating.py (original)
+++ tracker/roundup-src/roundup/cgi/templating.py Mon Jul 19 19:19:02 2010
@@ -2658,12 +2658,32 @@
</script>
"""%self.base
- def batch(self):
+ def get_ignored(self, to_ignore='ignore'):
+ """ Return a dict of '(class, property):None' items to ignore
+
+ 'ignore' is built from a form value, its name is passed as to_ignore
+ and it follows a 'class1:prop1,class2:prop2' format
+ """
+ ignore = {}
+ if not to_ignore or to_ignore not in self.form:
+ return ignore
+ for clprop in self.form[to_ignore].value.split(','):
+ clprop = clprop.strip()
+ if clprop.count(':') != 1:
+ continue
+ klass, prop = [kp.strip() for kp in clprop.split(':')]
+ if not klass or not prop:
+ continue
+ ignore[(klass, prop)] = None
+ return ignore
+
+ def batch(self, to_ignore='ignore'):
""" Return a batch object for results from the "current search"
"""
filterspec = self.filterspec
sort = self.sort
group = self.group
+ ignore = self.get_ignored(to_ignore)
# get the list of ids we're batching over
klass = self.client.db.getclass(self.classname)
@@ -2672,7 +2692,7 @@
[w.upper().encode("utf-8", "replace") for w in re.findall(
r'(?u)\b\w{2,25}\b',
unicode(self.search_text, "utf-8", "replace")
- )], klass)
+ )], klass, ignore)
else:
matches = None
More information about the Python-checkins
mailing list