sky: store birth_tz, prefill form from User model, drop localStorage
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -303,9 +303,12 @@ 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"),
|
||||
"saved_sky": request.user.sky_chart_data,
|
||||
"saved_sky": request.user.sky_chart_data,
|
||||
"saved_birth_dt": request.user.sky_birth_dt,
|
||||
"saved_birth_place": request.user.sky_birth_place,
|
||||
"saved_birth_lat": request.user.sky_birth_lat,
|
||||
"saved_birth_lon": request.user.sky_birth_lon,
|
||||
"saved_birth_tz": request.user.sky_birth_tz,
|
||||
"page_class": "page-sky",
|
||||
})
|
||||
|
||||
@@ -338,12 +341,13 @@ def sky_save(request):
|
||||
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_birth_tz = body.get('birth_tz', '')
|
||||
user.sky_house_system = body.get('house_system', 'O')
|
||||
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',
|
||||
'sky_birth_place', 'sky_birth_tz', 'sky_house_system', 'sky_chart_data',
|
||||
])
|
||||
return JsonResponse({"saved": True})
|
||||
|
||||
|
||||
18
src/apps/lyric/migrations/0019_sky_birth_tz.py
Normal file
18
src/apps/lyric/migrations/0019_sky_birth_tz.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 6.0 on 2026-04-22 01:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lyric', '0018_user_sky_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='sky_birth_tz',
|
||||
field=models.CharField(blank=True, max_length=64),
|
||||
),
|
||||
]
|
||||
@@ -52,6 +52,7 @@ class User(AbstractBaseUser):
|
||||
sky_birth_lat = models.DecimalField(max_digits=9, decimal_places=4, null=True, blank=True)
|
||||
sky_birth_lon = models.DecimalField(max_digits=9, decimal_places=4, null=True, blank=True)
|
||||
sky_birth_place = models.CharField(max_length=255, blank=True)
|
||||
sky_birth_tz = models.CharField(max_length=64, blank=True)
|
||||
sky_house_system = models.CharField(max_length=1, blank=True, default="O")
|
||||
sky_chart_data = models.JSONField(null=True, blank=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user