From ebf4775723053da9a0a989bdb01ddd9dddc70d56 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Sun, 5 Jan 2025 22:48:26 +0100 Subject: [PATCH] Add basic task view to importer --- archivist/apps/importer/views.py | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 archivist/apps/importer/views.py diff --git a/archivist/apps/importer/views.py b/archivist/apps/importer/views.py new file mode 100644 index 0000000..79a9c59 --- /dev/null +++ b/archivist/apps/importer/views.py @@ -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')