Commit 6d6ffb5b authored by Falk, Dennis Nikolas's avatar Falk, Dennis Nikolas
Browse files

Kommentare geschrieben und Code formatiert

parent 5c273cd3
......@@ -28,22 +28,18 @@
Blog Archiv
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
{% for blog in blogs %}
<a class="dropdown-item" href="{{ blog.slug }}">{{ blog.created }}: <strong>{{ blog.title }}</strong></a>
{% endfor %}
</div>
</li>
</ul>
<ul class="navbar-nav ml-auto">
{% if user.is_authenticated %}
<li class="nav-item nav-link disabled">Hallo, {{ user.username }}!</li>
{% if user.is_staff %}
<li class="nav-item"><a class="nav-link" href="/admin">Adminbereich</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="{% url 'blog:user_logout' %}">Logout</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{% url 'blog:user_login' %}">Login</a></li>
......
......@@ -17,9 +17,10 @@ def get_all_blogs(request):
Authenticated user get articles with status 4 and 6 extra.
"""
if request.user.is_authenticated:
# Exclude those with status hidden from the overall list, but show everything else
query = f'status & {BLOG_STATE_HIDE_FROM_LIST} <> {BLOG_STATE_HIDE_FROM_LIST}'
else:
# Exclude those with status hidden from the overall list
# Exclude those with status hidden from the overall list and the user only blogs
query = f'status & {BLOG_STATE_HIDE_FROM_LIST}<>{BLOG_STATE_HIDE_FROM_LIST}' \
f' AND status & {BLOG_STATE_USER_ONLY}<>{BLOG_STATE_USER_ONLY}' \
f' AND status & {BLOG_STATE_CAN_HAVE_COMMENTS_AND_USER_ONLY}' \
......@@ -36,7 +37,6 @@ def all_blogs(request):
"""
blogs = get_all_blogs(request)
return render(request, 'blog/all_blogs.html', {'blogs': blogs})
......@@ -46,7 +46,6 @@ def detail(request, slug):
"""
blogs = get_all_blogs(request)
blogResult = Blog.objects.filter(slug=slug)
print(blogResult)
if blogResult.count() == 0:
......@@ -87,7 +86,8 @@ def save_comment(request):
def user_login(request):
"""User login
"""
blogs = get_all_blogs(request)
if request.method == 'POST':
......@@ -109,5 +109,7 @@ def user_login(request):
def user_logout(request):
"""User logout
"""
logout(request)
return redirect(reverse_lazy('blog:all_blogs'))
\ No newline at end of file
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