From 01ecc8376893404cb026e34e7f8fecbefcd082cf Mon Sep 17 00:00:00 2001 From: Awoodwhale Date: Sat, 6 May 2023 17:42:04 +0800 Subject: [PATCH] refactor: refactor the way to check article level --- app/admin_service.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/admin_service.py b/app/admin_service.py index 1d1ba6e..a604b5e 100644 --- a/app/admin_service.py +++ b/app/admin_service.py @@ -91,10 +91,7 @@ def article(): question = data.get("question", "") level = data.get("level", "4") if content: - try: # check level - if level not in ['1', '2', '3', '4']: - raise ValueError - except ValueError: + if level not in ['1', '2', '3', '4']: return "Level must be between 1 and 4." add_article(content, source, level, question) _update_context()