Skip to content

Commit 7dd6ab4

Browse files
authored
Merge pull request #340 from Pseudo-Lab/feat/improve-cert-error-handling
feat(cert): improve eligibility error handling and messages
2 parents 87deb0f + e451d9f commit 7dd6ab4

4 files changed

Lines changed: 23 additions & 11 deletions

File tree

โ€Žcert/backend/src/constants/error_codes.pyโ€Ž

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ class ErrorCodes:
55

66
class ErrorMessages:
77
"""์—๋Ÿฌ ๋ฉ”์‹œ์ง€ ์ƒ์ˆ˜"""
8-
NO_HISTORY = "์ˆ˜๋ฃŒ์ด๋ ฅ์ด ํ™•์ธ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๐Ÿฅฒ\n๋””์Šค์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ๊น€์ฐฌ๋ž€์—๊ฒŒ ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”."
8+
NO_HISTORY = "์ˆ˜๋ฃŒ ๋ช…๋‹จ์— ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๐Ÿฅฒ\n์ž…๋ ฅํ•˜์‹  ์ด๋ฆ„ '{name}'(์ด)๊ฐ€ ๋ช…๋‹จ์— ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ฑฐ๋‚˜, ์Šคํ„ฐ๋”” ๋นŒ๋” ํ˜น์€ ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”."
9+
USER_DROPPED_OUT = "์Šคํ„ฐ๋””๋ฅผ ์ˆ˜๋ฃŒํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๐Ÿฅฒ\n์Šคํ„ฐ๋”” ๋นŒ๋” ํ˜น์€ ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”."
10+
STUDY_NOT_COMPLETED = "์ˆ˜๋ฃŒ์ฆ์€ ์Šคํ„ฐ๋””๊ฐ€ ์™„๋ฃŒ๋œ ์ดํ›„ ๋ฐœ๊ธ‰ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.\n์Šคํ„ฐ๋”” ๋นŒ๋” ํ˜น์€ ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”."
11+
PROJECT_NOT_FOUND = "ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๊ฐ€ ๊ฒ€์ƒ‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.\n๊ธฐ์ˆ˜์™€ ์Šคํ„ฐ๋””๋ช…์„ ๋‹ค์‹œ ํ™•์ธํ•˜๊ฑฐ๋‚˜, ์Šคํ„ฐ๋”” ๋นŒ๋” ํ˜น์€ ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”."
912
PIPELINE_ERROR = "๋ฐœ๊ธ‰ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค."
1013
CONTACT_INFO = "์‹œ์Šคํ…œ ์ƒ์˜ ์˜ค๋ฅ˜๋กœ ์ˆ˜๋ฃŒ์ฆ ๋ฐœ๊ธ‰์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ๐Ÿฅฒ\n๋””์Šค์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ๊น€์ˆ˜ํ˜„(kyopbi)์—๊ฒŒ ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”"
1114

โ€Žcert/backend/src/services/certificate_service.pyโ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,15 @@ async def _create_new_certificate(
589589
)
590590
)
591591

592+
except NotEligibleError as e:
593+
# ์ˆ˜๋ฃŒ ๋Œ€์ƒ ์•„๋‹˜ (๋ช…๋‹จ์— ์—†๊ฑฐ๋‚˜ ์ดํƒˆ์ž ๋“ฑ)
594+
logger.warning(f"์ˆ˜๋ฃŒ ๋Œ€์ƒ ์•„๋‹˜: {str(e)}")
595+
if request_id:
596+
await notion_client.update_certificate_status(
597+
page_id=request_id,
598+
status=CertificateStatus.NOT_ELIGIBLE
599+
)
600+
raise e
592601
except Exception as e:
593602
# ์‹œ์Šคํ…œ ์˜ค๋ฅ˜
594603
logger.exception("์‹ ๊ทœ ์ˆ˜๋ฃŒ์ฆ ๋ฐœ๊ธ‰ ์ค‘ ์‹œ์Šคํ…œ ์˜ค๋ฅ˜")

