Commit 1d7c2fa461d65424b208f6722ca20e539fc9a62f
1 parent
226f9140
Exists in
master
and in
31 other branches
Fixed flake8 checks
Showing
2 changed files
with
4 additions
and
6 deletions
Show diff stats
colab/plugins/noosfero/data_api.py
... | ... | @@ -9,7 +9,7 @@ from django.conf import settings |
9 | 9 | from django.db.models.fields import DateTimeField |
10 | 10 | |
11 | 11 | from colab.plugins.noosfero.models import (NoosferoArticle, NoosferoCommunity, |
12 | - NoosferoCategory) | |
12 | + NoosferoCategory) | |
13 | 13 | from colab.plugins.utils.proxy_data_api import ProxyDataAPI |
14 | 14 | |
15 | 15 | LOGGER = logging.getLogger('colab.plugin.debug') |
... | ... | @@ -76,7 +76,7 @@ class NoosferoDataAPI(ProxyDataAPI): |
76 | 76 | self.fill_object_data(element, community) |
77 | 77 | community.save() |
78 | 78 | |
79 | - if element.has_key('categories'): | |
79 | + if 'categories' in element: | |
80 | 80 | for category_json in element["categories"]: |
81 | 81 | category = NoosferoCategory.objects.get_or_create( |
82 | 82 | id=category_json["id"], name=category_json["name"])[0] | ... | ... |
colab/plugins/noosfero/search_indexes.py
... | ... | @@ -30,8 +30,7 @@ class NoosferoCommunityIndex(indexes.SearchIndex, indexes.Indexable): |
30 | 30 | category = indexes.MultiValueField() |
31 | 31 | |
32 | 32 | def prepare_category(self, obj): |
33 | - return [category.name for category in \ | |
34 | - obj.categories.all()] | |
33 | + return obj.categories.values_list('name', flat=True) | |
35 | 34 | |
36 | 35 | def prepare_icon_name(self, obj): |
37 | 36 | return u'file' |
... | ... | @@ -62,8 +61,7 @@ class NoosferoArticleIndex(indexes.SearchIndex, indexes.Indexable): |
62 | 61 | return NoosferoArticle |
63 | 62 | |
64 | 63 | def prepare_category(self, obj): |
65 | - return [category.name for category in \ | |
66 | - obj.categories.all()] | |
64 | + return obj.categories.values_list('name', flat=True) | |
67 | 65 | |
68 | 66 | def prepare_icon_name(self, obj): |
69 | 67 | return u'file' | ... | ... |