diff options
author | Yaroslav de la Peña <contact@yaroslavps.com> | 2018-10-12 16:33:43 +0300 |
---|---|---|
committer | Yaroslav de la Peña <contact@yaroslavps.com> | 2018-10-12 16:33:43 +0300 |
commit | a306094530a5e49a758cd9cf02d8860437c2dd8f (patch) | |
tree | c77ada864544ed15dcbc5f22b0b13cfe8fc5148f | |
parent | 1902be002029baf09a5d0e2b980f46a34510182c (diff) | |
download | w3blog-a306094530a5e49a758cd9cf02d8860437c2dd8f.tar.gz w3blog-a306094530a5e49a758cd9cf02d8860437c2dd8f.zip |
fixed pinned posts appearing even if they are not published yet
-rwxr-xr-x | setup.py | 2 | ||||
-rwxr-xr-x | weblog/templatetags/weblog_extras.py | 2 | ||||
-rwxr-xr-x | weblog/views.py | 3 |
3 files changed, 4 insertions, 3 deletions
@@ -10,7 +10,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='w3blog', - version='0.5-testing.4', + version='0.5-testing.5', packages=find_packages(), include_package_data=True, license='BSD License', diff --git a/weblog/templatetags/weblog_extras.py b/weblog/templatetags/weblog_extras.py index 25431f5..777618d 100755 --- a/weblog/templatetags/weblog_extras.py +++ b/weblog/templatetags/weblog_extras.py @@ -46,7 +46,7 @@ def get_sidebar_categories(selected_cat_slug=None): @register.inclusion_tag('weblog/sidebar_archive.html') def get_sidebar_archive(): - if BlogPost.objects.all().count() < 1: + if BlogPost.objects.filter(published=True).count() < 1: return {} now = datetime.datetime.now() oldest_post = BlogPost.objects.filter(published=True).reverse()[0] diff --git a/weblog/views.py b/weblog/views.py index d3a7066..d614cd6 100755 --- a/weblog/views.py +++ b/weblog/views.py @@ -78,7 +78,7 @@ def Index(request, **kwargs): # and get the pinned and necessary posts depending on the page posts_raw = list(all_pages[slice_start:slice_end]) if len(kwargs) < 1: - for pinned_post in BlogPost.objects.filter(pinned=True).order_by('-pin_priority'): + for pinned_post in BlogPost.objects.filter(published=True, pinned=True).order_by('-pin_priority'): if pinned_post in posts_raw: posts_raw.remove(pinned_post) posts_raw.append(pinned_post) @@ -155,6 +155,7 @@ def Index(request, **kwargs): else: posts.append(post) + print('rendering template') # If ajax is asking for the next page through the kwargs, # just send the posts for the requested page without the other page elements if 'nxtpage' in kwargs: |