diff options
Diffstat (limited to 'pyblackbird_cc/resources/views.py')
-rw-r--r-- | pyblackbird_cc/resources/views.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index 07227e4..2feb655 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -17,7 +17,7 @@ from django.shortcuts import redirect from django.shortcuts import render from . import services -from .forms import ResourceCreateForm +from .forms import ResourceCreateForm, ResourceUpdateThumbnailsForm from .forms import ResourceUpdateMetadataForm from .models import PDFPageSnapshot, ResourceSubcategory from .models import PDFResource @@ -185,7 +185,7 @@ def upload_to_s3(pdf_files, thumbnail_files, snapshotted_pages) -> bool: f"thumbnails/{f.name}", ) if _get_pdf_collection_type(snapshotted_pages) == "SINGLE_PDF_SINGLE_PAGE" \ - or _get_pdf_collection_type(snapshotted_pages) == "SINGLE_PDF_MULTI_PAGE": + or _get_pdf_collection_type(snapshotted_pages) == "SINGLE_PDF_MULTI_PAGE": for img in snapshotted_pages[0]: logger.info("Uploading {img} to S3") client.upload_file( @@ -195,7 +195,7 @@ def upload_to_s3(pdf_files, thumbnail_files, snapshotted_pages) -> bool: ) return True if _get_pdf_collection_type(snapshotted_pages) == "MULTI_PDF_SINGLE_PAGE" \ - or _get_pdf_collection_type(snapshotted_pages) == "MULTI_PDF_MULTI_PAGE": + or _get_pdf_collection_type(snapshotted_pages) == "MULTI_PDF_MULTI_PAGE": for pdf in snapshotted_pages: for img in pdf: logger.info("Uploading {img} to S3") @@ -221,7 +221,7 @@ def _write_pdf_to_tempdir(f) -> str: def create_metadata( - pdf_files, + pdf_files, ) -> Generator[tuple[services.PDFMetadata, str], None, None]: with tempfile.TemporaryDirectory() as temp_dir: for pdf_file in pdf_files: @@ -372,6 +372,17 @@ def resource_detail(request, resource_id): return render(request, "resources/resource_detail.html", {"resource": resource}) +def update_resource_thumbnails(request, pk): + resource = get_object_or_404(Resource, pk=pk) + if request.method == "POST": + form = ResourceUpdateThumbnailsForm(request.POST, request.FILES) + + else: + form = ResourceUpdateThumbnailsForm(resource=pk) + + return render(request, "resources/update_thumbnails.html", {"form": form, "resource": resource}) + + @login_required def hx_download_button(request): """ |