From fc2a683b9caa3d49eaf0398d45f8b02a980c9501 Mon Sep 17 00:00:00 2001 From: mariomitte Date: Tue, 8 Sep 2026 10:32:49 +0200 Subject: [PATCH] fix: restore monthly archive temp file builders The monthly ZIP job was still being requested normally, but the backend archive task could not create its temp archive files because the helper functions were missing. Restore those builders so the archive task can complete and emit the final generated_archive notification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- backend/modules/fleet/views.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backend/modules/fleet/views.py b/backend/modules/fleet/views.py index 7ed7272..6d7ffa0 100644 --- a/backend/modules/fleet/views.py +++ b/backend/modules/fleet/views.py @@ -5,6 +5,7 @@ from io import StringIO import base64 import csv import mimetypes +import tempfile import threading import zipfile import re @@ -2937,6 +2938,25 @@ def _generated_archive_filename_for_user(user, *, year, month, archive_type): return f"{prefix}-{month:02d}-{year}-{suffix}.zip" +def _build_monthly_archive_to_temp_file(*, user, year, month, archive_type): + if archive_type == 'service_tasks': + archive_content = _build_monthly_service_tasks_archive_content(user=user, year=year, month=month) + else: + archive_content = _build_monthly_work_orders_archive_content(user=user, year=year, month=month) + + with tempfile.NamedTemporaryFile(delete=False, suffix='.zip') as temp_file: + temp_file.write(archive_content) + return Path(temp_file.name) + + +def _build_monthly_service_tasks_archive_to_temp_file(*, user, year, month): + return _build_monthly_archive_to_temp_file(user=user, year=year, month=month, archive_type='service_tasks') + + +def _build_monthly_work_orders_archive_to_temp_file(*, user, year, month): + return _build_monthly_archive_to_temp_file(user=user, year=year, month=month, archive_type='work_orders') + + def _unique_zip_entry_name(entry_name, used_names): candidate = entry_name entry_path = Path(entry_name)