โ€Žcert/backend/src/utils/notion_client.pyโ€Ž

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import aiohttp
77
from typing import Optional, Dict, Any, List
88

9-
from ..constants.error_codes import NotEligibleError, ResponseStatus
9+
from ..constants.error_codes import NotEligibleError, ResponseStatus, ErrorMessages
1010
from ..models.certificate import CertificateStatus
1111
from ..models.project import Project, SeasonGroup, ProjectsBySeasonResponse
1212

@@ -156,14 +156,17 @@ async def verify_user_participation(
156156
user_role = "BUILDER"
157157
elif user_name in runner_names:
158158
user_role = "RUNNER"
159+
# '์ˆ˜๋ฃŒ์ž' ํ•„๋“œ์— ์ด๋ฆ„์ด ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ
160+
elif any(user_name in c for c in completer_names):
161+
user_role = "RUNNER"
159162

160163
# 2. ์‚ฌ์šฉ์ž๊ฐ€ ์ดํƒˆ์ž์— ์žˆ๋Š”์ง€ ํ™•์ธ
161164
if user_name in dropout_names:
162-
raise NotEligibleError(f"์ˆ˜๋ฃŒ ๋ช…๋‹จ์— ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๐Ÿฅฒ\n๋””์Šค์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”.")
165+
raise NotEligibleError(ErrorMessages.USER_DROPPED_OUT)
163166

164167
# 3. ์‚ฌ์šฉ์ž๊ฐ€ ์ฐธ์—ฌ์ž ๋ชฉ๋ก์— ์žˆ๋Š”์ง€ ํ™•์ธ
165168
if user_role is None:
166-
raise NotEligibleError(f"์ˆ˜๋ฃŒ ๋ช…๋‹จ์— ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๐Ÿฅฒ\n๋””์Šค์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”.")
169+
raise NotEligibleError(ErrorMessages.NO_HISTORY.format(name=user_name))
167170

168171
study_status = properties.get("๋‹จ๊ณ„", {}).get("select", {})
169172
period_raw = project.get("properties", {}).get("๊ธฐ๊ฐ„", {}).get("date", {}) or {}
@@ -174,9 +177,7 @@ async def verify_user_participation(
174177
)
175178

176179
if study_status.get("name") != "์™„๋ฃŒ":
177-
raise NotEligibleError(
178-
"์ˆ˜๋ฃŒ์ฆ์€ ์Šคํ„ฐ๋””๊ฐ€ ์™„๋ฃŒ๋œ ์ดํ›„ ๋ฐœ๊ธ‰ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.\n๋””์Šค์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”."
179-
)
180+
raise NotEligibleError(ErrorMessages.STUDY_NOT_COMPLETED)
180181

181182
fallback_period = self.default_periods.get(str(season), {})
182183
raw_start = period_raw.get("start")
@@ -273,7 +274,7 @@ async def verify_user_participation(
273274
"course_name": course_name,
274275
},
275276
)
276-
raise Exception("ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๊ฐ€ ๊ฒ€์ƒ‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. \n๋””์Šค์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ์งˆ๋ฌธ๊ฒŒ์‹œํŒ์— ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”.")
277+
raise NotEligibleError(ErrorMessages.PROJECT_NOT_FOUND)
277278
except Exception as e:
278279
raise e
279280

โ€Žplatform/frontend/style.cssโ€Ž

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,7 @@ body {
14221422
/* Activities Section */
14231423
#activities {
14241424
padding-top: 2rem;
1425-
padding-bottom: 4rem;
1426-
/* Reduced since it's the last section before footer */
1425+
padding-bottom: 6rem;
14271426
}
14281427

14291428
.activities-grid {
@@ -1783,6 +1782,6 @@ body {
17831782
}
17841783

17851784
#activities {
1786-
padding-bottom: 8rem;
1785+
padding-bottom: 6rem;
17871786
}
17881787
}

0 commit comments

Comments
ย (0)