Feat: 템플릿 파일명을 근무처파일명_template.xlsx 에서 자동 로드

This commit is contained in:
user01
2026-05-25 00:53:15 +09:00
parent 5846ad8a70
commit 8c3e53b017

7
app.py
View File

@@ -679,6 +679,7 @@ def upload_workplaces():
wp['id'] = f'p{offset}' wp['id'] = f'p{offset}'
offset += 1 offset += 1
t['workplaces'] = existing + new_workplaces t['workplaces'] = existing + new_workplaces
t['workplace_filename'] = file.filename
total = len(t['workplaces']) total = len(t['workplaces'])
update_progress('완료', f'근무처 업로드 완료 (총 {total}개, 이번 {len(new_workplaces)}개)') update_progress('완료', f'근무처 업로드 완료 (총 {total}개, 이번 {len(new_workplaces)}개)')
@@ -826,7 +827,11 @@ def export():
ws.append([w['name'], w['hope'], w['address'], w['dob'], w['phone']]) ws.append([w['name'], w['hope'], w['address'], w['dob'], w['phone']])
elif export_type == 'assigned': elif export_type == 'assigned':
template_path = '선거참관인_배치_와꾸_.xlsx' wp_filename = t.get('workplace_filename', '')
base = os.path.splitext(wp_filename)[0]
template_path = f'{base}_template.xlsx' if base else ''
if not template_path or not os.path.exists(template_path):
template_path = '선거참관인_배치_와꾸_.xlsx'
if os.path.exists(template_path): if os.path.exists(template_path):
wb = openpyxl.load_workbook(template_path) wb = openpyxl.load_workbook(template_path)
wp_workers = {} wp_workers = {}