new topics can now be created

This commit is contained in:
CDaut 2022-06-25 19:07:24 +02:00 committed by CDaut
parent ee7c359d5b
commit c71b06ac9b
4 changed files with 41 additions and 1 deletions

View file

@ -159,3 +159,14 @@ def createmocks(request, objtype, n) -> HttpResponse:
print('Created ' + str(n) + ' mock topics.')
return redirect("index")
@login_required
def addtopic(request):
context = {'roottopics': Topic.objects.all().filter(rootTopic=None), 'allposts': Blogpost.objects.all()}
if request.method == 'POST':
topictitle = request.POST['title']
Topic.objects.get_or_create(name=topictitle)
return render(request, 'blog/addtopic.html', context)