add gamification characters (Duolingo-style mascot catalog)

New progress.Character model: an admin-managed catalog (same pattern as
subscription.Plan) of selectable mascots, each unlocked once the user's
XP crosses unlock_xp. No separate ownership table yet — unlocking is a
pure function of UserStats.xp, kept intentionally minimal since this is
the first of an incremental rollout the senior asked for.

- GET /api/characters — catalog with per-user unlocked/selected flags
- POST /api/characters/select — picks an active character, rejecting
  ones the user hasn't unlocked yet
- UserStats.selected_character_id tracks the pick
- seed_test_data now seeds 4 sample characters (owl/fox/turtle/lion)
  for local/staging testing

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-06 13:53:17 +03:30
parent b5476e1c5d
commit 37a1741e0e
9 changed files with 266 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
# Generated by Django 5.2.17 on 2026-09-06 10:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('progress', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Character',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(unique=True)),
('name', models.CharField(max_length=50)),
('icon', models.CharField(max_length=100)),
('unlock_xp', models.PositiveIntegerField(default=0)),
('order', models.PositiveIntegerField(default=0)),
],
options={
'ordering': ['order', 'unlock_xp'],
},
),
migrations.AddField(
model_name='userstats',
name='selected_character_id',
field=models.IntegerField(blank=True, null=True),
),
]