- 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>
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from django.db import models
|
|
|
|
|
|
class Notification(models.Model):
|
|
# انواع رویدادهایی که این اپ فقط بهشون گوش میده (event-listener)؛
|
|
# خودش تولیدکنندهی رویداد نیست. طبق سند معماری:
|
|
# LessonCompleted/XPEarned (Progress), OrderPaid (Payment),
|
|
# TicketReplied (Support).
|
|
TYPE_CHOICES = [
|
|
('xp_earned', 'امتیاز گرفتی'),
|
|
('lesson_completed', 'درس تکمیل شد'),
|
|
('node_completed', 'جزیره تمام شد'),
|
|
('order_paid', 'پرداخت موفق'),
|
|
('ticket_replied', 'پاسخ تیکت'),
|
|
]
|
|
|
|
user_id = models.IntegerField(db_index=True) # ارجاع سبک به accounts.User
|
|
type = models.CharField(max_length=30, choices=TYPE_CHOICES)
|
|
title = models.CharField(max_length=150)
|
|
body = models.CharField(max_length=300, blank=True)
|
|
related_id = models.IntegerField(null=True, blank=True) # id رکورد رویداد منبع، بدون FK واقعی
|
|
is_read = models.BooleanField(default=False)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
|
|
def __str__(self):
|
|
return f"notif-{self.id}-{self.type}-user{self.user_id}"
|