Ensure cross_plans directory exists before saving JSON in import_cross_plan
This commit is contained in:
parent
3ede92b24f
commit
09e684a07c
1 changed files with 2 additions and 0 deletions
|
|
@ -3706,6 +3706,7 @@ def import_cross_plan(request, intersection_id):
|
||||||
|
|
||||||
intersection = get_object_or_404(TrafficLightIntersection, pk=intersection_id)
|
intersection = get_object_or_404(TrafficLightIntersection, pk=intersection_id)
|
||||||
uploaded_dir = os.path.join(settings.PRIVATE_MEDIA_ROOT, 'cross_plans')
|
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
|
# Fetch DXF files and georeferenced documents associated with this intersection
|
||||||
dxf_files = []
|
dxf_files = []
|
||||||
|
|
@ -4030,6 +4031,7 @@ def import_cross_plan(request, intersection_id):
|
||||||
# Save merged results into a temporary JSON file
|
# Save merged results into a temporary JSON file
|
||||||
json_filename = f"combined_{intersection.id}_{uuid.uuid4().hex}.json"
|
json_filename = f"combined_{intersection.id}_{uuid.uuid4().hex}.json"
|
||||||
json_filepath = os.path.join(uploaded_dir, json_filename)
|
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:
|
with open(json_filepath, 'w', encoding='utf-8') as f:
|
||||||
json.dump(merged_deduced, f, indent=4)
|
json.dump(merged_deduced, f, indent=4)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue