mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 05:07:10 +00:00
add callback to start competition endpoint
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
from http import HTTPStatus as status
|
from http import HTTPStatus as status
|
||||||
|
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
from ninja import Router
|
from ninja import Router
|
||||||
|
|
||||||
from api.v1.schemas import NotFoundError, UnauthorizedError, ForbiddenError
|
from api.v1.schemas import NotFoundError, UnauthorizedError, ForbiddenError
|
||||||
from api.v1.ping.schemas import PingOut
|
from api.v1.ping.schemas import PingOut
|
||||||
from api.v1.task.schemas import TaskOutSchema
|
from api.v1.task.schemas import TaskOutSchema
|
||||||
|
from apps.competition.models import Competition, State
|
||||||
|
|
||||||
router = Router(tags=["competition"])
|
router = Router(tags=["competition"])
|
||||||
|
|
||||||
@@ -19,7 +21,11 @@ router = Router(tags=["competition"])
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
def start_competition(request, competition_id: str) -> PingOut:
|
def start_competition(request, competition_id: str) -> PingOut:
|
||||||
...
|
competition = get_object_or_404(Competition, pk=competition_id)
|
||||||
|
state_obj, _ = State.objects.update_or_create(
|
||||||
|
user=request.auth, competition=competition, state="started"
|
||||||
|
)
|
||||||
|
return status.OK, PingOut()
|
||||||
|
|
||||||
|
|
||||||
@router.get(
|
@router.get(
|
||||||
|
|||||||
Reference in New Issue
Block a user