order posts by title

This commit is contained in:
CDaut 2022-09-12 01:09:32 +02:00 committed by CDaut
parent dab1a625c6
commit 4e97480a21

View file

@ -39,7 +39,7 @@ def viewblog(request, title) -> HttpResponse:
rendered_html = render_md_file(filepath)
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)
@ -50,7 +50,7 @@ def index(request) -> HttpResponse:
rendered_html = render_md_file(filepath)
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)
@ -62,7 +62,7 @@ def edit(request, id) -> HttpResponse:
mdfile_content = open(blogpost.mdfile, "r").read()
context = {'alltopics': Topic.objects.all().order_by('name').values(), 'markdown': mdfile_content,
'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':
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.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)
@ -123,7 +124,7 @@ def order(request) -> HttpResponse:
def addpost(request) -> HttpResponse:
context = {'alltopics': Topic.objects.all().order_by('name').values(), 'markdown': '',
'roottopics': Topic.objects.all().filter(rootTopic=None),
'allposts': Blogpost.objects.all()}
'allposts': Blogpost.objects.all().order_by("title")}
if request.method == 'POST':
title = request.POST['title']
markdown = request.POST['markdown']
@ -180,7 +181,8 @@ def addpost(request) -> HttpResponse:
@login_required
@mfa_login_required
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':
topictitle = request.POST['title']