Ensure cross_plans directory exists before saving JSON in import_cross_plan

This commit is contained in:
Karl Determe 2026-08-25 12:23:46 +02:00
parent 3ede92b24f
commit 09e684a07c

View file

@ -3706,6 +3706,7 @@ def import_cross_plan(request, intersection_id):
intersection = get_object_or_404(TrafficLightIntersection, pk=intersection_id)
uploaded_dir = os.path.join(settings.PRIVATE_MEDIA_ROOT, 'cross_plans')
os.makedirs(uploaded_dir, exist_ok=True)
# Fetch DXF files and georeferenced documents associated with this intersection
dxf_files = []
@ -4030,6 +4031,7 @@ def import_cross_plan(request, intersection_id):
# Save merged results into a temporary JSON file
json_filename = f"combined_{intersection.id}_{uuid.uuid4().hex}.json"
json_filepath = os.path.join(uploaded_dir, json_filename)
os.makedirs(uploaded_dir, exist_ok=True)
with open(json_filepath, 'w', encoding='utf-8') as f:
json.dump(merged_deduced, f, indent=4)