refactor: extract apply_applet_toggle, rooms_for_user & natus helpers to utils; DRY toggle views
All checks were successful
ci/woodpecker/push/pyswiss Pipeline was successful
ci/woodpecker/push/main Pipeline was successful

- epic/utils.py (new): _planet_house, _compute_distinctions, rooms_for_user
- applets/utils.py: apply_applet_toggle replaces 5 copy-pasted toggle loops
- dashboard/views.py: use apply_applet_toggle; fix double free_tokens/tithe_tokens query in wallet(); promote _compute_distinctions import to module level
- gameboard/views.py: use apply_applet_toggle & rooms_for_user; fix double free_tokens query in toggle_game_applets
- billboard/views.py: use apply_applet_toggle & rooms_for_user
- SCSS: %tt-token-fields placeholder in _tooltips.scss; _gameboard & _game-kit @extend it
- epic/tests/unit/test_utils.py (new): coverage for _planet_house fallback path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-04-21 15:46:30 -04:00
parent ea2bfa6ce1
commit 7c249500bd
10 changed files with 104 additions and 106 deletions

View File

@@ -0,0 +1,13 @@
from django.test import SimpleTestCase
from apps.epic.utils import _planet_house
class PlanetHouseFallbackTest(SimpleTestCase):
def test_returns_1_when_no_cusp_matches(self):
# Pathological cusps list: all 12 cusps identical (zero-width arcs).
# No range has start < end, and the wrap-around condition is also
# never satisfied, so the loop exhausts without returning — hitting
# the fallback `return 1`.
cusps = [0.0] * 12
self.assertEqual(_planet_house(180.0, cusps), 1)