diff --git a/backend/routers/__pycache__/issues.cpython-311.pyc b/backend/routers/__pycache__/issues.cpython-311.pyc index aa947ac..6115acb 100644 Binary files a/backend/routers/__pycache__/issues.cpython-311.pyc and b/backend/routers/__pycache__/issues.cpython-311.pyc differ diff --git a/backend/routers/issues.py b/backend/routers/issues.py index e8b86f5..e10054e 100644 --- a/backend/routers/issues.py +++ b/backend/routers/issues.py @@ -236,6 +236,10 @@ async def update_issue_management( """ 관리함에서 이슈의 관리 관련 필드들을 업데이트합니다. """ + print(f"DEBUG: Received management update for issue {issue_id}") + print(f"DEBUG: Update data: {management_update}") + print(f"DEBUG: Current user: {current_user.username}") + # 관리함 페이지 권한 확인 if not (current_user.role == UserRole.admin or check_page_access(current_user.id, 'issues_management', db)): raise HTTPException(status_code=403, detail="관리함 접근 권한이 없습니다.") @@ -245,22 +249,39 @@ async def update_issue_management( if not issue: raise HTTPException(status_code=404, detail="부적합을 찾을 수 없습니다.") + print(f"DEBUG: Found issue: {issue.id}") + # 관리함에서만 수정 가능한 필드들만 업데이트 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: # 완료 사진 업로드 처리 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}") except Exception as e: + print(f"DEBUG: Photo save error: {str(e)}") raise HTTPException(status_code=400, detail=f"완료 사진 저장 실패: {str(e)}") elif field != 'completion_photo': # completion_photo는 위에서 처리됨 - setattr(issue, field, value) + try: + setattr(issue, field, value) + print(f"DEBUG: Set {field} = {value}") + except Exception as e: + print(f"DEBUG: Field set error for {field}: {str(e)}") + raise HTTPException(status_code=400, detail=f"필드 {field} 설정 실패: {str(e)}") - db.commit() - db.refresh(issue) + try: + db.commit() + db.refresh(issue) + print(f"DEBUG: Successfully updated issue {issue.id}") + except Exception as e: + print(f"DEBUG: Database commit error: {str(e)}") + db.rollback() + raise HTTPException(status_code=500, detail=f"데이터베이스 저장 실패: {str(e)}") return { "message": "관리 정보가 업데이트되었습니다.", diff --git a/frontend/issues-management.html b/frontend/issues-management.html index e784b14..ae48593 100644 --- a/frontend/issues-management.html +++ b/frontend/issues-management.html @@ -956,6 +956,8 @@ } }); + console.log('Sending updates:', updates); + // API 호출 const response = await fetch(`/api/issues/${issueId}/management`, { method: 'PUT', @@ -966,15 +968,26 @@ body: JSON.stringify(updates) }); + console.log('Response status:', response.status); + if (response.ok) { alert('변경사항이 저장되었습니다.'); await loadIssues(); // 목록 새로고침 } else { - const error = await response.json(); - throw new Error(error.detail || '저장에 실패했습니다.'); + const errorText = await response.text(); + console.error('API Error Response:', errorText); + let errorMessage = '저장에 실패했습니다.'; + try { + const errorJson = JSON.parse(errorText); + errorMessage = errorJson.detail || JSON.stringify(errorJson); + } catch (e) { + errorMessage = errorText || '저장에 실패했습니다.'; + } + throw new Error(errorMessage); } } catch (error) { console.error('저장 실패:', error); + console.error('Error details:', error); alert(error.message || '저장 중 오류가 발생했습니다.'); } } @@ -1128,6 +1141,8 @@ updates.completion_photo = base64; } + console.log('Modal sending updates:', updates); + // API 호출 const response = await fetch(`/api/issues/${currentModalIssueId}/management`, { method: 'PUT', @@ -1138,16 +1153,27 @@ body: JSON.stringify(updates) }); + console.log('Modal response status:', response.status); + if (response.ok) { alert('변경사항이 저장되었습니다.'); closeIssueDetailModal(); await loadIssues(); // 목록 새로고침 } else { - const error = await response.json(); - throw new Error(error.detail || '저장에 실패했습니다.'); + const errorText = await response.text(); + console.error('Modal API Error Response:', errorText); + let errorMessage = '저장에 실패했습니다.'; + try { + const errorJson = JSON.parse(errorText); + errorMessage = errorJson.detail || JSON.stringify(errorJson); + } catch (e) { + errorMessage = errorText || '저장에 실패했습니다.'; + } + throw new Error(errorMessage); } } catch (error) { - console.error('저장 실패:', error); + console.error('모달 저장 실패:', error); + console.error('Error details:', error); alert(error.message || '저장 중 오류가 발생했습니다.'); } }