diff --git a/aldryn_blog/forms.py b/aldryn_blog/forms.py index e00159e..ba5f842 100644 --- a/aldryn_blog/forms.py +++ b/aldryn_blog/forms.py @@ -24,7 +24,7 @@ class PostTagWidget(django_select2.widgets.Select2Mixin, taggit.forms.TagWidget) def __init__(self, *args, **kwargs): options = kwargs.get('select2_options', {}) options['tags'] = list(taggit.models.Tag.objects.values_list('name', flat=True)) - options['tokenSeparators'] = [',',] + options['tokenSeparators'] = [','] kwargs['select2_options'] = options super(PostTagWidget, self).__init__(*args, **kwargs) diff --git a/aldryn_blog/models.py b/aldryn_blog/models.py index a37de6e..bdc6eec 100644 --- a/aldryn_blog/models.py +++ b/aldryn_blog/models.py @@ -201,7 +201,9 @@ def get_author_slug(self): class LatestEntriesPlugin(CMSPlugin): latest_entries = models.IntegerField(default=5, help_text=_('The number of latests entries to be displayed.')) - tags = models.ManyToManyField('taggit.Tag', blank=True, help_text=_('Show only the blog posts tagged with chosen tags.')) + tags = models.ManyToManyField( + 'taggit.Tag', blank=True, help_text=_('Show only the blog posts tagged with chosen tags.') + ) def __unicode__(self): """ @@ -226,7 +228,8 @@ def get_authors(self): def force_language(sender, instance, **kwargs): - if issubclass(sender, CMSPlugin) and instance.placeholder and instance.placeholder.slot == 'aldryn_blog_post_content': + if issubclass(sender, CMSPlugin) and instance.placeholder \ + and instance.placeholder.slot == 'aldryn_blog_post_content': instance.language = settings.ALDRYN_BLOG_PLUGIN_LANGUAGE diff --git a/aldryn_blog/search_indexes.py b/aldryn_blog/search_indexes.py index 415c439..ea0e620 100644 --- a/aldryn_blog/search_indexes.py +++ b/aldryn_blog/search_indexes.py @@ -27,7 +27,7 @@ def prepare_pub_date(self, obj): def get_index_queryset(self, language): queryset = self.get_model().published.all() - return queryset.filter(Q(language=language)|Q(language__isnull=True)) + return queryset.filter(Q(language=language) | Q(language__isnull=True)) def get_model(self): return Post @@ -38,7 +38,7 @@ def get_search_data(self, obj, language, request): plugins = obj.content.cmsplugin_set.filter(language=language) for base_plugin in plugins: instance, plugin_type = base_plugin.get_plugin_instance() - if not instance is None: + if instance is not None: content = strip_tags(instance.render_plugin(context=RequestContext(request))) text_bits.append(content) return ' '.join(text_bits) diff --git a/aldryn_blog/templatetags/__init__.py b/aldryn_blog/templatetags/__init__.py index 633f866..40a96af 100644 --- a/aldryn_blog/templatetags/__init__.py +++ b/aldryn_blog/templatetags/__init__.py @@ -1,2 +1 @@ # -*- coding: utf-8 -*- - diff --git a/aldryn_blog/urls.py b/aldryn_blog/urls.py index 8be548b..de3a092 100644 --- a/aldryn_blog/urls.py +++ b/aldryn_blog/urls.py @@ -15,7 +15,8 @@ url(r'^(?P\d{4})/$', ArchiveView.as_view(), name='archive-year'), url(r'^(?P\d{4})/(?P\d{1,2})/$', ArchiveView.as_view(), name='archive-month'), url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', ArchiveView.as_view(), name='archive-day'), - url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$', PostDetailView.as_view(), name='post-detail'), + url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$', + PostDetailView.as_view(), name='post-detail'), url(r'^category/$', CategoryListView.as_view(), name='category-list'), url(r'^category/(?P[-\w]+)/$', CategoryPostListView.as_view(), name='category-posts'), url(r'^category/(?P[-\w]+)/feed/$', CategoryFeed(), name='category-posts-feed'), diff --git a/aldryn_blog/utils.py b/aldryn_blog/utils.py index 7f093bd..ee38a0c 100644 --- a/aldryn_blog/utils.py +++ b/aldryn_blog/utils.py @@ -10,7 +10,8 @@ def get_blog_languages(): from .models import Post - return Post.objects.exclude(language__isnull=True).order_by('language').values_list('language', flat=True).distinct() + return Post.objects.exclude(language__isnull=True).order_by('language').values_list( + 'language', flat=True).distinct() def get_blog_authors(coauthors=True): @@ -24,7 +25,8 @@ def get_blog_authors(coauthors=True): if coauthors: coauthors_filters = ( - (Q(aldryn_blog_coauthors__publication_end__isnull=True) | Q(aldryn_blog_coauthors__publication_end__gte=now)) + (Q(aldryn_blog_coauthors__publication_end__isnull=True) | + Q(aldryn_blog_coauthors__publication_end__gte=now)) & (Q(aldryn_blog_coauthors__language=get_language()) | Q(aldryn_blog_coauthors__language__isnull=True)) & Q(aldryn_blog_coauthors__publication_start__lte=now) ) @@ -49,7 +51,7 @@ def generate_slugs(users): if not _slug: slug = user.get_username() - elif not _slug in slugs: + elif _slug not in slugs: slug = _slug else: @@ -86,7 +88,8 @@ def get_slug_for_user(find_user): def get_slug_in_language(record, language): if not record: return None - if hasattr(record, record._meta.translations_cache) and language == record.language_code: # possibly no need to hit db, try cache + # possibly no need to hit db, try cache + if hasattr(record, record._meta.translations_cache) and language == record.language_code: return record.lazy_translation_getter('slug') else: # hit db try: