senior's post-demo changes: parent report in the student's own account, Jalali birth date, invoices, math-only tutor, priced quotas

- remove the family app from the root (separate parent accounts, invite codes, parental
  settings); progress.0006 drops its tables, permissions and migration history, and
  Profile.parent_phone, the two family notification types and ?userId= on
  /api/progress/nodes go with it
- GET /api/user/weekly-report: last 7 days next to the 7 before (estimated minutes,
  questions, accuracy, islands, tutor questions) for the "parent report" page
- profile birthDate in Jalali (accounts/jalali.py), ages 5-99, birthYear derived from it
- GET /api/payment/invoices; orders now snapshot list price and plan title
- tutor answers only math: server pre-filter, scope rule in the prompt (tutor-v11),
  refusal marker replaced with fixed text; self-harm gets a help line instead
- streamed answers now record token usage (it was always 0)
- daily tutor quota: AI_DAILY_QUOTA_FREE (default 3) vs Plan.ai_daily_quota
- delete_users management command for wiping test accounts across every app
- docs/ai-cost-and-guardrails.md: measured cost per question and guardrail results

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 02:38:43 +03:30
parent d5dbd1b23d
commit 39247f6d53
67 changed files with 1619 additions and 1140 deletions

View File

@@ -893,7 +893,7 @@ class UserProfileViewTests(TestCase):
self.assertIsNone(data['phone'])
self.assertIsNone(data['gradeId'])
self.assertIsNone(data['birthYear'])
self.assertEqual(data['parentPhone'], '')
self.assertIsNone(data['birthDate'])
self.assertEqual(data['bio'], '')
# get_or_create باید یک رکورد Profile واقعی ساخته باشه.
self.assertTrue(Profile.objects.filter(user_id=user.id).exists())
@@ -902,7 +902,7 @@ class UserProfileViewTests(TestCase):
user = User.objects.create(
phone='09120000001', is_guest=False, name='علی', avatar='avatar.png', grade_id=2,
)
Profile.objects.create(user=user, birth_year=2005, parent_phone='09120000002', bio='سلام')
Profile.objects.create(user=user, birth_year=1384, bio='سلام')
token = issue_access_token(user.id)
response = self._get_profile(token)
@@ -914,8 +914,7 @@ class UserProfileViewTests(TestCase):
self.assertEqual(data['avatar'], 'avatar.png')
self.assertEqual(data['isGuest'], False)
self.assertEqual(data['gradeId'], 2)
self.assertEqual(data['birthYear'], 2005)
self.assertEqual(data['parentPhone'], '09120000002')
self.assertEqual(data['birthYear'], 1384)
self.assertEqual(data['bio'], 'سلام')
def test_does_not_leak_other_users_profile(self):