Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #104 from SoyBeansLab/feature/registration_delete
Browse files Browse the repository at this point in the history
registrationにdeleteを追加
  • Loading branch information
ucpr authored Sep 16, 2020
2 parents 420a41d + 947562d commit 4006aee
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/domain/Registration/database/registration_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def find(self, contest_id: str, username: str):
if not row:
return None
return Registration(*row)

def delete(self, contest_id: str, username: str):
query = (
"DELETE FROM registrations WHERE contest_id = %s AND username = %s"
)
3 changes: 3 additions & 0 deletions src/domain/Registration/usecase/registration_interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ def registrations(self) -> List[Registration]:

def registration(self) -> Registration:
return self.repository.find()

def delete(self, contest_id: str, username: str) -> None:
return self.repository.delete(contest_id, username)
4 changes: 4 additions & 0 deletions src/domain/Registration/usecase/registration_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ def find_all(self) -> List[Registration]:
@abstractmethod
def find(self, contest_id: str, username: str) -> Registration:
raise NotImplementedError()

@abstractmethod
def delete(self, contest_id: str, username: str) -> None:
raise NotImplementedError()
6 changes: 6 additions & 0 deletions src/infrastructure/waf/fastapi/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ def set_router_registration(api: FastAPI) -> None:
methods=["POST"],
tags=["registrations"],
)
api.add_api_route(
"/registration",
registration_controller.delete,
methods=["DELETE"],
tags=["registrations"],
)


def set_route_notification(api: FastAPI) -> None:
Expand Down
9 changes: 9 additions & 0 deletions src/interface/controllers/registration_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ async def registrations(self):

async def registration(self):
pass

async def delete(self, contest_id: str, username: str) -> None:
resp = dict()
self.interactor.delete(contest_id, username)

resp["status"] = "Success"
resp["message"] = "Delete registraion"

return resp

0 comments on commit 4006aee

Please sign in to comment.