diff --git a/src/apps/epic/models.py b/src/apps/epic/models.py index 6a450ab..97bfd6b 100644 --- a/src/apps/epic/models.py +++ b/src/apps/epic/models.py @@ -136,6 +136,13 @@ def debit_token(user, slot, token): period = slot.room.renewal_period or timedelta(days=7) token.next_ready_at = timezone.now() + period token.save() + # Parity w. CARTE's drop_token unequip: a deposited COIN is committed + # elsewhere & can't be re-used as the active trinket until the deposit + # is released, so clear `equipped_trinket` to drop it out of the Kit + # Bag's Trinket slot. PASS stays equipped (auto-admits, never deposits). + if user.equipped_trinket_id == token.pk: + user.equipped_trinket = None + user.save(update_fields=["equipped_trinket"]) elif token.token_type == Token.CARTE: pass # current_room already set in drop_token; token not consumed elif token.token_type != Token.PASS: diff --git a/src/functional_tests/test_trinket_coin_on_a_string.py b/src/functional_tests/test_trinket_coin_on_a_string.py index 7779b32..48ac9c9 100644 --- a/src/functional_tests/test_trinket_coin_on_a_string.py +++ b/src/functional_tests/test_trinket_coin_on_a_string.py @@ -113,11 +113,16 @@ class CoinOnAStringTest(FunctionalTest): len(get_slot(1).find_elements(By.CSS_SELECTOR, ".btn-confirm")), 0 ) - # Kit bag's Trinkets section is now empty (COIN unequipped on deposit). + # Kit bag's Trinket section is now empty (COIN unequipped on deposit). + # Selector is scoped to .kit-bag-section--trinket because the Dice + # section ALSO renders a .kit-bag-placeholder unconditionally (dice + # feature isn't built yet) — a bare `.kit-bag-placeholder` selector + # would silently pass even if the trinket section still rendered COIN. self.browser.find_element(By.ID, "id_kit_btn").click() self.wait_for( lambda: self.browser.find_element( - By.CSS_SELECTOR, "#id_kit_bag_dialog .kit-bag-placeholder" + By.CSS_SELECTOR, + "#id_kit_bag_dialog .kit-bag-section--trinket .kit-bag-placeholder", ) ) diff --git a/src/templates/core/_partials/_kit_bag_panel.html b/src/templates/core/_partials/_kit_bag_panel.html index 955a917..51736d8 100644 --- a/src/templates/core/_partials/_kit_bag_panel.html +++ b/src/templates/core/_partials/_kit_bag_panel.html @@ -28,7 +28,7 @@ -
+
Trinket
{% if equipped_trinket %}