Fix add_session prefilling game from last session
When no game_id is provided, the session form should start with no game selected rather than defaulting to the last session's game. https://claude.ai/code/session_01BZHdra2YBPwS3umwsGrgUj
This commit is contained in:
@@ -244,10 +244,6 @@ def _session_fields(form) -> SafeText:
|
|||||||
def add_session(request: HttpRequest, game_id: int = 0) -> HttpResponse:
|
def add_session(request: HttpRequest, game_id: int = 0) -> HttpResponse:
|
||||||
initial: dict[str, Any] = {"timestamp_start": timezone.now()}
|
initial: dict[str, Any] = {"timestamp_start": timezone.now()}
|
||||||
|
|
||||||
last = Session.objects.last()
|
|
||||||
if last is not None:
|
|
||||||
initial["game"] = last.game
|
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = SessionForm(request.POST or None, initial=initial)
|
form = SessionForm(request.POST or None, initial=initial)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
|||||||
Reference in New Issue
Block a user