summaryrefslogtreecommitdiff
path: root/patchwork/filters.py
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2014-09-27 23:44:25 +0100
committerStephen Finucane <stephen.finucane@intel.com>2015-11-05 03:51:38 +0000
commit73a4f9a414239bdee5a5d5b4bb490538bebd2c48 (patch)
treeba2e168b092dc622abd772105cd3d67e5fd01a1f /patchwork/filters.py
parent17bca7243d7ec435c0e10f89d946d3e8e88a9397 (diff)
downloadpatchwork-73a4f9a414239bdee5a5d5b4bb490538bebd2c48.tar
patchwork-73a4f9a414239bdee5a5d5b4bb490538bebd2c48.tar.gz
filters: Rewrite the submitter autocompletion code
We now have a nice(r) autocompletion widget that will popup the list of options directly underneath the input fild. A few changes are done in this commit that couldn't be split any further: - Use jQuery's $.ajax() for the completion query - Use the application/json content type on the completion answer to allow jQuery to directly create an object from it instead of giving back a string (because of the text/plain content type) - Crafted more logical objects in the json answer ie all properties are at the same level instead of the default queryset serializer that put the object fields in a 'field' sub-object. - Use selectize.js for the autocompletion widget logic A slight change in behaviour is that we now don't allow "free form" submitter search, ie we need a valid completion to search with that specific person (through its primary key). I didn't remove the backend logic that allows the "free form" mechanism, but maybe we should. v2: Squash the unit tests fixes into this patch (Jeremy Kerr) Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'patchwork/filters.py')
-rw-r--r--patchwork/filters.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/patchwork/filters.py b/patchwork/filters.py
index 3f8bd3e..db671ff 100644
--- a/patchwork/filters.py
+++ b/patchwork/filters.py
@@ -87,6 +87,11 @@ class SubmitterFilter(Filter):
self.person = None
self.person_match = None
submitter_id = None
+
+ str = str.strip()
+ if str == '':
+ return
+
try:
submitter_id = int(str)
except ValueError:
@@ -128,15 +133,8 @@ class SubmitterFilter(Filter):
return ''
def _form(self):
- name = ''
- if self.person:
- name = self.person.name
- return mark_safe(('<input onKeyUp="submitter_field_change(this)" ' +
- 'name="submitter" id="submitter_input" ' +
- 'class="form-control"' +
- 'value="%s">' % escape(name)) +
- '<select id="submitter_select" ' +
- 'disabled="true"></select>')
+ return mark_safe(('<input type="text" name="submitter" ' + \
+ 'id="submitter_input" class="form-control">'))
def key(self):
if self.person: