Files
google-labs-jules[bot] ff22ca9a80 feat(users): add Night Owl badge and User Badges API (#66)
- Added `UserBadgeListAPIView`, `BadgeSerializer`, `UserBadgeSerializer` to expose user badges.
- Added URL path `/api/users/badges/`.
- Added logic for 'Night Owl' badge in `users/services.py` (watching between 2 AM and 5 AM).
- Added data migration `0005_seed_night_owl.py`.
- Added tests for Night Owl logic and API in `users/tests/test_badges.py` and `users/tests/test_badges_api.py`.

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

26 lines
767 B
Python

from django.db import migrations
def create_night_owl_badge(apps, schema_editor):
Badge = apps.get_model('users', 'Badge')
if not Badge.objects.filter(slug='night-owl').exists():
Badge.objects.create(
slug='night-owl',
name='Night Owl',
description='Watched an episode between 2 AM and 5 AM',
icon_url='/static/badges/night-owl.png'
)
def remove_night_owl_badge(apps, schema_editor):
Badge = apps.get_model('users', 'Badge')
Badge.objects.filter(slug='night-owl').delete()
class Migration(migrations.Migration):
dependencies = [
('users', '0004_notification'),
]
operations = [
migrations.RunPython(create_night_owl_badge, remove_night_owl_badge),
]