All checks were successful
Build and Push Docker Image / build (push) Successful in 51s
- Implemented `Favorite` model with unique user-item constraint and timestamped records - Added `favorites:index` and `favorites:toggle` views with AJAX support for toggling favorites - Built templates and front-end assets for the favorites page and integration with item grids - Extended header with favorites link and dynamic counter - Added tests covering models, views, and templates for the favorites functionality - Updated admin to enable management of favorites via Django admin interface
13 lines
274 B
Python
13 lines
274 B
Python
from typing import Any
|
|
|
|
from favorites.models import Favorite
|
|
|
|
|
|
def get_user_favorite_item_ids(user: Any) -> set[int]:
|
|
if not user.is_authenticated:
|
|
return set()
|
|
|
|
return set(
|
|
Favorite.objects.filter(user=user).values_list("item_id", flat=True)
|
|
)
|