mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 02:19:59 +03:00
- Added migration to seed 'Otaku' badge - Implemented logic in `users/services.py` to award the badge for completing 5 anime series - Added tests in `users/tests/test_otaku_badge.py` - Optimized DB queries to avoid N+1 issue Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
25 lines
608 B
Python
25 lines
608 B
Python
# Generated by Django 5.1.6 on 2026-01-23 00:00
|
|
|
|
from django.db import migrations
|
|
|
|
def seed_otaku_badge(apps, schema_editor):
|
|
Badge = apps.get_model('users', 'Badge')
|
|
Badge.objects.get_or_create(
|
|
slug='otaku',
|
|
defaults={
|
|
'name': 'Otaku',
|
|
'description': 'Completed 5 different anime series.',
|
|
'icon_url': '/static/badges/otaku.png'
|
|
}
|
|
)
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('users', '0029_seed_review_guru_and_star_power'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(seed_otaku_badge),
|
|
]
|