mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 02:19:59 +03:00
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>
29 lines
828 B
Python
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),
|
|
]
|