This commit is contained in:
confestim 2023-05-09 04:53:50 +02:00
parent d3772eae5e
commit 489a06504f
2 changed files with 9 additions and 1 deletions

View File

@ -154,6 +154,8 @@ class Scraper:
# If you are indeed the creator, create the game and disclose its name to the server # If you are indeed the creator, create the game and disclose its name to the server
if checker["creator"] == name: if checker["creator"] == name:
created = game.create() created = game.create()
# TODO: This doesn't work, because we need to serve stuff separately(as in private keys)
# Fix
requests.put(f"{self.URL}/current/1", data={ requests.put(f"{self.URL}/current/1", data={
"lobby_name": created, "lobby_name": created,
"players": 1, "players": 1,

View File

@ -43,9 +43,14 @@ def current(request):
Creates/edits/deletes the current game that's being played and orchestrates Creates/edits/deletes the current game that's being played and orchestrates
the matchmaking process. the matchmaking process.
""" """
# Change # We need to get the singular game that we want based on the creator
# We can't use the default get_object_or_404 because we need to get the
# object based on the creator, not the pk
current = Current.objects.all() current = Current.objects.all()
if request.method == "GET": if request.method == "GET":
serializer = CurrentSerializer(current, many=True) serializer = CurrentSerializer(current, many=True)
return Response(serializer.data) return Response(serializer.data)
@ -59,6 +64,7 @@ def current(request):
return Response("Invalid data.", status=status.HTTP_400_BAD_REQUEST) return Response("Invalid data.", status=status.HTTP_400_BAD_REQUEST)
if request.method == "PUT": if request.method == "PUT":
current = Current.objects.filter(creator=request.data.get("creator", None)).first()
if not current: if not current:
return Response("Current game doesn't exist.", status=status.HTTP_404_NOT_FOUND) return Response("Current game doesn't exist.", status=status.HTTP_404_NOT_FOUND)
serializer = CurrentSerializer(current, data=request.data) serializer = CurrentSerializer(current, data=request.data)