mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 02:19:59 +03:00
- Added migration `0018_seed_opinionated_badge.py` to seed the badge. - Added logic in `users/services.py` to award the badge when user has 5 reviews. - Added signal in `users/signals.py` to trigger check on Review creation. - Added unit test `users/tests/test_opinionated_badge.py`. Current Focus Mode: C Impact on System: Adds gamification for user reviews. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
27 lines
734 B
Python
27 lines
734 B
Python
from django.db import migrations
|
|
|
|
def seed_opinionated_badge(apps, schema_editor):
|
|
Badge = apps.get_model('users', 'Badge')
|
|
Badge.objects.get_or_create(
|
|
slug='opinionated',
|
|
defaults={
|
|
'name': 'Opinionated',
|
|
'description': 'Wrote 5 reviews.',
|
|
'icon_url': '/static/badges/opinionated.png',
|
|
}
|
|
)
|
|
|
|
def remove_opinionated_badge(apps, schema_editor):
|
|
Badge = apps.get_model('users', 'Badge')
|
|
Badge.objects.filter(slug='opinionated').delete()
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('users', '0017_seed_critic_badge'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(seed_opinionated_badge, remove_opinionated_badge),
|
|
]
|