Add per-photo-widget lock (freezes current photo until unlocked)
A "Lock this photo" button in the photos widget's dialog toggles PhotoWidgetConfig.locked, which suppresses both the timer-elapsed auto-advance and the advance/back button actions until unlocked. The Layout tab canvas shows a lock badge on any locked photo widget's box.
This commit is contained in:
@@ -109,6 +109,41 @@ def test_advance_action_is_a_no_op_when_unconfigured(db_session):
|
||||
assert cfg.current_asset_id == ""
|
||||
|
||||
|
||||
def test_render_does_not_advance_when_locked(db_session, monkeypatch):
|
||||
frame, widget = _make_widget(db_session)
|
||||
monkeypatch.setattr(widgets.photos, "immich_client_for", lambda frame: object())
|
||||
monkeypatch.setattr(widgets.photos, "list_assets", lambda client, album_id: _ASSETS)
|
||||
source = Image.new("RGB", (100, 80), (10, 20, 30))
|
||||
monkeypatch.setattr(widgets.photos, "fetch_source_and_faces", lambda client, mode, asset_id: (source, None))
|
||||
|
||||
with widget_locked(db_session, frame.id, widget.id) as (_, _, cfg):
|
||||
cfg.current_asset_id = "asset-1"
|
||||
cfg.current_asset_set_at = 0.0 # long ago -- refresh_interval_s has definitely elapsed
|
||||
cfg.locked = True
|
||||
|
||||
widgets.photos.render(db_session, frame, widget, 400, 300)
|
||||
|
||||
cfg = db_session.get(PhotoWidgetConfig, widget.id)
|
||||
assert cfg.current_asset_id == "asset-1"
|
||||
|
||||
|
||||
def test_advance_and_back_actions_are_no_ops_when_locked(db_session, monkeypatch):
|
||||
frame, widget = _make_widget(db_session)
|
||||
monkeypatch.setattr(widgets.photos, "immich_client_for", lambda frame: object())
|
||||
monkeypatch.setattr(widgets.photos, "list_assets", lambda client, album_id: _ASSETS)
|
||||
|
||||
with widget_locked(db_session, frame.id, widget.id) as (_, _, cfg):
|
||||
cfg.current_asset_id = "asset-1"
|
||||
cfg.locked = True
|
||||
|
||||
widgets.photos.ACTIONS["advance"](db_session, frame, widget)
|
||||
widgets.photos.ACTIONS["back"](db_session, frame, widget)
|
||||
|
||||
cfg = db_session.get(PhotoWidgetConfig, widget.id)
|
||||
assert cfg.current_asset_id == "asset-1"
|
||||
assert cfg.history == []
|
||||
|
||||
|
||||
def test_advance_uses_the_frame_stats_counter_not_the_widget_config():
|
||||
"""advance_forced's frame/stats split (see app/photo_queue.py) means
|
||||
stats_photos_displayed should land on the Frame row, never on
|
||||
|
||||
Reference in New Issue
Block a user