Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
pep8 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrumalo committed Sep 24, 2014
1 parent 23ee0a4 commit c47af07
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aldryn_blog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions aldryn_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions aldryn_blog/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
1 change: 0 additions & 1 deletion aldryn_blog/templatetags/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-

3 changes: 2 additions & 1 deletion aldryn_blog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
url(r'^(?P<year>\d{4})/$', ArchiveView.as_view(), name='archive-year'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/$', ArchiveView.as_view(), name='archive-month'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', ArchiveView.as_view(), name='archive-day'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$', PostDetailView.as_view(), name='post-detail'),
url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<slug>\w[-\w]*)/$',
PostDetailView.as_view(), name='post-detail'),
url(r'^category/$', CategoryListView.as_view(), name='category-list'),
url(r'^category/(?P<category>[-\w]+)/$', CategoryPostListView.as_view(), name='category-posts'),
url(r'^category/(?P<category>[-\w]+)/feed/$', CategoryFeed(), name='category-posts-feed'),
Expand Down
11 changes: 7 additions & 4 deletions aldryn_blog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
)
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c47af07

Please sign in to comment.