pep8
authorJan Szejko <janek37@gmail.com>
Tue, 8 Nov 2016 14:52:49 +0000 (15:52 +0100)
committerJan Szejko <janek37@gmail.com>
Tue, 8 Nov 2016 14:52:49 +0000 (15:52 +0100)
14 files changed:
migdal/__init__.py
migdal/admin.py
migdal/api.py
migdal/fields.py
migdal/forms.py
migdal/helpers.py
migdal/models.py
migdal/search_indexes.py
migdal/sitemap.py
migdal/templatetags/migdal_tags.py
migdal/tests.py
migdal/urls.py
migdal/views.py
setup.py

index fe90406..dda9569 100644 (file)
@@ -27,26 +27,24 @@ class Settings(AppSettings):
 
     MAIN_PAGE_ENTRY = None
 
 
     MAIN_PAGE_ENTRY = None
 
-    TYPES_DICT = None
     def _more_TYPES_DICT(self, value):
         return dict((t.db, t) for t in self.TYPES)
     def _more_TYPES_DICT(self, value):
         return dict((t.db, t) for t in self.TYPES)
+    TYPES_DICT = None
 
 
-    TYPES_ON_MAIN = None
     def _more_TYPES_ON_MAIN(self, value):
         return tuple(t.db for t in self.TYPES if t.on_main)
     def _more_TYPES_ON_MAIN(self, value):
         return tuple(t.db for t in self.TYPES if t.on_main)
+    TYPES_ON_MAIN = None
 
 
-    TYPES_PROMOTABLE = None
     def _more_TYPES_PROMOTABLE(self, value):
         return tuple(t.db for t in self.TYPES if t.promotable)
     def _more_TYPES_PROMOTABLE(self, value):
         return tuple(t.db for t in self.TYPES if t.promotable)
+    TYPES_PROMOTABLE = None
 
 
-    OBLIGATORY_LANGUAGES = None
     def _more_OBLIGATORY_LANGUAGES(self, value):
     def _more_OBLIGATORY_LANGUAGES(self, value):
-        return value or tuple(lang for lang in settings.LANGUAGES
-                        if lang[0] == settings.LANGUAGE_CODE)
+        return value or tuple(lang for lang in settings.LANGUAGES if lang[0] == settings.LANGUAGE_CODE)
+    OBLIGATORY_LANGUAGES = None
 
 
-    OPTIONAL_LANGUAGES = None
     def _more_OPTIONAL_LANGUAGES(self, value):
     def _more_OPTIONAL_LANGUAGES(self, value):
-        return tuple(lang for lang in settings.LANGUAGES
-                        if lang not in self.OBLIGATORY_LANGUAGES)
+        return tuple(lang for lang in settings.LANGUAGES if lang not in self.OBLIGATORY_LANGUAGES)
+    OPTIONAL_LANGUAGES = None
 
 app_settings = Settings('MIGDAL')
 
 app_settings = Settings('MIGDAL')
index 8ed11ea..6d4bffe 100644 (file)
@@ -78,16 +78,15 @@ def filtered_entry_admin(typ):
                 for lang_code, lang_name in settings.LANGUAGES
             ]) 
 
                 for lang_code, lang_name in settings.LANGUAGES
             ]) 
 
-        list_display = translated_fields(('title',),
-                            app_settings.OBLIGATORY_LANGUAGES) + \
-                ('date', 'author') + \
-                _promo_if_necessary + \
-                ('in_stream', 'first_published_at',) + \
-                translated_fields(('published_at',)) + \
-                translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
+        list_display = translated_fields(('title',), app_settings.OBLIGATORY_LANGUAGES) + \
+            ('date', 'author') + \
+            _promo_if_necessary + \
+            ('in_stream', 'first_published_at',) + \
+            translated_fields(('published_at',)) + \
+            translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
         list_filter = _promo_if_necessary + \
         list_filter = _promo_if_necessary + \
