feat: support rejected application status
This commit is contained in:
1 parent
08ec58c7e9
commit
cd33a382c0
5 files changed
+47
-15
No files matched your search
+10
-6
@@ -464,24 +464,28 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._json(200, {"deleted": calculation_id})
|
||||
|
||||
def do_PATCH(self) -> None: # noqa: N802
|
||||
"""Принимает заявку и запускает уведомление через PATCH API."""
|
||||
"""Меняет статус новой заявки через PATCH API."""
|
||||
parsed = urlparse(self.path)
|
||||
prefix = "/api/admin/applications/"
|
||||
if not parsed.path.startswith(prefix) or not parsed.path.endswith("/accept"):
|
||||
if not parsed.path.startswith(prefix):
|
||||
self._json(404, {"error": "Не найдено"})
|
||||
return
|
||||
if not self._admin_authorized():
|
||||
return
|
||||
raw_id = parsed.path[len(prefix):-len("/accept")].strip("/")
|
||||
raw_id, separator, action = parsed.path[len(prefix):].strip("/").partition("/")
|
||||
if not separator or action not in {"accept", "reject"}:
|
||||
self._json(404, {"error": "Не найдено"})
|
||||
return
|
||||
try:
|
||||
application = application_store().accept(int(raw_id))
|
||||
application = application_store().review(int(raw_id), status="accepted" if action == "accept" else "rejected")
|
||||
except (ValueError, ApplicationError) as exc:
|
||||
self._json(400, {"error": str(exc)})
|
||||
return
|
||||
if application is None:
|
||||
self._json(404, {"error": "Заявка не найдена или уже принята"})
|
||||
self._json(404, {"error": "Заявка не найдена или уже рассмотрена"})
|
||||
return
|
||||
sync_application_exports()
|
||||
if application["status"] == "accepted":
|
||||
sync_application_exports()
|
||||
self._json(200, {"item": application})
|
||||
|
||||
def log_message(self, format: str, *args: object) -> None:
|
||||
|
||||
Reference in new issue
Block a user