diff --git a/src/apps/epic/tests/integrated/test_views.py b/src/apps/epic/tests/integrated/test_views.py index 0609179..79a1230 100644 --- a/src/apps/epic/tests/integrated/test_views.py +++ b/src/apps/epic/tests/integrated/test_views.py @@ -1855,6 +1855,24 @@ class PickSeaRenderingTest(TestCase): self.assertIn("user_polarity", response.context) self.assertEqual(response.context["user_polarity"], "levity") # PC is levity + def test_my_tray_sig_comes_from_character_significator_when_confirmed(self): + """When sky_confirmed, my_tray_sig reads from Character.significator (not TableSeat).""" + char = Character.objects.create( + seat=self.pc_seat, + significator=self.sig_card, + confirmed_at=timezone.now(), + ) + # Give the seat a *different* sig card so we can distinguish the sources + other_card = TarotCard.objects.get( + deck_variant=self.earthman, arcana="MIDDLE", suit="GRAILS", number=11 + ) + self.pc_seat.significator = other_card + self.pc_seat.save() + + response = self.client.get(self.url) + self.assertEqual(response.context["my_tray_sig"], char.significator) + self.assertNotEqual(response.context["my_tray_sig"], other_card) + # ── select_role GET redirect ────────────────────────────────────────────────── @@ -2046,3 +2064,23 @@ class NatusSaveViewTest(TestCase): }) self.assertEqual(response.status_code, 200) self.assertTrue(response.json()["confirmed"]) + + def test_confirm_copies_seat_significator_to_character(self): + """natus_save with action=confirm copies seat.significator onto Character.""" + earthman, _ = DeckVariant.objects.get_or_create( + slug="earthman", defaults={"name": "Earthman Deck", "card_count": 108} + ) + sig_card = TarotCard.objects.filter(deck_variant=earthman).first() + pc_seat = TableSeat.objects.get(room=self.room, role="PC") + pc_seat.significator = sig_card + pc_seat.save() + + self._post({ + "birth_dt": "1990-06-15T09:00:00Z", + "birth_lat": 51.5, "birth_lon": -0.1, + "birth_place": "", "house_system": "O", + "chart_data": {}, "action": "confirm", + }) + + char = Character.objects.get(seat=pc_seat) + self.assertEqual(char.significator, sig_card) diff --git a/src/apps/epic/views.py b/src/apps/epic/views.py index fae779f..2e63114 100644 --- a/src/apps/epic/views.py +++ b/src/apps/epic/views.py @@ -352,14 +352,18 @@ def _role_select_context(room, user): elif user_role in _GRAVITY_ROLES: user_polarity = 'gravity' ctx["user_polarity"] = user_polarity - sky_confirmed = bool( - _canonical_seat and Character.objects.filter( + confirmed_char = ( + Character.objects.filter( seat=_canonical_seat, confirmed_at__isnull=False, retired_at__isnull=True, - ).exists() + ).first() + if _canonical_seat else None ) + sky_confirmed = confirmed_char is not None ctx["sky_confirmed"] = sky_confirmed + if sky_confirmed: + ctx["my_tray_sig"] = confirmed_char.significator return ctx @@ -1083,6 +1087,8 @@ def natus_save(request, room_id): char.house_system = body.get('house_system', Character.PORPHYRY) char.chart_data = body.get('chart_data') + char.significator = seat.significator + if body.get('action') == 'confirm': char.confirmed_at = timezone.now()