public user IDs, plans priced by tutor cost, age-based tutor tone, self-service account deletion

- profile publicId ("User482917", accounts/public_id.py); admin shows and searches it
- plans API reports aiDailyQuota per plan and freeAiDailyQuota; migration 0007 sets the
  temporary prices (monthly 99,000 / yearly 990,000 toman, 5 tutor questions a day) unless
  an admin already edited the yearly plan
- tutor tone follows the learner's age (18+ gets an adult tone at any grade); notation
  still follows the grade's book; answer cache keyed by tone (prompt tutor-v12-age-tone)
- POST /api/user/delete: phone users confirm with a fresh SMS code (same checks as login,
  now shared in verify_phone_otp), guests type "حذف"; payment records are kept, demo
  accounts refused
- delete_users --skip-paid

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 06:10:17 +03:30
parent e9d676ce68
commit 63cd1af6f7
18 changed files with 468 additions and 78 deletions

View File

@@ -1,3 +1,4 @@
from django.conf import settings
from django.core.cache import cache
from django.db import transaction
from django.db.models import F
@@ -42,7 +43,7 @@ class GuestAwarePurchaseThrottle(ScopedRateThrottle):
# پلن‌ها تقریباً هیچ‌وقت عوض نمی‌شوند و روی صفحه‌ی اشتراک هر بار خوانده می‌شوند.
# با هر save/delete روی Plan کش باطل می‌شود (subscription/receivers.py).
PLANS_CACHE_KEY = 'subscription:plans:v1'
PLANS_CACHE_KEY = 'subscription:plans:v2' # v2: aiDailyQuota و freeAiDailyQuota
PLANS_CACHE_TTL = 3600
@@ -64,9 +65,11 @@ class PlansListView(APIView):
'durationDays': p.duration_days,
'features': p.features or [],
'badge': p.badge,
'aiDailyQuota': p.ai_daily_quota,
}
for p in Plan.objects.all()
]
for p in Plan.objects.order_by('duration_days', 'price')
],
'freeAiDailyQuota': settings.AI_DAILY_QUOTA_FREE,
}
data = cache.get_or_set(PLANS_CACHE_KEY, build, PLANS_CACHE_TTL)