feat(vacation): 관리자는 모든 상태(승인/취소 포함) 휴가 삭제 가능

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 21:27:10 +09:00
parent cb43fe1257
commit e2c6a50b46
2 changed files with 31 additions and 18 deletions
+10 -5
View File
@@ -352,15 +352,20 @@ class VacationDBStore:
return self._req_serialize(row)
def hard_delete(self, *, request_id: str, user_email: str, is_admin: bool) -> None:
"""완전 삭제. 승인 전(작성중/제출/반려)만 허용. owner 또는 admin."""
"""완전 삭제.
- 관리자(is_admin): 모든 상태 삭제 가능.
- 일반 사용자: 본인 + 승인 전(작성중/제출/반려)만. 승인/취소 건은 불가.
"""
user_email = user_email.lower().strip()
current = self.get_request(request_id=request_id)
if not current:
raise KeyError(request_id)
if not is_admin and current["owner"] != user_email:
raise PermissionError("본인 신청만 삭제할 수 있습니다.")
if current["status"] == "승인":
raise ValueError("승인된 휴가는 삭제할 수 없습니다. 취소 처리하세요.")
if not is_admin:
if current["owner"] != user_email:
raise PermissionError("본인 신청만 삭제할 수 있습니다.")
if current["status"] not in ("작성중", "제출", "반려"):
raise ValueError("승인/취소된 휴가는 삭제할 수 없습니다. (관리자 문의)")
with self._pool.connection() as conn:
cur = conn.execute(
"DELETE FROM vacation_requests WHERE id = %s", (request_id,)