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

@@ -66,7 +66,6 @@ API docs: Swagger `/api/docs/`, Redoc `/api/redoc/`, admin `/admin/`.
| `notifications` | notifications | `Notification` |
| `affiliate` | referral program | `AffiliateAccount`, `Conversion` |
| `support` | tickets/bug reports | `BugReport`, `Ticket`, `TicketMessage` |
| `family` | parental control | `FamilyLink`, `ParentalSettings`, `WeeklyReportLog` |
| `statuslog` | generic cross-app status-change log | `StatusChangeLog` |
| `campaigns` | messaging campaign storage only, no send logic yet | `MessageCampaign` |
| `config` | project settings, root urls, middleware | — |
@@ -388,6 +387,29 @@ preferred setup, because there is then no key to leak. **Never let the server ru
`django-insecure-…` fallback from `config/settings.py`: that string is committed here, so
anyone who can read this repo can forge a token for any user.**
## وضعیت ۲۰۲۶-۱۰-۰۲ — تصمیم‌های سینیور پس از ارائه
- **بخشِ والدین از ریشه حذف شد.** اپِ `family` دیگر وجود ندارد. جدول‌هایش، مجوزهای ادمینش و ردش در
`django_migrations` را migrationِ `progress.0006` پاک می‌کند. `Profile.parent_phone`، دو نوع اعلانِ
والدین و پارامترِ `?userId=` در `/api/progress/nodes` هم رفتند. جایش «گزارشِ والدین» در پروفایلِ
خودِ دانش‌آموز است: `GET /api/user/weekly-report` (`progress/report.py`)، ۷ روزِ اخیر در کنارِ
۷ روزِ قبل. **`minutes` تخمین است**، از فاصله‌ی جواب‌ها؛ heartbeat عمداً ساخته نشد.
- **تاریخِ تولدِ شمسی** به‌جای «سن»: `birthDate` («1385-04-12»)، میلادی ذخیره می‌شود و تبدیلش فقط در
`accounts/jalali.py` است. `birthYear` از آن پر می‌شود و `age` حذف شد. بازه‌ی سن ۵ تا ۹۹ است. در
فرانت سه فهرستِ روز/ماه/سال (`BirthDatePicker`) هست و برای ۱۹+ سوالِ «ریاضیِ کدوم پایه؟» پرسیده می‌شود.
- **شناسه‌ی کاربری** زیرِ نام در پروفایل. **فاکتورها:** `GET /api/payment/invoices` و صفحه‌ی
«پرداخت‌ها و فاکتورها». `Order.list_price` و `plan_title` در لحظه‌ی خرید ثبت می‌شوند تا فاکتور با
عوض شدنِ پلن تغییر نکند.
- **دستیار فقط ریاضی** (`rag/services/guardrails.py`، پرامپت `tutor-v11-math-only`). آزمونِ زنده ۷ از ۷
رد شد؛ شرحش در `docs/ai-cost-and-guardrails.md` است.
- **هزینه:** هر سوال حدودِ ۰٫۲ سنت (≈۶۰۰ تومان) است و ۷۰٪ِ آن ورودی است. **سقفِ روزانه:** رایگان
`AI_DAILY_QUOTA_FREE` (پیش‌فرض ۳)، مشترک `Plan.ai_daily_quota` (ادمین، پیش‌فرض ۱۵). تا امروز همه ۱۵
داشتند. گزارشِ مدیرعامل در `~/Desktop/گزارشات Tadrisino/گزارش-هزینه-دستیار/` است. مسیرِ استریم
حالا توکن‌ها را ثبت می‌کند (پیش از این صفر بود). خرجِ GapGPTِ آن روز حدودِ ۴ سنت بود.
- ⚠️ **لحنِ دستیار هنوز از روی پایه است، نه سن**؛ بزرگسالی که پایه‌ی سوم را بردارد لحنِ دبستانی
می‌گیرد. این تصمیمِ محصولی است و سنجش می‌خواهد.
- `spectacular --validate` یک خطای از پیش موجود دارد (روی `d5dbd1b` هم بود) که به این تغییرها ربطی ندارد.
## وضعیت ۲۰۲۶-۰۹-۳۰ — بازار وصل شد
- حسابِ **شرکت** در بازار «اجازه» داد (۰۹-۳۰ ۱۲:۰۶، `bazaar: true`). اسمِ پکیج را کسی نداد؛ با توکنِ خودمان