sky wheel: element contributor display; sign + house tooltips — TDD
All checks were successful
ci/woodpecker/push/pyswiss Pipeline was successful
ci/woodpecker/push/main Pipeline was successful

sky_save now re-fetches from PySwiss server-side on save so stored
chart_data always carries enriched element format (contributors/stellia/
parades). New sky/data endpoint serves fresh PySwiss data to the My Sky
applet on load, replacing the stale inline json_script approach.

natus-wheel.js: sign ring slices (data-sign-name) and house ring slices
(data-house) now have click handlers with _activateSign/_activateHouse;
em-dash fallback added for classic elements with empty contributor lists.
Action URLs sky/preview, sky/save, sky/data lose trailing slashes.

Jasmine: T12 sign tooltip, T13 house tooltip, T14 enriched element
contributor display (symbols, Stellium/Parade formations, em-dash fallback).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-04-21 20:07:40 -04:00
parent 02975d79d3
commit b8ac004fb6
10 changed files with 868 additions and 95 deletions

View File

@@ -301,8 +301,8 @@ def _sky_natus_preview(request):
@login_required(login_url="/")
def sky_view(request):
return render(request, "apps/dashboard/sky.html", {
"preview_url": request.build_absolute_uri("/dashboard/sky/preview/"),
"save_url": request.build_absolute_uri("/dashboard/sky/save/"),
"preview_url": request.build_absolute_uri("/dashboard/sky/preview"),
"save_url": request.build_absolute_uri("/dashboard/sky/save"),
"saved_sky": request.user.sky_chart_data,
"saved_birth_dt": request.user.sky_birth_dt,
"saved_birth_place": request.user.sky_birth_place,
@@ -327,21 +327,72 @@ def sky_save(request):
user = request.user
birth_dt_str = body.get('birth_dt', '')
birth_dt_utc = None
if birth_dt_str:
try:
naive = datetime.fromisoformat(birth_dt_str.replace('Z', '+00:00'))
user.sky_birth_dt = naive if naive.tzinfo else naive.replace(
tzinfo=zoneinfo.ZoneInfo('UTC')
)
birth_dt_utc = user.sky_birth_dt.astimezone(zoneinfo.ZoneInfo('UTC'))
except ValueError:
user.sky_birth_dt = None
user.sky_birth_lat = body.get('birth_lat')
user.sky_birth_lon = body.get('birth_lon')
user.sky_birth_place = body.get('birth_place', '')
user.sky_house_system = body.get('house_system', 'O')
user.sky_chart_data = body.get('chart_data')
lat_str = body.get('birth_lat')
lon_str = body.get('birth_lon')
if birth_dt_utc and lat_str is not None and lon_str is not None:
try:
dt_iso = birth_dt_utc.strftime('%Y-%m-%dT%H:%M:%SZ')
resp = http_requests.get(
settings.PYSWISS_URL + '/api/chart/',
params={'dt': dt_iso, 'lat': str(lat_str), 'lon': str(lon_str)},
timeout=5,
)
resp.raise_for_status()
enriched = resp.json()
if 'elements' in enriched and 'Earth' in enriched['elements']:
enriched['elements']['Stone'] = enriched['elements'].pop('Earth')
user.sky_chart_data = enriched
except Exception:
user.sky_chart_data = body.get('chart_data')
else:
user.sky_chart_data = body.get('chart_data')
user.save(update_fields=[
'sky_birth_dt', 'sky_birth_lat', 'sky_birth_lon',
'sky_birth_place', 'sky_house_system', 'sky_chart_data',
])
return JsonResponse({"saved": True})
@login_required(login_url="/")
def sky_natus_data(request):
user = request.user
if not user.sky_birth_lat or not user.sky_birth_lon or not user.sky_birth_dt:
return HttpResponse(status=404)
try:
utc_dt = user.sky_birth_dt.astimezone(zoneinfo.ZoneInfo('UTC'))
dt_iso = utc_dt.strftime('%Y-%m-%dT%H:%M:%SZ')
resp = http_requests.get(
settings.PYSWISS_URL + '/api/chart/',
params={
'dt': dt_iso,
'lat': str(user.sky_birth_lat),
'lon': str(user.sky_birth_lon),
},
timeout=5,
)
resp.raise_for_status()
except Exception:
return HttpResponse(status=502)
data = resp.json()
if 'elements' in data and 'Earth' in data['elements']:
data['elements']['Stone'] = data['elements'].pop('Earth')
data['distinctions'] = _compute_distinctions(data['planets'], data['houses'])
return JsonResponse(data)