Commit 7f2b5906 authored by Behr, Svenja's avatar Behr, Svenja
Browse files

- Kosmetik

parent d433b393
......@@ -27,8 +27,7 @@ def get_all_blogs(request):
if not request.user.is_authenticated:
query += f' AND status & {BLOG_STATE_USER_ONLY} <> {BLOG_STATE_USER_ONLY}'
blogs = Blog.objects.extra(where=[query]).order_by('-created')
return blogs
return Blog.objects.extra(where=[query]).order_by('-created')
# Create your views here.
......@@ -41,10 +40,9 @@ def all_blogs(request):
# split into subqueries, turn into lists for shuffling, then being chained
if allblogs.count() > NEWEST_BLOGS_AT_BEGINNING:
last_three_blogs = allblogs[:NEWEST_BLOGS_AT_BEGINNING]
all_blogs_except_last_three_in_random_order = list(allblogs[NEWEST_BLOGS_AT_BEGINNING:])
shuffle(all_blogs_except_last_three_in_random_order)
allblogs = chain(last_three_blogs, all_blogs_except_last_three_in_random_order)
all_blogs_except_last_three = list(allblogs[NEWEST_BLOGS_AT_BEGINNING:])
shuffle(all_blogs_except_last_three)
allblogs = chain(allblogs[:NEWEST_BLOGS_AT_BEGINNING], all_blogs_except_last_three)
blogs = get_all_blogs(request)
return render(request, 'blog/all_blogs.html', {'blogs': blogs, 'overview_blogs': allblogs})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment