Merge branch 'master' into production

This commit is contained in:
CDaut 2022-09-12 01:09:52 +02:00 committed by CDaut
commit 2ecf1e8f65

View file

@ -39,7 +39,7 @@ def viewblog(request, title) -> HttpResponse:
rendered_html = render_md_file(filepath) rendered_html = render_md_file(filepath)
context = {'post': post, 'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None), context = {'post': post, 'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all()} 'allposts': Blogpost.objects.all().order_by("title")}
return render(request, 'blog/viewpost.html', context) return render(request, 'blog/viewpost.html', context)
@ -50,7 +50,7 @@ def index(request) -> HttpResponse:
rendered_html = render_md_file(filepath) rendered_html = render_md_file(filepath)
context = {'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None), context = {'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all()} 'allposts': Blogpost.objects.all().order_by("title")}
return render(request, 'blog/index.html', context) return render(request, 'blog/index.html', context)
@ -62,7 +62,7 @@ def edit(request, id) -> HttpResponse:
mdfile_content = open(blogpost.mdfile, "r").read() mdfile_content = open(blogpost.mdfile, "r").read()
context = {'alltopics': Topic.objects.all().order_by('name').values(), 'markdown': mdfile_content, context = {'alltopics': Topic.objects.all().order_by('name').values(), 'markdown': mdfile_content,
'roottopics': Topic.objects.all().filter(rootTopic=None), 'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all(), 'post': Blogpost.objects.get(pk=id)} 'allposts': Blogpost.objects.all().order_by("title"), 'post': Blogpost.objects.get(pk=id)}
if request.method == 'POST': if request.method == 'POST':
title = request.POST['title'] title = request.POST['title']
@ -114,7 +114,8 @@ def order(request) -> HttpResponse:
post.topic = Topic.objects.get(pk=root_id) if root_id is not None else None post.topic = Topic.objects.get(pk=root_id) if root_id is not None else None
post.save() post.save()
context = {'roottopics': Topic.objects.all().filter(rootTopic=None), 'allposts': Blogpost.objects.all()} context = {'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all().order_by("title")}
return render(request, 'blog/order.html', context) return render(request, 'blog/order.html', context)
@ -123,7 +124,7 @@ def order(request) -> HttpResponse:
def addpost(request) -> HttpResponse: def addpost(request) -> HttpResponse:
context = {'alltopics': Topic.objects.all().order_by('name').values(), 'markdown': '', context = {'alltopics': Topic.objects.all().order_by('name').values(), 'markdown': '',
'roottopics': Topic.objects.all().filter(rootTopic=None), 'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all()} 'allposts': Blogpost.objects.all().order_by("title")}
if request.method == 'POST': if request.method == 'POST':
title = request.POST['title'] title = request.POST['title']
markdown = request.POST['markdown'] markdown = request.POST['markdown']
@ -180,7 +181,8 @@ def addpost(request) -> HttpResponse:
@login_required @login_required
@mfa_login_required @mfa_login_required
def addtopic(request): def addtopic(request):
context = {'roottopics': Topic.objects.all().filter(rootTopic=None), 'allposts': Blogpost.objects.all()} context = {'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all().order_by("title")}
if request.method == 'POST': if request.method == 'POST':
topictitle = request.POST['title'] topictitle = request.POST['title']