attach favorites to logged in user

This commit is contained in:
cwilvx
2024-05-25 15:12:44 +03:00
parent 300c8eb30b
commit 0b8a5e92f5
14 changed files with 128 additions and 38 deletions
+17 -3
View File
@@ -1,7 +1,10 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
import os
from pathlib import Path
from flask_jwt_extended import current_user
from app.settings import SessionVarKeys, get_flag
from app.utils.hashing import create_hash
from app.utils.parsers import (
@@ -40,11 +43,22 @@ class Track:
image: str = ""
artist_hashes: str = ""
is_favorite: bool = False
fav_userids: list = field(default_factory=list)
"""
A string of user ids separated by commas.
"""
# is_favorite: bool = False
@property
def is_favorite(self):
return current_user['id'] in self.fav_userids
# temporary attributes
_pos: int = 0 # for sorting tracks by disc and track number
_ati: str = "" # (album track identifier) for removing duplicates when merging album versions
_ati: str = (
"" # (album track identifier) for removing duplicates when merging album versions
)
og_title: str = ""
og_album: str = ""