diff options
author | Yaroslav de la Peña Smirnov <contact@yaroslavps.com> | 2018-06-20 16:14:20 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <contact@yaroslavps.com> | 2018-06-20 16:14:20 +0300 |
commit | 06b58a6a3afbe3e9ffac45b363cfeafcf0e4b3f2 (patch) | |
tree | 4659c4eda47b78188f1cbff5339bbe03b31d8d5b | |
parent | 843e7e06709a35a162ddb28e9eef528870e2c0f6 (diff) | |
download | w3blog-06b58a6a3afbe3e9ffac45b363cfeafcf0e4b3f2.tar.gz w3blog-06b58a6a3afbe3e9ffac45b363cfeafcf0e4b3f2.zip |
rss bug fixes
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | weblog/feeds.py | 22 | ||||
-rwxr-xr-x | weblog/urls.py | 17 |
3 files changed, 22 insertions, 19 deletions
@@ -9,7 +9,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-weblog', - version='0.3-rss.4', + version='0.3-rss.7', packages=find_packages(), include_package_data=True, license='BSD License', diff --git a/weblog/feeds.py b/weblog/feeds.py index 7e567c2..158e90f 100644 --- a/weblog/feeds.py +++ b/weblog/feeds.py @@ -1,4 +1,4 @@ -from django.contrib.syndication.views. import Feed +from django.contrib.syndication.views import Feed from django.urls import reverse from weblog.models import BlogPost, Translation, Category, CategoryTranslation from weblog.apps import SETTINGS as blog_settings @@ -8,15 +8,15 @@ from django.utils import translation class BlogFeed(Feed): def get_object(self, request, category_slug=None): + self.current_language = translation.get_language() + if self.current_language is None: + self.current_language = settings.LANGUAGE_CODE if category_slug: if category_slug != 'misc': - self.category = Category.objects.get(slug=obj) + self.category = Category.objects.get(slug=category_slug) self.category_name = self.category.name - self.current_language = translation.get_language() - if self.current_language is None: - self.current_language = settings.LANGUAGE_CODE - if IS_MULTILINGUAL and obj != 'misc': - category_translations = CategoryTranslation.objects.filter(category=category) + if blog_settings['multilingual'] and category_slug != 'misc': + category_translations = CategoryTranslation.objects.filter(category=self.category) if category_translations.count() > 0: for cat_trans in category_translations: if self.current_language[0:2] == cat_trans.language[0:2]: @@ -46,10 +46,10 @@ class BlogFeed(Feed): return BlogPost.objects.filter(category__slug=obj).order_by('-publish_date')[:blog_settings['posts_per_page']] return BlogPost.objects.order_by('-publish_date')[:blog_settings['posts_per_page']] - def item_title(self, item, obj): + def item_title(self, item): translation_exists = False post_translations = Translation.objects.filter(post=item) - if post_translations.count() > 0 and blog_settings['multilingual'] + if post_translations.count() > 0 and blog_settings['multilingual']: orig_lang = item.original_language if len(orig_lang) < 2: orig_lang = settings.LANGUAGE_CODE[0:2] @@ -68,10 +68,10 @@ class BlogFeed(Feed): return item.author.get_full_name() return None - def item_description(self, item, obj): + def item_description(self, item): translation_exists = False post_translations = Translation.objects.filter(post=item) - if post_translation.count() > 0 and blog_settings['multilingual']: + if post_translations.count() > 0 and blog_settings['multilingual']: orig_lang = item.original_language if len(orig_lang) < 2: orig_lang = settings.LANGUAGE_CODE[0:2] diff --git a/weblog/urls.py b/weblog/urls.py index 4d6a325..b3e95b1 100755 --- a/weblog/urls.py +++ b/weblog/urls.py @@ -4,7 +4,16 @@ from weblog.feeds import BlogFeed from weblog.apps import SETTINGS as blog_settings
app_name = 'weblog'
-urlpatterns = [
+
+urlpatterns = []
+
+if blog_settings['enable_rss']:
+ urlpatterns += [
+ url(r'^rss/$', BlogFeed(), name='RSS'),
+ url(r'^(?P<category_slug>[-\w]+)/rss/$', BlogFeed(), name='CategoryRSS'),
+ ]
+
+urlpatterns += [
url(r'^$', views.Index, name='Index'),
url(r'^change-language/(?P<language>[-\w]+)/$', views.ChangeLanguage, name='ChangeLanguage'),
url(r'^(?P<year>[0-9]{4})/$', views.Index, name='ArchiveIndex'),
@@ -12,9 +21,3 @@ urlpatterns = [ url(r'^(?P<category_slug>[-\w]+)/$', views.Index, name='CategoryIndex'),
url(r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$', views.PostView, name='PostView'),
]
-
-if blog_settings['enable_rss']:
- urlpatters += [
- url(r'^/rss/$', BlogFeed(), name='RSS'),
- url(r'^/(?P<category_slug>[-\w]+)/rss/$', BlogFeed(), name='CategoryRSS'),
- ]
|