-                translated_fields(('published',)) + \
-                translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
+            translated_fields(('published',)) + \
+            translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
         inlines = (AttachmentInline,)
         search_fields = ('title_pl', 'title_en')
     return EntryAdmin
         inlines = (AttachmentInline,)
         search_fields = ('title_pl', 'title_en')
     return EntryAdmin
index abd3b21..fd89352 100644 (file)
@@ -2,14 +2,12 @@
 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
-from itertools import chain
 from migdal.models import Entry
 from migdal import app_settings
 from django.utils.translation import get_language
 
 
 from migdal.models import Entry
 from migdal import app_settings
 from django.utils.translation import get_language
 
 
-def entry_list(entry_type=None, category=None, promobox=False,
-            for_feed=False):
+def entry_list(entry_type=None, category=None, promobox=False, for_feed=False):
     lang = get_language()
     object_list = Entry.objects.filter(**{"published_%s" % lang: True})
 
     lang = get_language()
     object_list = Entry.objects.filter(**{"published_%s" % lang: True})
 
@@ -26,13 +24,11 @@ def entry_list(entry_type=None, category=None, promobox=False,
     if category:
         object_list = object_list.filter(categories=category)
 
     if category:
         object_list = object_list.filter(categories=category)
 
-    if promobox:
-        promo = list(object_list.filter(promo=True)[:promobox])
-        #object_list = object_list.exclude(pk__in=[p.pk for p in promo])
-
     object_list = object_list.filter(in_stream=True)
 
     if promobox:
     object_list = object_list.filter(in_stream=True)
 
     if promobox:
+        promo = list(object_list.filter(promo=True)[:promobox])
+        # object_list = object_list.exclude(pk__in=[p.pk for p in promo])
         object_list.promobox = promo
 
     return object_list
         object_list.promobox = promo
 
     return object_list
index 843c44e..c9fe7fc 100644 (file)
@@ -4,15 +4,16 @@
 #
 from django.db import models
 
 #
 from django.db import models
 
+
 class SlugNullField(models.SlugField):
     description = "SlugField that stores NULL instead of blank value."
 
 class SlugNullField(models.SlugField):
     description = "SlugField that stores NULL instead of blank value."
 
-    def to_python(self, value, **kwargs):
-        value = super(SlugNullField, self).to_python(value, **kwargs)
+    def to_python(self, value):
+        value = super(SlugNullField, self).to_python(value)
         return value if value is not None else u""
 
     def get_prep_value(self, value, **kwargs):
         return value if value is not None else u""
 
     def get_prep_value(self, value, **kwargs):
-        value = super(SlugNullField, self).get_prep_value(value, **kwargs)
+        value = super(SlugNullField, self).get_prep_value(value)
         return value or None
 
 
         return value or None
 
 
index 63eba61..649980c 100644 (file)
@@ -7,7 +7,7 @@ from django.core.mail import mail_managers
 from django import forms
 from django import template
 from django.utils.translation import ugettext_lazy as _, get_language
 from django import forms
 from django import template
 from django.utils.translation import ugettext_lazy as _, get_language
-from fnpdjango.utils.text.slughifi import slughifi
+from slugify import slugify
 from migdal.models import Entry
 from migdal import app_settings
 
 from migdal.models import Entry
 from migdal import app_settings
 
@@ -18,8 +18,7 @@ def get_submit_form(*args, **kwargs):
     class SubmitForm(forms.ModelForm):
         class Meta:
             model = Entry
     class SubmitForm(forms.ModelForm):
         class Meta:
             model = Entry
-            fields = ['title_%s' % lang, 'lead_%s' % lang,
-                'author', 'author_email', 'categories']
+            fields = ['title_%s' % lang, 'lead_%s' % lang, 'author', 'author_email', 'categories']
             required = ['title_%s' % lang]
 
         def __init__(self, *args, **kwargs):
             required = ['title_%s' % lang]
 
         def __init__(self, *args, **kwargs):
@@ -34,7 +33,7 @@ def get_submit_form(*args, **kwargs):
         def clean(self):
             data = super(SubmitForm, self).clean()
             data['type'] = app_settings.TYPE_SUBMIT
         def clean(self):
             data = super(SubmitForm, self).clean()
             data['type'] = app_settings.TYPE_SUBMIT
-            orig_slug = slughifi(data.get('title_%s' % lang, ''))[:47]
+            orig_slug = slugify(data.get('title_%s' % lang, ''))[:47]
             slug = orig_slug
             number = 2
             while Entry.objects.filter(**{'slug_%s' % lang: slug}).exists():
             slug = orig_slug
             number = 2
             while Entry.objects.filter(**{'slug_%s' % lang: slug}).exists():
@@ -54,7 +53,8 @@ def get_submit_form(*args, **kwargs):
                 setattr(entry, f, self.cleaned_data[f])
             entry.save()
             entry = super(SubmitForm, self).save(*args, **kwargs)
                 setattr(entry, f, self.cleaned_data[f])
             entry.save()
             entry = super(SubmitForm, self).save(*args, **kwargs)
-            mail_managers(u"Nowy wpis",
+            mail_managers(
+                u"Nowy wpis",
                 template.loader.get_template(
                     'migdal/mail/manager_new_entry.txt').render(
                         template.Context({
                 template.loader.get_template(
                     'migdal/mail/manager_new_entry.txt').render(
                         template.Context({
@@ -62,4 +62,4 @@ def get_submit_form(*args, **kwargs):
                             'site': Site.objects.get_current(),
                         })))
 
                             'site': Site.objects.get_current(),
                         })))
 
-    return SubmitForm(*args, **kwargs)
\ No newline at end of file
+    return SubmitForm(*args, **kwargs)
index 8c06c16..e62333d 100644 (file)
@@ -2,9 +2,10 @@
 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 # This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
+
+
 class EntryType(object):
 class EntryType(object):
-    def __init__(self, db, slug, commentable=False, on_main=False,
-            promotable=False, categorized=False):
+    def __init__(self, db, slug, commentable=False, on_main=False, promotable=False, categorized=False):
         self.db = db
         self.slug = slug
         self.commentable = commentable
         self.db = db
         self.slug = slug
         self.commentable = commentable
index 75529d6..b3238b7 100644 (file)
@@ -5,22 +5,21 @@
 import re
 from datetime import datetime
 from django.conf import settings
 import re
 from datetime import datetime
 from django.conf import settings
-from django.contrib.comments.signals import comment_will_be_posted
 from django.contrib.sites.models import Site
 from django.core.exceptions import ValidationError
 from django.core.mail import mail_managers, send_mail
 from django.db import models
 from django.template import loader, Context
 from django.contrib.sites.models import Site
 from django.core.exceptions import ValidationError
 from django.core.mail import mail_managers, send_mail
 from django.db import models
 from django.template import loader, Context
-from django.utils.translation import get_language, ugettext_lazy as _, ugettext
+from django.utils.translation import ugettext_lazy as _, ugettext
 from django_comments_xtd.models import XtdComment
 from markupfield.fields import MarkupField
 from fnpdjango.utils.models.translation import add_translatable, tQ
 from migdal import app_settings
 from migdal.fields import SlugNullField
 
 from django_comments_xtd.models import XtdComment
 from markupfield.fields import MarkupField
 from fnpdjango.utils.models.translation import add_translatable, tQ
 from migdal import app_settings
 from migdal.fields import SlugNullField
 
+
 class Category(models.Model):
 class Category(models.Model):
-    taxonomy = models.CharField(_('taxonomy'), max_length=32,
-                    choices=app_settings.TAXONOMIES)
+    taxonomy = models.CharField(_('taxonomy'), max_length=32, choices=app_settings.TAXONOMIES)
 
     class Meta:
         verbose_name = _('category')
 
     class Meta:
         verbose_name = _('category')
@@ -31,7 +30,7 @@ class Category(models.Model):
 
     @models.permalink
     def get_absolute_url(self):
 
     @models.permalink
     def get_absolute_url(self):
-        return ('migdal_category', [self.slug])
+        return 'migdal_category', [self.slug]
 
 
 add_translatable(Category, {
 
 
 add_translatable(Category, {
@@ -46,21 +45,24 @@ class PublishedEntryManager(models.Manager):
                 tQ(published=True)
             )
 
                 tQ(published=True)
             )
 
+
 class Entry(models.Model):
 class Entry(models.Model):
-    type = models.CharField(max_length=16,
-            choices=((t.db, t.slug) for t in app_settings.TYPES),
-            db_index=True)
+    type = models.CharField(
+        max_length=16,
+        choices=((t.db, t.slug) for t in app_settings.TYPES),
+        db_index=True)
     date = models.DateTimeField(_('created at'), auto_now_add=True, db_index=True)
     changed_at = models.DateTimeField(_('changed at'), auto_now=True, db_index=True)
     author = models.CharField(_('author'), max_length=128)
     date = models.DateTimeField(_('created at'), auto_now_add=True, db_index=True)
     changed_at = models.DateTimeField(_('changed at'), auto_now=True, db_index=True)
     author = models.CharField(_('author'), max_length=128)
-    author_email = models.EmailField(_('author email'), max_length=128, null=True, blank=True,
-            help_text=_('Used only to display gravatar and send notifications.'))
+    author_email = models.EmailField(
+        _('author email'), max_length=128, null=True, blank=True,
+        help_text=_('Used only to display gravatar and send notifications.'))
     image = models.ImageField(_('image'), upload_to='entry/image/', null=True, blank=True)
     promo = models.BooleanField(_('promoted'), default=False)
     in_stream = models.BooleanField(_('in stream'), default=True)
     categories = models.ManyToManyField(Category, null=True, blank=True, verbose_name=_('categories'))
     first_published_at = models.DateTimeField(_('published at'), null=True, blank=True)
     image = models.ImageField(_('image'), upload_to='entry/image/', null=True, blank=True)
     promo = models.BooleanField(_('promoted'), default=False)
     in_stream = models.BooleanField(_('in stream'), default=True)
     categories = models.ManyToManyField(Category, null=True, blank=True, verbose_name=_('categories'))
     first_published_at = models.DateTimeField(_('published at'), null=True, blank=True)
-    canonical_url = models.URLField(_('canonical link'), null = True, blank = True)
+    canonical_url = models.URLField(_('canonical link'), null=True, blank=True)
 
     objects = models.Manager()
     published_objects = PublishedEntryManager()
 
     objects = models.Manager()
     published_objects = PublishedEntryManager()
@@ -96,7 +98,7 @@ class Entry(models.Model):
 
     @models.permalink
     def get_absolute_url(self):
 
     @models.permalink
     def get_absolute_url(self):
-        return ('migdal_entry_%s' % self.type, [self.slug])
+        return 'migdal_entry_%s' % self.type, [self.slug]
 
     def get_type(self):
         return dict(app_settings.TYPES_DICT)[self.type]
 
     def get_type(self):
         return dict(app_settings.TYPES_DICT)[self.type]
@@ -131,10 +133,12 @@ add_translatable(Entry, languages=app_settings.OPTIONAL_LANGUAGES, fields={
 add_translatable(Entry, {
     'slug': SlugNullField(unique=True, db_index=True, null=True, blank=True),
     'title': models.CharField(_('title'), max_length=255, null=True, blank=True),
 add_translatable(Entry, {
     'slug': SlugNullField(unique=True, db_index=True, null=True, blank=True),
     'title': models.CharField(_('title'), max_length=255, null=True, blank=True),
-    'lead': MarkupField(_('lead'), markup_type='textile_pl', null=True, blank=True,
-                help_text=_('Use <a href="http://textile.thresholdstate.com/">Textile</a> syntax.')),
-    'body': MarkupField(_('body'), markup_type='textile_pl', null=True, blank=True,
-                help_text=_('Use <a href="http://textile.thresholdstate.com/">Textile</a> syntax.')),
+    'lead': MarkupField(
+        _('lead'), markup_type='textile_pl', null=True, blank=True,
+        help_text=_('Use <a href="http://textile.thresholdstate.com/">Textile</a> syntax.')),
+    'body': MarkupField(
+        _('body'), markup_type='textile_pl', null=True, blank=True,
+        help_text=_('Use <a href="http://textile.thresholdstate.com/">Textile</a> syntax.')),
     'published': models.BooleanField(_('published'), default=False),
     'published_at': models.DateTimeField(_('published at'), null=True, blank=True),
 })
     'published': models.BooleanField(_('published'), default=False),
     'published_at': models.DateTimeField(_('published at'), null=True, blank=True),
 })
@@ -148,10 +152,8 @@ class Attachment(models.Model):
         return self.file.url if self.file else ''
 
 
         return self.file.url if self.file else ''
 
 
-
 def notify_new_comment(sender, instance, created, **kwargs):
 def notify_new_comment(sender, instance, created, **kwargs):
-    if (created and isinstance(instance.content_object, Entry) and
-                instance.content_object.author_email):
+    if created and isinstance(instance.content_object, Entry) and instance.content_object.author_email:
         site = Site.objects.get_current()
         mail_text = loader.get_template('migdal/mail/new_comment.txt').render(
             Context({
         site = Site.objects.get_current()
         mail_text = loader.get_template('migdal/mail/new_comment.txt').render(
             Context({
@@ -169,13 +171,15 @@ models.signals.post_save.connect(notify_new_comment, sender=XtdComment)
 def spamfilter(sender, comment, **kwargs):
     """Very simple spam filter. Just don't let any HTML links go through."""
     if re.search(r"<a\s+href=", comment.comment):
 def spamfilter(sender, comment, **kwargs):
     """Very simple spam filter. Just don't let any HTML links go through."""
     if re.search(r"<a\s+href=", comment.comment):
-        fields = (comment.user, comment.user_name, comment.user_email,
+        fields = (
+            comment.user, comment.user_name, comment.user_email,
             comment.user_url, comment.submit_date, comment.ip_address,
             comment.followup, comment.comment)
             comment.user_url, comment.submit_date, comment.ip_address,
             comment.followup, comment.comment)
-        mail_managers(u"Spam filter report",
+        mail_managers(
+            u"Spam filter report",
             (u"""This comment was turned down as SPAM: \n""" +
             (u"""This comment was turned down as SPAM: \n""" +
-            """\n%s""" * len(fields) +
-            """\n\nYou don't have to do anything.""") % fields)
+             """\n%s""" * len(fields) +
+             """\n\nYou don't have to do anything.""") % fields)
         return False
     return True
         return False
     return True
-comment_will_be_posted.connect(spamfilter)
+comment_will_be_posted.connect(spamfilter)
index d809e7b..7c2ba7f 100644 (file)
@@ -1,4 +1,7 @@
-import datetime
+# -*- coding: utf-8 -*-
+# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
 from django.conf import settings
 from haystack import indexes
 from fnpdjango.utils.models.translation import add_translatable_index, localize_field
 from django.conf import settings
 from haystack import indexes
 from fnpdjango.utils.models.translation import add_translatable_index, localize_field
@@ -6,7 +9,8 @@ from migdal.models import Entry
 
 
 class EntryIndex(indexes.SearchIndex, indexes.Indexable):
 
 
 class EntryIndex(indexes.SearchIndex, indexes.Indexable):
-    text = indexes.CharField(null=True,
+    text = indexes.CharField(
+        null=True,
         model_attr=localize_field('body', settings.LANGUAGE_CODE),
         document=True)
     date = indexes.DateTimeField(indexed=True, model_attr="date")
         model_attr=localize_field('body', settings.LANGUAGE_CODE),
         document=True)
     date = indexes.DateTimeField(indexed=True, model_attr="date")
index 7da7c38..a8ef28c 100755 (executable)
@@ -1,8 +1,13 @@
+# -*- coding: utf-8 -*-
+# This file is part of PrawoKultury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
 from django.contrib.sitemaps import Sitemap
 from django.utils.translation import override
 from .models import Entry
 from django.conf import settings
 
 from django.contrib.sitemaps import Sitemap
 from django.utils.translation import override
 from .models import Entry
 from django.conf import settings
 
+
 class MigdalSitemap(Sitemap):
     changefreq = "never"
     priority = 0.5
 class MigdalSitemap(Sitemap):
     changefreq = "never"
     priority = 0.5
index c1b824c..5cc64d2 100644 (file)
@@ -6,8 +6,7 @@ from django_comments_xtd.models import XtdComment
 from django.contrib import comments
 from django import template
 from migdal import app_settings
 from django.contrib import comments
 from django import template
 from migdal import app_settings
-from migdal.models import Category, Entry
-from django.utils.translation import ugettext_lazy as _
+from migdal.models import Category
 
 register = template.Library()
 
 
 register = template.Library()
 
@@ -57,16 +56,15 @@ def entry_promobox(context, entry, counter):
 def categories(context, taxonomy):
     context = {
         'request': context['request'],
 def categories(context, taxonomy):
     context = {
         'request': context['request'],
-        'object_list': Category.objects.filter(taxonomy=taxonomy
-                ).exclude(entry__isnull=True)
+        'object_list': Category.objects.filter(taxonomy=taxonomy).exclude(entry__isnull=True)
     }
     return context
 
 
 @register.inclusion_tag('migdal/last_comments.html')
 def last_comments(limit=app_settings.LAST_COMMENTS):
     }
     return context
 
 
 @register.inclusion_tag('migdal/last_comments.html')
 def last_comments(limit=app_settings.LAST_COMMENTS):
-    return {'object_list': 
-        XtdComment.objects.filter(is_public=True, is_removed=False).order_by('-submit_date')[:limit]}
+    return {
+        'object_list': XtdComment.objects.filter(is_public=True, is_removed=False).order_by('-submit_date')[:limit]}
 
 
 @register.inclusion_tag(['comments/form.html'])
 
 
 @register.inclusion_tag(['comments/form.html'])
index 501deb7..b967c44 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 """
 This file demonstrates writing tests using the unittest module. These will pass
 when you run "manage.py test".
 """
 This file demonstrates writing tests using the unittest module. These will pass
 when you run "manage.py test".
index dbf144b..efe67c9 100644 (file)
@@ -3,7 +3,7 @@
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from django.conf import settings
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from django.conf import settings
-from django.conf.urls import patterns, include, url, handler404
+from django.conf.urls import patterns, url
 from django.utils.translation import ugettext_lazy as _
 from django.utils.translation import string_concat
 from migdal import feeds, app_settings
 from django.utils.translation import ugettext_lazy as _
 from django.utils.translation import string_concat
 from migdal import feeds, app_settings
@@ -27,13 +27,15 @@ for t in app_settings.TYPES:
     ]
 
 
     ]
 
 
-urlpatterns = i18n_patterns('',
+urlpatterns = i18n_patterns(
+    '',
     # main page
     url(r'^$', 'migdal.views.main', name='migdal_main'),
     url(r'^rss.xml$', feeds.EntriesFeed(), name='migdal_main_feed'),
     # submit new entry
     url(string_concat(r'^', _('submit'), r'/$'), 'migdal.views.submit', name='migdal_submit'),
     # main page
     url(r'^$', 'migdal.views.main', name='migdal_main'),
     url(r'^rss.xml$', feeds.EntriesFeed(), name='migdal_main_feed'),
     # submit new entry
     url(string_concat(r'^', _('submit'), r'/$'), 'migdal.views.submit', name='migdal_submit'),
-    url(string_concat(r'^', _('submit'), r'/', _('thanks'), r'$'), 'migdal.views.submit_thanks', name='migdal_submit_thanks'),
+    url(string_concat(r'^', _('submit'), r'/', _('thanks'), r'$'), 'migdal.views.submit_thanks',
+        name='migdal_submit_thanks'),
     # category
     url(string_concat(r'^', _('categories'), r'/(?P<category_slug>[^/]*)/$'),
         'migdal.views.entry_list', name='migdal_category'),
     # category
     url(string_concat(r'^', _('categories'), r'/(?P<category_slug>[^/]*)/$'),
         'migdal.views.entry_list', name='migdal_category'),
@@ -47,9 +49,9 @@ urlpatterns = i18n_patterns('',
 
 if 'django.contrib.sitemaps' in settings.INSTALLED_APPS:
     from .sitemap import sitemaps
 
 if 'django.contrib.sitemaps' in settings.INSTALLED_APPS:
     from .sitemap import sitemaps
-    urlpatterns += patterns('',
+    urlpatterns += patterns(
+        '',
         url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {
             'sitemaps': sitemaps
         }),
     )
         url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {
             'sitemaps': sitemaps
         }),
     )
-
index 1f769a9..0d4d996 100644 (file)
@@ -45,8 +45,7 @@ def entry_list(request, type_db=None, category_slug=None):
 
     promobox = 5 if entry_type is None and category is None else None
 
 
     promobox = 5 if entry_type is None and category is None else None
 
-    object_list = api.entry_list(entry_type=entry_type, category=category,
-                    promobox=promobox)
+    object_list = api.entry_list(entry_type=entry_type, category=category, promobox=promobox)
 
     return render(request, templates, {
             'object_list': object_list,
 
     return render(request, templates, {
             'object_list': object_list,
@@ -84,6 +83,7 @@ def submit(request):
             'submit_form': submit_form,
         })
 
             'submit_form': submit_form,
         })
 
+
 def submit_thanks(request):
     return render(request, "migdal/entry/submit_thanks.html")
 
 def submit_thanks(request):
     return render(request, "migdal/entry/submit_thanks.html")
 
@@ -95,9 +95,10 @@ class SearchPublishedView(SearchView):
     def get_results(self):
         results = super(SearchPublishedView, self).get_results()
         lang_code = get_language()
     def get_results(self):
         results = super(SearchPublishedView, self).get_results()
         lang_code = get_language()
+
         def is_published(entity):
             if isinstance(entity, Entry):
         def is_published(entity):
             if isinstance(entity, Entry):
-                return getattr(entity, "published_%s" % lang_code) == True
+                return getattr(entity, "published_%s" % lang_code)
             else:
                 return True
         results = filter(lambda r: is_published(r.object), results)
             else:
                 return True
         results = filter(lambda r: is_published(r.object), results)
index 371846c..03986fc 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -4,10 +4,11 @@
 import os.path
 from setuptools import setup, find_packages
 
 import os.path
 from setuptools import setup, find_packages
 
+
 def whole_trees(package_dir, paths):
     def whole_tree(prefix, path):
         files = []
 def whole_trees(package_dir, paths):
     def whole_tree(prefix, path):
         files = []
-        for f in (f for f in os.listdir(os.path.join(prefix, path)) if not f[0]=='.'):
+        for f in (f for f in os.listdir(os.path.join(prefix, path)) if f[0] != '.'):
             new_path = os.path.join(path, f)
             if os.path.isdir(os.path.join(prefix, new_path)):
                 files.extend(whole_tree(prefix, new_path))
             new_path = os.path.join(path, f)
             if os.path.isdir(os.path.join(prefix, new_path)):
                 files.extend(whole_tree(prefix, new_path))
@@ -25,10 +26,9 @@ setup(
     version='0.4',
     author='Radek Czajka',
     author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
     version='0.4',
     author='Radek Czajka',
     author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
-    url = '',
+    url='',
     packages=find_packages(),
     packages=find_packages(),
-    package_data={'migdal': whole_trees('migdal', 
-            ['templates', 'locale'])},
+    package_data={'migdal': whole_trees('migdal', ['templates', 'locale'])},
     license='LICENSE',
     description='.',
     long_description="",
     license='LICENSE',
     description='.',
     long_description="",