Skip to content

Commit

Permalink
feat: allowing to check in only at the day of workhop
Browse files Browse the repository at this point in the history
  • Loading branch information
fivan999 committed Nov 2, 2024
1 parent cb26256 commit 761b863
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/workshops/repository.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

from sqlalchemy import delete, select, update
from sqlalchemy.dialects.postgresql import insert
from sqlalchemy.ext.asyncio import AsyncSession
Expand Down Expand Up @@ -64,6 +66,12 @@ async def create(self, workshop_id: int, user_id: int) -> bool:
if exists:
return False

time_now = datetime.datetime.now(tz=None)
registration_start_time = workshop.dtend.replace(hour=0, minute=0, second=0)

if time_now < registration_start_time or time_now > workshop.dtstart:
return False

request = insert(CheckIn).values(workshop_id=workshop_id, user_id=user_id)
await self.session.execute(request)
await self.workshops_repository.update_remain_places(workshop_id, -1)
Expand Down

0 comments on commit 761b863

Please sign in to comment.