77from django .db import models
88from django .http import FileResponse , HttpRequest , HttpResponse , JsonResponse
99from django .shortcuts import get_object_or_404 , redirect , render
10- from django .utils import timezone
10+ from django .utils import timezone , formats
1111
1212from .forms import DownloadSubmissionForm , GameForm , MatchForm , SubmissionForm
1313from .models import Game , Match , Submission
@@ -191,18 +191,21 @@ def queue_json(request: HttpRequest) -> HttpResponse:
191191 "id" : match .id ,
192192 "player1_name" : match .player1 .user .username ,
193193 "player2_name" : match .player2 .user .username ,
194- "score" : f"{ match .player1_wins } - { match .ties } - { match .player2_wins } "
194+ "score" : f"{ match .player1_wins } - { match .ties } - { match .player2_wins } "
195195 if match .status == "completed"
196196 else "-" ,
197197 "is_ranked" : "Yes" if match .is_ranked else "No" ,
198198 "status" : match .status ,
199199 "status_display" : match .get_status_display (),
200- "created_at" : match .created_at .isoformat (),
200+ "created_at" : formats .date_format (
201+ timezone .localtime (match .created_at ),
202+ "DATETIME_FORMAT" ,
203+ ),
201204 "can_view_replay" : request .user in [match .player1 .user , match .player2 .user ],
202- "player1_rating_delta" : float ( match .player1_rating_delta )
205+ "player1_rating_delta" : match .player1_rating_delta
203206 if match .player1_rating_delta
204207 else None ,
205- "player2_rating_delta" : float ( match .player2_rating_delta )
208+ "player2_rating_delta" : match .player2_rating_delta
206209 if match .player2_rating_delta
207210 else None ,
208211 }
@@ -218,6 +221,7 @@ def queue_json(request: HttpRequest) -> HttpResponse:
218221 )
219222
220223
224+ @login_required
221225def queue (request : HttpRequest ) -> HttpResponse :
222226 matches = Match .objects .all ().order_by ("-created_at" )
223227 my_matches_only = request .GET .get ("my_matches" ) == "1"
0 commit comments