fix: report empty projects as not locked

GET /projects/{id}/locked returned True for a project with no drawings
or nodes: both loops ran zero times and the fallback return won. Locking
and unlocking such a project always succeeded while the state stayed
"locked", so it could never be unlocked.

Report a project with nothing to lock as not locked, and re-check the
state after unlock in the route tests.
This commit is contained in:
YueGuobin committed 2026-08-25 13:45:36 +08:00
1 parent f31bfffefc
commit 97e7a79117
2 files changed
+30

No files matched your search

+4
View File
@@ -2141,6 +2141,10 @@ class Project:
Check if all items in a project are locked and not
"""
if not self._drawings and not self._nodes:
# a project without drawings or nodes has nothing to lock and would
# otherwise always report as locked, even after unlocking it
return False
for drawing in self._drawings.values():
if not drawing.locked:
return False