Commit e1694f210a0394f62f334bbd7b5cb12fc575006e
1 parent
e0562676
Exists in
master
and in
7 other branches
Moved generic filters from search
- Moved mailing lists filters to super_archives - Moved users filters to accounts Signed-off-by: Gustavo Jaruga <darksshades@gmail.com> Signed-off-by: Matheus Faria <matheus.sousa.faria@gmail.com>
Showing
4 changed files
with
48 additions
and
45 deletions
Show diff stats
... | ... | @@ -0,0 +1,24 @@ |
1 | +from django.utils.translation import ugettext as _ | |
2 | + | |
3 | + | |
4 | +def get_filters(request): | |
5 | + return { | |
6 | + 'user': { | |
7 | + 'name': _(u'User'), | |
8 | + 'icon': 'user', | |
9 | + 'fields': ( | |
10 | + ( | |
11 | + 'username', | |
12 | + _(u'Username'), | |
13 | + request.get('username'), | |
14 | + ), | |
15 | + ('name', _(u'Name'), request.get('name')), | |
16 | + ( | |
17 | + 'institution', | |
18 | + _(u'Institution'), | |
19 | + request.get('institution'), | |
20 | + ), | |
21 | + ('role', _(u'Role'), request.get('role')) | |
22 | + ), | |
23 | + }, | |
24 | + } | ... | ... |
colab/search/tests.py
... | ... | @@ -77,10 +77,6 @@ class SearchViewTest(TestCase): |
77 | 77 | |
78 | 78 | request = self.client.get('/search/?q=') |
79 | 79 | |
80 | - value = [ | |
81 | - ('plugin_name', 'PluginData', 'plugin_icon'), | |
82 | - ('user', u'User', 'user'), | |
83 | - ('thread', u'Discussion', 'envelope') | |
84 | - ] | |
80 | + value = [('plugin_name', 'PluginData', 'plugin_icon')] | |
85 | 81 | |
86 | 82 | self.assertEqual(request.context['filters_options'], value) | ... | ... |
colab/search/views.py
1 | 1 | # -*- coding:utf-8 -*- |
2 | 2 | |
3 | 3 | from django.conf import settings |
4 | -from django.utils.translation import ugettext as _ | |
5 | 4 | |
6 | 5 | from haystack.views import SearchView |
7 | 6 | from colab.plugins.utils import filters_importer |
8 | -from colab.super_archives.models import MailingList | |
9 | 7 | |
10 | 8 | |
11 | 9 | class ColabSearchView(SearchView): |
... | ... | @@ -15,43 +13,6 @@ class ColabSearchView(SearchView): |
15 | 13 | self.request.LANGUAGE_CODE, (None, None) |
16 | 14 | ) |
17 | 15 | |
18 | - types = { | |
19 | - 'thread': { | |
20 | - 'name': _(u'Discussion'), | |
21 | - 'icon': 'envelope', | |
22 | - 'fields': ( | |
23 | - ('author', _(u'Author'), self.request.GET.get('author')), | |
24 | - ( | |
25 | - 'list', | |
26 | - _(u'Mailinglist'), | |
27 | - self.request.GET.getlist('list'), | |
28 | - 'list', | |
29 | - [(v, v) for v in MailingList.objects.values_list( | |
30 | - 'name', flat=True)] | |
31 | - ), | |
32 | - ), | |
33 | - }, | |
34 | - } | |
35 | - | |
36 | - types['user'] = { | |
37 | - 'name': _(u'User'), | |
38 | - 'icon': 'user', | |
39 | - 'fields': ( | |
40 | - ( | |
41 | - 'username', | |
42 | - _(u'Username'), | |
43 | - self.request.GET.get('username'), | |
44 | - ), | |
45 | - ('name', _(u'Name'), self.request.GET.get('name')), | |
46 | - ( | |
47 | - 'institution', | |
48 | - _(u'Institution'), | |
49 | - self.request.GET.get('institution'), | |
50 | - ), | |
51 | - ('role', _(u'Role'), self.request.GET.get('role')) | |
52 | - ), | |
53 | - } | |
54 | - | |
55 | 16 | try: |
56 | 17 | type_chosen = self.form.cleaned_data.get('type') |
57 | 18 | except AttributeError: |
... | ... | @@ -65,7 +26,7 @@ class ColabSearchView(SearchView): |
65 | 26 | size_chosen = self.request.GET.get('size') |
66 | 27 | used_by_chosen = self.request.GET.get('used_by') |
67 | 28 | |
68 | - types.update(filters_importer.import_plugin_filters(self.request)) | |
29 | + types = filters_importer.import_plugin_filters(self.request.GET) | |
69 | 30 | |
70 | 31 | filters_options = [(k, v['name'], v['icon']) |
71 | 32 | for (k, v) in types.iteritems()] | ... | ... |
... | ... | @@ -0,0 +1,22 @@ |
1 | +from django.utils.translation import ugettext as _ | |
2 | +from colab.super_archives.models import MailingList | |
3 | + | |
4 | + | |
5 | +def get_filters(request): | |
6 | + return { | |
7 | + 'thread': { | |
8 | + 'name': _(u'Discussion'), | |
9 | + 'icon': 'envelope', | |
10 | + 'fields': ( | |
11 | + ('author', _(u'Author'), request.get('author')), | |
12 | + ( | |
13 | + 'list', | |
14 | + _(u'Mailinglist'), | |
15 | + request.get('list'), | |
16 | + 'list', | |
17 | + [(v, v) for v in MailingList.objects.values_list( | |
18 | + 'name', flat=True)] | |
19 | + ), | |
20 | + ), | |
21 | + }, | |
22 | + } | ... | ... |