feat: 5장 사진 지원 및 엑셀 내보내기 UI 개선
- 신고 및 완료 사진 5장 지원 (photo_path3, photo_path4, photo_path5 추가) - 엑셀 일일 리포트 개선: - 사진 5장 모두 한 행에 일렬 배치 (A, C, E, G, I 열) - 상태별 색상 구분 (지연중: 빨강, 진행중: 노랑, 완료: 진한 초록) - 우선순위 기반 정렬 (지연중 → 진행중 → 완료됨) - 프로젝트 현황 통계 박스 UI 개선 (색상 구분) - 프론트엔드 모든 페이지 5장 사진 표시 (flex-wrap 레이아웃) - 관리함, 수신함, 현황판, 신고내용 확인 페이지 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,22 +20,26 @@ async def create_issue(
|
||||
):
|
||||
print(f"DEBUG: 받은 issue 데이터: {issue}")
|
||||
print(f"DEBUG: project_id: {issue.project_id}")
|
||||
# 이미지 저장
|
||||
photo_path = None
|
||||
photo_path2 = None
|
||||
|
||||
if issue.photo:
|
||||
photo_path = save_base64_image(issue.photo)
|
||||
|
||||
if issue.photo2:
|
||||
photo_path2 = save_base64_image(issue.photo2)
|
||||
|
||||
# 이미지 저장 (최대 5장)
|
||||
photo_paths = {}
|
||||
for i in range(1, 6):
|
||||
photo_field = f"photo{i if i > 1 else ''}"
|
||||
path_field = f"photo_path{i if i > 1 else ''}"
|
||||
photo_data = getattr(issue, photo_field, None)
|
||||
if photo_data:
|
||||
photo_paths[path_field] = save_base64_image(photo_data)
|
||||
else:
|
||||
photo_paths[path_field] = None
|
||||
|
||||
# Issue 생성
|
||||
db_issue = Issue(
|
||||
category=issue.category,
|
||||
description=issue.description,
|
||||
photo_path=photo_path,
|
||||
photo_path2=photo_path2,
|
||||
photo_path=photo_paths.get('photo_path'),
|
||||
photo_path2=photo_paths.get('photo_path2'),
|
||||
photo_path3=photo_paths.get('photo_path3'),
|
||||
photo_path4=photo_paths.get('photo_path4'),
|
||||
photo_path5=photo_paths.get('photo_path5'),
|
||||
reporter_id=current_user.id,
|
||||
project_id=issue.project_id,
|
||||
status=IssueStatus.new
|
||||
@@ -135,38 +139,27 @@ async def update_issue(
|
||||
|
||||
# 업데이트
|
||||
update_data = issue_update.dict(exclude_unset=True)
|
||||
|
||||
# 첫 번째 사진이 업데이트되는 경우 처리
|
||||
if "photo" in update_data:
|
||||
# 기존 사진 삭제
|
||||
if issue.photo_path:
|
||||
delete_file(issue.photo_path)
|
||||
|
||||
# 새 사진 저장
|
||||
if update_data["photo"]:
|
||||
photo_path = save_base64_image(update_data["photo"])
|
||||
update_data["photo_path"] = photo_path
|
||||
else:
|
||||
update_data["photo_path"] = None
|
||||
|
||||
# photo 필드는 제거 (DB에는 photo_path만 저장)
|
||||
del update_data["photo"]
|
||||
|
||||
# 두 번째 사진이 업데이트되는 경우 처리
|
||||
if "photo2" in update_data:
|
||||
# 기존 사진 삭제
|
||||
if issue.photo_path2:
|
||||
delete_file(issue.photo_path2)
|
||||
|
||||
# 새 사진 저장
|
||||
if update_data["photo2"]:
|
||||
photo_path2 = save_base64_image(update_data["photo2"])
|
||||
update_data["photo_path2"] = photo_path2
|
||||
else:
|
||||
update_data["photo_path2"] = None
|
||||
|
||||
# photo2 필드는 제거 (DB에는 photo_path2만 저장)
|
||||
del update_data["photo2"]
|
||||
|
||||
# 사진 업데이트 처리 (최대 5장)
|
||||
for i in range(1, 6):
|
||||
photo_field = f"photo{i if i > 1 else ''}"
|
||||
path_field = f"photo_path{i if i > 1 else ''}"
|
||||
|
||||
if photo_field in update_data:
|
||||
# 기존 사진 삭제
|
||||
existing_path = getattr(issue, path_field, None)
|
||||
if existing_path:
|
||||
delete_file(existing_path)
|
||||
|
||||
# 새 사진 저장
|
||||
if update_data[photo_field]:
|
||||
new_path = save_base64_image(update_data[photo_field])
|
||||
update_data[path_field] = new_path
|
||||
else:
|
||||
update_data[path_field] = None
|
||||
|
||||
# photo 필드는 제거 (DB에는 photo_path만 저장)
|
||||
del update_data[photo_field]
|
||||
|
||||
# work_hours가 입력되면 자동으로 상태를 complete로 변경
|
||||
if "work_hours" in update_data and update_data["work_hours"] > 0:
|
||||
@@ -235,13 +228,19 @@ async def delete_issue(
|
||||
)
|
||||
db.add(deletion_log)
|
||||
|
||||
# 이미지 파일 삭제
|
||||
if issue.photo_path:
|
||||
delete_file(issue.photo_path)
|
||||
if issue.photo_path2:
|
||||
delete_file(issue.photo_path2)
|
||||
if issue.completion_photo_path:
|
||||
delete_file(issue.completion_photo_path)
|
||||
# 이미지 파일 삭제 (신고 사진 최대 5장)
|
||||
for i in range(1, 6):
|
||||
path_field = f"photo_path{i if i > 1 else ''}"
|
||||
path = getattr(issue, path_field, None)
|
||||
if path:
|
||||
delete_file(path)
|
||||
|
||||
# 완료 사진 삭제 (최대 5장)
|
||||
for i in range(1, 6):
|
||||
path_field = f"completion_photo_path{i if i > 1 else ''}"
|
||||
path = getattr(issue, path_field, None)
|
||||
if path:
|
||||
delete_file(path)
|
||||
|
||||
db.delete(issue)
|
||||
db.commit()
|
||||
@@ -300,18 +299,32 @@ async def update_issue_management(
|
||||
update_data = management_update.dict(exclude_unset=True)
|
||||
print(f"DEBUG: Update data dict: {update_data}")
|
||||
|
||||
for field, value in update_data.items():
|
||||
print(f"DEBUG: Processing field {field} = {value}")
|
||||
if field == 'completion_photo' and value:
|
||||
# 완료 사진 업로드 처리
|
||||
# 완료 사진 처리 (최대 5장)
|
||||
completion_photo_fields = []
|
||||
for i in range(1, 6):
|
||||
photo_field = f"completion_photo{i if i > 1 else ''}"
|
||||
path_field = f"completion_photo_path{i if i > 1 else ''}"
|
||||
|
||||
if photo_field in update_data and update_data[photo_field]:
|
||||
completion_photo_fields.append(photo_field)
|
||||
try:
|
||||
completion_photo_path = save_base64_image(value, "completion")
|
||||
setattr(issue, 'completion_photo_path', completion_photo_path)
|
||||
print(f"DEBUG: Saved completion photo: {completion_photo_path}")
|
||||
# 기존 사진 삭제
|
||||
existing_path = getattr(issue, path_field, None)
|
||||
if existing_path:
|
||||
delete_file(existing_path)
|
||||
|
||||
# 새 사진 저장
|
||||
new_path = save_base64_image(update_data[photo_field], "completion")
|
||||
setattr(issue, path_field, new_path)
|
||||
print(f"DEBUG: Saved {photo_field}: {new_path}")
|
||||
except Exception as e:
|
||||
print(f"DEBUG: Photo save error: {str(e)}")
|
||||
print(f"DEBUG: Photo save error for {photo_field}: {str(e)}")
|
||||
raise HTTPException(status_code=400, detail=f"완료 사진 저장 실패: {str(e)}")
|
||||
elif field != 'completion_photo': # completion_photo는 위에서 처리됨
|
||||
|
||||
# 나머지 필드 처리 (완료 사진 제외)
|
||||
for field, value in update_data.items():
|
||||
if field not in completion_photo_fields:
|
||||
print(f"DEBUG: Processing field {field} = {value}")
|
||||
try:
|
||||
setattr(issue, field, value)
|
||||
print(f"DEBUG: Set {field} = {value}")
|
||||
@@ -359,22 +372,28 @@ async def request_completion(
|
||||
|
||||
try:
|
||||
print(f"DEBUG: 완료 신청 시작 - Issue ID: {issue_id}, User: {current_user.username}")
|
||||
|
||||
# 완료 사진 저장
|
||||
completion_photo_path = None
|
||||
if request.completion_photo:
|
||||
print(f"DEBUG: 완료 사진 저장 시작")
|
||||
completion_photo_path = save_base64_image(request.completion_photo, "completion")
|
||||
print(f"DEBUG: 완료 사진 저장 완료 - Path: {completion_photo_path}")
|
||||
|
||||
if not completion_photo_path:
|
||||
raise Exception("완료 사진 저장에 실패했습니다.")
|
||||
|
||||
|
||||
# 완료 사진 저장 (최대 5장)
|
||||
saved_paths = []
|
||||
for i in range(1, 6):
|
||||
photo_field = f"completion_photo{i if i > 1 else ''}"
|
||||
path_field = f"completion_photo_path{i if i > 1 else ''}"
|
||||
photo_data = getattr(request, photo_field, None)
|
||||
|
||||
if photo_data:
|
||||
print(f"DEBUG: {photo_field} 저장 시작")
|
||||
saved_path = save_base64_image(photo_data, "completion")
|
||||
if saved_path:
|
||||
setattr(issue, path_field, saved_path)
|
||||
saved_paths.append(saved_path)
|
||||
print(f"DEBUG: {photo_field} 저장 완료 - Path: {saved_path}")
|
||||
else:
|
||||
raise Exception(f"{photo_field} 저장에 실패했습니다.")
|
||||
|
||||
# 완료 신청 정보 업데이트
|
||||
print(f"DEBUG: DB 업데이트 시작")
|
||||
issue.completion_requested_at = datetime.now()
|
||||
issue.completion_requested_by_id = current_user.id
|
||||
issue.completion_photo_path = completion_photo_path
|
||||
issue.completion_comment = request.completion_comment
|
||||
|
||||
db.commit()
|
||||
@@ -385,18 +404,19 @@ async def request_completion(
|
||||
"message": "완료 신청이 성공적으로 제출되었습니다.",
|
||||
"issue_id": issue.id,
|
||||
"completion_requested_at": issue.completion_requested_at,
|
||||
"completion_photo_path": completion_photo_path
|
||||
"completion_photo_paths": saved_paths
|
||||
}
|
||||
|
||||
|
||||
except Exception as e:
|
||||
print(f"ERROR: 완료 신청 처리 오류 - {str(e)}")
|
||||
db.rollback()
|
||||
# 업로드된 파일이 있다면 삭제
|
||||
if 'completion_photo_path' in locals() and completion_photo_path:
|
||||
try:
|
||||
delete_file(completion_photo_path)
|
||||
except:
|
||||
pass
|
||||
if 'saved_paths' in locals():
|
||||
for path in saved_paths:
|
||||
try:
|
||||
delete_file(path)
|
||||
except:
|
||||
pass
|
||||
raise HTTPException(status_code=500, detail=f"완료 신청 처리 중 오류가 발생했습니다: {str(e)}")
|
||||
|
||||
@router.post("/{issue_id}/reject-completion")
|
||||
@@ -425,18 +445,23 @@ async def reject_completion_request(
|
||||
try:
|
||||
print(f"DEBUG: 완료 반려 시작 - Issue ID: {issue_id}, User: {current_user.username}")
|
||||
|
||||
# 완료 사진 파일 삭제
|
||||
if issue.completion_photo_path:
|
||||
try:
|
||||
delete_file(issue.completion_photo_path)
|
||||
print(f"DEBUG: 완료 사진 삭제 완료")
|
||||
except Exception as e:
|
||||
print(f"WARNING: 완료 사진 삭제 실패 - {str(e)}")
|
||||
# 완료 사진 파일 삭제 (최대 5장)
|
||||
for i in range(1, 6):
|
||||
path_field = f"completion_photo_path{i if i > 1 else ''}"
|
||||
photo_path = getattr(issue, path_field, None)
|
||||
if photo_path:
|
||||
try:
|
||||
delete_file(photo_path)
|
||||
print(f"DEBUG: {path_field} 삭제 완료")
|
||||
except Exception as e:
|
||||
print(f"WARNING: {path_field} 삭제 실패 - {str(e)}")
|
||||
|
||||
# 완료 신청 정보 초기화
|
||||
issue.completion_requested_at = None
|
||||
issue.completion_requested_by_id = None
|
||||
issue.completion_photo_path = None
|
||||
for i in range(1, 6):
|
||||
path_field = f"completion_photo_path{i if i > 1 else ''}"
|
||||
setattr(issue, path_field, None)
|
||||
issue.completion_comment = None
|
||||
|
||||
# 완료 반려 정보 기록 (전용 필드 사용)
|
||||
|
||||
Reference in New Issue
Block a user