aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-08-01 20:02:19 +0100
committerMatthew Lemon <y@yulqen.org>2024-08-01 20:02:19 +0100
commit9b7839bb128fef31e8d3418f4308b59b6cb8e93a (patch)
treecc9fc2e9b880b9e6368c2ba98eabad58f674dc22
parent55babe754a7dd7876d328b7a1c95c2d0def5b4f9 (diff)
Refactor PDF collection type conditions for readability.
Simplify conditional checks for PDF collection types by removing unnecessary line continuations. Also, fix param format in hx_download_button docstring and adjust string formatting for error messages.
-rw-r--r--pyblackbird_cc/resources/views.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py
index bb0187f..07227e4 100644
--- a/pyblackbird_cc/resources/views.py
+++ b/pyblackbird_cc/resources/views.py
@@ -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")
@@ -237,7 +237,6 @@ def create_metadata(
yield metadata, snapshot_images
-
@login_required
def create_resource(request):
if request.method == "POST":
@@ -307,7 +306,8 @@ def create_resource(request):
except IntegrityError:
slot = form.cleaned_data["feature_slot"]
messages.add_message(request, messages.ERROR, f"Feature slot {slot} is already "
- "in use. Quit this form and remove from existing resource.")
+ "in use. Quit this form and remove from existing "
+ "resource.")
except Exception:
logger.exception("Error creating resource")
form.add_error(None, "An error occurred while creating the resource.")
@@ -376,7 +376,7 @@ def resource_detail(request, resource_id):
def hx_download_button(request):
"""
This is an HTMX view that is called when the user clicks the download button.
- :param
+ :param:
:return:
"""
pdf = request.GET.get("rn")