From 1d7c2fa461d65424b208f6722ca20e539fc9a62f Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Mon, 3 Aug 2015 20:43:50 -0300 Subject: [PATCH] Fixed flake8 checks --- colab/plugins/noosfero/data_api.py | 4 ++-- colab/plugins/noosfero/search_indexes.py | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/colab/plugins/noosfero/data_api.py b/colab/plugins/noosfero/data_api.py index fdfd987..6fc9d7d 100644 --- a/colab/plugins/noosfero/data_api.py +++ b/colab/plugins/noosfero/data_api.py @@ -9,7 +9,7 @@ from django.conf import settings from django.db.models.fields import DateTimeField from colab.plugins.noosfero.models import (NoosferoArticle, NoosferoCommunity, - NoosferoCategory) + NoosferoCategory) from colab.plugins.utils.proxy_data_api import ProxyDataAPI LOGGER = logging.getLogger('colab.plugin.debug') @@ -76,7 +76,7 @@ class NoosferoDataAPI(ProxyDataAPI): self.fill_object_data(element, community) community.save() - if element.has_key('categories'): + if 'categories' in element: for category_json in element["categories"]: category = NoosferoCategory.objects.get_or_create( id=category_json["id"], name=category_json["name"])[0] diff --git a/colab/plugins/noosfero/search_indexes.py b/colab/plugins/noosfero/search_indexes.py index 4a57657..7b5e60a 100644 --- a/colab/plugins/noosfero/search_indexes.py +++ b/colab/plugins/noosfero/search_indexes.py @@ -30,8 +30,7 @@ class NoosferoCommunityIndex(indexes.SearchIndex, indexes.Indexable): category = indexes.MultiValueField() def prepare_category(self, obj): - return [category.name for category in \ - obj.categories.all()] + return obj.categories.values_list('name', flat=True) def prepare_icon_name(self, obj): return u'file' @@ -62,8 +61,7 @@ class NoosferoArticleIndex(indexes.SearchIndex, indexes.Indexable): return NoosferoArticle def prepare_category(self, obj): - return [category.name for category in \ - obj.categories.all()] + return obj.categories.values_list('name', flat=True) def prepare_icon_name(self, obj): return u'file' -- libgit2 0.21.2