Fix Autocomplete
Closes #273 (closed)
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
Closes #273 (closed)
15 | def choice_html(self, choice): | |
17 | def highlight(self, field, q, none_wo_match=True): | |
18 | if not field: | |
19 | return None | |
16 | 20 | try: |
17 | name = choice.get_full_name() | |
18 | except AttributeError: | |
19 | name = _('group') | |
20 | if name: | |
21 | name = u'(%s)' % name | |
21 | match = field.lower().index(q.lower()) | |
22 | except ValueError: | |
23 | match = None | |
24 | if q and match is not None: | |
25 | match_end = match + len(q) | |
26 | return (field[:match] + '<span class="autocomplete-hl">' + | |
Please
register
or
sign in
to reply
|
29 | return None if none_wo_match else field | |
30 | ||
31 | def choice_displayed_text(self, choice): | |
32 | q = unicode(self.request.GET.get('q', '')) | |
33 | name = self.highlight(unicode(choice), q, False) | |
34 | if isinstance(choice, User): | |
35 | extra_fields = [self.highlight(choice.get_full_name(), q, False), | |
36 | self.highlight(choice.email, q)] | |
37 | try: | |
38 | extra_fields.append(self.highlight(choice.profile.org_id, q)) | |
39 | except Profile.DoesNotExist: | |
40 | pass | |
41 | return '%s (%s)' % (name, ', '.join(f for f in extra_fields | |
42 | if f)) | |
43 | else: | |
44 | return '%s (%s)' % (name, _('group')) | |
|
+1