Gallery-Archivist/archivist/apps/importer/views.py

60 lines
1.3 KiB
Python
Raw Normal View History

2025-01-05 22:48:26 +01:00
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')