feat: exclude source photos from automatic selection
This commit is contained in:
@@ -15,6 +15,7 @@ from xml.etree import ElementTree
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from pigway_frame_flow.core.photo_preferences import eligible
|
||||
from pigway_frame_flow.errors import ErrorCode as E
|
||||
from pigway_frame_flow.errors import FlowError
|
||||
from pigway_frame_flow.models import StrictModel
|
||||
@@ -60,6 +61,8 @@ class PhotoSourceView(PhotoSourceInput):
|
||||
|
||||
|
||||
class PhotoItem(StrictModel):
|
||||
starred: bool = False
|
||||
excluded: bool = False
|
||||
id: str
|
||||
name: str
|
||||
caption: dict[str, str] | None = None
|
||||
@@ -220,6 +223,7 @@ class PhotoSources:
|
||||
self.db.execute(
|
||||
"DELETE FROM app_config WHERE key=?", ("photo_source:" + source_id,)
|
||||
)
|
||||
self.db.execute("DELETE FROM photo_preferences WHERE source_id=?", (source_id,))
|
||||
self.cache.pop(source_id, None)
|
||||
self.api_items.pop(source_id, None)
|
||||
|
||||
@@ -581,9 +585,11 @@ class PhotoSources:
|
||||
def read(self, source_id, item_id=None, *, target_size=(1200, 1600)):
|
||||
source = self.get(source_id)
|
||||
items = self.catalog(source_id, target_size=target_size)
|
||||
if not item_id:
|
||||
items = eligible(self.db, source_id, items)
|
||||
if not items:
|
||||
raise FlowError(
|
||||
E.NOT_FOUND, "Photo source contains no supported images", 404
|
||||
E.NOT_FOUND, "Photo source contains no eligible images", 404
|
||||
)
|
||||
item = (
|
||||
next((x for x in items if x["id"] == item_id), None)
|
||||
|
||||
Reference in New Issue
Block a user