From 7afeb41469e0aacb435465032b3f6dfca2ad833f Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 22 Sep 2023 21:51:27 +0700 Subject: [PATCH] use SearchProcess for single_lookup --- tubearchivist/home/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index cca537d..50aebc7 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -12,7 +12,7 @@ from api.src.search_processor import SearchProcess from django.conf import settings from django.contrib.auth import login from django.contrib.auth.forms import AuthenticationForm -from django.http import JsonResponse +from django.http import Http404, JsonResponse from django.shortcuts import redirect, render from django.views import View from home.src.download.queue import PendingInteract @@ -181,8 +181,12 @@ class ArchivistResultsView(ArchivistViewConfig): def single_lookup(self, es_path): """retrieve a single item from url""" - search = SearchHandler(es_path) - result = search.get_data()[0]["source"] + response, status_code = ElasticWrap(es_path).get() + if not status_code == 200: + raise Http404 + + result = SearchProcess(response).process() + return result def initiate_vars(self, request):