sorting topics
This commit is contained in:
parent
4216e11e5b
commit
01ed26a939
4 changed files with 40 additions and 4 deletions
|
|
@ -5,5 +5,5 @@ urlpatterns = [
|
|||
path('', viewblog, name="index"),
|
||||
path('manage/addpost', addpost, name='addpost'),
|
||||
path('manage/order', order, name='order'),
|
||||
path('mock/<str:object>/<int:n>/', createmocks, name='mock'),
|
||||
path('mock/<str:objtype>/<int:n>/', createmocks, name='mock'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from django.http import HttpResponse
|
|||
from django.shortcuts import render, redirect
|
||||
from blog.factories import TopicFactory
|
||||
from blog.models import Topic, Tag, Blogpost
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from markdownblog import settings
|
||||
|
||||
|
|
@ -14,7 +15,16 @@ def viewblog(request) -> HttpResponse:
|
|||
|
||||
|
||||
@login_required
|
||||
@csrf_exempt
|
||||
def order(request):
|
||||
if request.method == "POST":
|
||||
root_id = int(request.POST['rootID']) if request.POST['rootID'] != 'root_list' else None
|
||||
child_id = int(request.POST['childID'])
|
||||
|
||||
child_topic = Topic.objects.get(pk=child_id)
|
||||
child_topic.rootTopic = Topic.objects.get(pk=root_id) if root_id is not None else None
|
||||
child_topic.save()
|
||||
|
||||
context = {'roottopics': Topic.objects.all().filter(rootTopic=None)}
|
||||
return render(request, 'blog/order.html', context)
|
||||
|
||||
|
|
@ -42,6 +52,7 @@ def addpost(request) -> HttpResponse:
|
|||
return render(request, 'blog/addpost.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
def createmocks(request, objtype, n) -> HttpResponse:
|
||||
topics = TopicFactory.create_batch(n)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue