Files
offline-db/users/migrations/0009_seed_collector_badge.py
google-labs-jules[bot] 149e27783c feat(users): added Collector badge for 10 subscriptions (#82)
Current Focus Mode: C (The Architect)
Changes Made:
- Added `Collector` badge seed migration.
- Updated `users/services.py` to check for 10 subscriptions.
- Updated `users/signals.py` to trigger badge check on `Subscription.post_save`.
- Added unit test in `users/tests/test_badges.py`.

Impact on System:
- Users will now be automatically awarded the 'Collector' badge when they subscribe to their 10th anime.
- Adds incentive for users to use the subscription feature.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-20 20:17:56 +00:00

29 lines
828 B
Python

# Generated by Django 5.1.6
from django.db import migrations
def create_collector_badge(apps, schema_editor):
Badge = apps.get_model('users', 'Badge')
badge_data = {
'slug': 'collector',
'name': 'Collector',
'description': 'Subscribed to 10 different anime',
'icon_url': '/static/badges/collector.png'
}
if not Badge.objects.filter(slug=badge_data['slug']).exists():
Badge.objects.create(**badge_data)
def remove_collector_badge(apps, schema_editor):
Badge = apps.get_model('users', 'Badge')
Badge.objects.filter(slug='collector').delete()
class Migration(migrations.Migration):
dependencies = [
('users', '0008_seed_social_butterfly'),
]
operations = [
migrations.RunPython(create_collector_badge, remove_collector_badge),
]