Add basic task view to importer
This commit is contained in:
parent
ae676b29a5
commit
ebf4775723
1 changed files with 59 additions and 0 deletions
59
archivist/apps/importer/views.py
Normal file
59
archivist/apps/importer/views.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
import os
|
||||
import json
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.paginator import Paginator
|
||||
from django.urls import reverse
|
||||
|
||||
from django_celery_results.models import TaskResult
|
||||
|
||||
from .models import ImportSourceURLs
|
||||
from .forms import ImportSourceURLsForm, GalleryDLConfigForm
|
||||
|
||||
from apps.sites.models import Category
|
||||
|
||||
from core import settings
|
||||
|
||||
|
||||
NAVTABS = [
|
||||
{
|
||||
"name" : "Home",
|
||||
"url" : "importer:index",
|
||||
"adminOnly" : False
|
||||
},
|
||||
{
|
||||
"name" : "Source URLs",
|
||||
"url" : "importer:source_urls",
|
||||
"adminOnly" : False
|
||||
},
|
||||
{
|
||||
"name" : "Config",
|
||||
"url" : "importer:config",
|
||||
"adminOnly" : True
|
||||
},
|
||||
{
|
||||
"name" : "Tasks",
|
||||
"url" : "importer:tasks",
|
||||
"adminOnly" : True
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@login_required(login_url="login")
|
||||
def TasksView(request):
|
||||
|
||||
if not (request.user.is_staff or request.user.is_superuser):
|
||||
return redirect('importer:index')
|
||||
|
||||
|
||||
from django_celery_results.models import TaskResult
|
||||
|
||||
tasks = TaskResult.objects.all().order_by('-date_created')
|
||||
|
||||
context = {
|
||||
"tasks" : tasks,
|
||||
"tabs" : NAVTABS
|
||||
}
|
||||
|
||||
return render(request, context=context, template_name='importer/tasks.html')
|
Loading…
Reference in a new issue