Files
MathApp/progress/admin.py
Zareian 37a1741e0e 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>
2026-09-06 13:53:17 +03:30

37 lines
1.1 KiB
Python

from django.contrib import admin
from .models import ActiveDay, Character, LeaderboardEntry, StreakRecord, UserHearts, UserStats
@admin.register(UserStats)
class UserStatsAdmin(admin.ModelAdmin):
list_display = ('id', 'user_id', 'xp', 'coins', 'progress_percent', 'selected_character_id')
@admin.register(Character)
class CharacterAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'slug', 'icon', 'unlock_xp', 'order')
ordering = ('order', 'unlock_xp')
@admin.register(LeaderboardEntry)
class LeaderboardEntryAdmin(admin.ModelAdmin):
list_display = ('id', 'user_id', 'period', 'xp_in_period', 'rank')
list_filter = ('period',)
class ActiveDayInline(admin.TabularInline):
model = ActiveDay
extra = 1
@admin.register(StreakRecord)
class StreakRecordAdmin(admin.ModelAdmin):
list_display = ('id', 'user_id', 'current_streak', 'longest_streak')
inlines = [ActiveDayInline]
@admin.register(UserHearts)
class UserHeartsAdmin(admin.ModelAdmin):
list_display = ('id', 'user_id', 'current_hearts', 'max_hearts', 'next_refill_at')