new topics can now be created
This commit is contained in:
parent
ee7c359d5b
commit
c71b06ac9b
4 changed files with 41 additions and 1 deletions
|
|
@ -1,9 +1,10 @@
|
|||
from blog.views import viewblog, addpost, order, index, createmocks, edit
|
||||
from blog.views import viewblog, addpost, order, index, createmocks, edit, addtopic
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('', index, name="index"),
|
||||
path('manage/addpost', addpost, name='addpost'),
|
||||
path('manage/addtopic', addtopic, name='addtopic'),
|
||||
path('manage/order', order, name='order'),
|
||||
path('manage/edit/<int:id>/', edit, name='editpost'),
|
||||
path('mock/<str:objtype>/<int:n>/', createmocks, name='mock'),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue