fix(submissions): fix upload + bucket path
This commit is contained in:
@@ -37,6 +37,29 @@ def create_submission(
|
||||
return submission
|
||||
|
||||
|
||||
@router.get("/user", response=list[SubmissionOut])
|
||||
def list_user_submissions(request: HttpRequest, game_path: str):
|
||||
game = get_object_or_404(Game, path=game_path)
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
return 403, {"detail": "Authentication required"}
|
||||
|
||||
submissions = Submission.objects.filter(game=game, user=request.user).order_by(
|
||||
"-created_at"
|
||||
)
|
||||
return submissions
|
||||
|
||||
|
||||
@router.get("/game", response=list[SubmissionOut])
|
||||
def list_submissions_by_game(request: HttpRequest, game_path: str):
|
||||
game = get_object_or_404(Game, path=game_path)
|
||||
|
||||
if not request.user.is_staff:
|
||||
return 403, {"detail": "Admin access required"}
|
||||
|
||||
return Submission.objects.filter(game=game)
|
||||
|
||||
|
||||
@router.get("/{submission_id}", response=SubmissionOut)
|
||||
def get_submission(request: HttpRequest, submission_id: str):
|
||||
submission = get_object_or_404(Submission, id=submission_id)
|
||||
@@ -45,14 +68,3 @@ def get_submission(request: HttpRequest, submission_id: str):
|
||||
return 403, {"detail": "Not authorized"}
|
||||
|
||||
return submission
|
||||
|
||||
|
||||
@router.get("/game/{game_path}")
|
||||
def list_submissions_by_game(request: HttpRequest, game_path: str):
|
||||
game = get_object_or_404(Game, path=game_path)
|
||||
|
||||
if not request.user.is_staff:
|
||||
return 403, {"detail": "Admin access required"}
|
||||
|
||||
submissions = Submission.objects.filter(game=game)
|
||||
return [SubmissionOut.from_orm(s) for s in submissions]
|
||||
|
||||
Reference in New Issue
Block a user