feat: add Settings tab with provider management and language preferences
- Implemented AppSettings model and table using SQLModel. - Created Settings router with endpoints for preferences and provider toggling. - Added Settings tab to the UI with real-time health status of providers. - Integrated language and provider filtering into anime and series search logic. - Updated templates to respect user-defined settings.
This commit is contained in:
@@ -69,3 +69,4 @@ from .auth import UserTable
|
||||
from .watchlist import WatchlistItemTable, WatchlistSettingsTable
|
||||
from .favorites import FavoriteTable
|
||||
from .sonarr import SonarrMappingTable, SonarrConfigTable
|
||||
from .settings import AppSettingsTable
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Models for application settings with SQLModel support"""
|
||||
import uuid
|
||||
import json
|
||||
from pydantic import BaseModel, Field as PydanticField
|
||||
from typing import Optional, List, Dict
|
||||
from datetime import datetime
|
||||
from sqlmodel import SQLModel, Field, Column, String
|
||||
|
||||
|
||||
class AppSettingsBase(SQLModel):
|
||||
"""Base schema for application settings"""
|
||||
default_lang: str = Field(default="vostfr")
|
||||
theme: str = Field(default="dark")
|
||||
|
||||
# Store list of disabled providers as a JSON string
|
||||
disabled_providers_json: str = Field(default="[]", sa_column=Column(String))
|
||||
|
||||
@property
|
||||
def disabled_providers(self) -> List[str]:
|
||||
try:
|
||||
return json.loads(self.disabled_providers_json or "[]")
|
||||
except:
|
||||
return []
|
||||
|
||||
@disabled_providers.setter
|
||||
def disabled_providers(self, value: List[str]):
|
||||
self.disabled_providers_json = json.dumps(value or [])
|
||||
|
||||
|
||||
class AppSettingsTable(AppSettingsBase, table=True):
|
||||
"""Database table for application settings"""
|
||||
__tablename__ = "app_settings"
|
||||
|
||||
id: str = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
primary_key=True,
|
||||
index=True,
|
||||
nullable=False
|
||||
)
|
||||
user_id: str = Field(foreign_key="users.id", index=True, unique=True)
|
||||
updated_at: datetime = Field(default_factory=datetime.now)
|
||||
|
||||
|
||||
class AppSettings(BaseModel):
|
||||
"""Application settings (API Response)"""
|
||||
default_lang: str = "vostfr"
|
||||
theme: str = "dark"
|
||||
disabled_providers: List[str] = []
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class AppSettingsUpdate(BaseModel):
|
||||
"""Model for updating application settings"""
|
||||
default_lang: Optional[str] = None
|
||||
theme: Optional[str] = None
|
||||
disabled_providers: Optional[List[str]] = None
|
||||
Reference in New Issue
Block a user