Skip to content

Commit d71f50a

Browse files
committed
model shall not silently do stuff
1 parent d40d435 commit d71f50a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/models-library/src/models_library/projects_state.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,17 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
146146

147147
@model_validator(mode="after")
148148
def check_model_valid(self) -> Self:
149-
self.locked = self.status in [
150-
ProjectStatus.CLONING,
151-
ProjectStatus.EXPORTING,
152-
ProjectStatus.MAINTAINING,
153-
]
149+
if (
150+
self.status
151+
in [
152+
ProjectStatus.CLONING,
153+
ProjectStatus.EXPORTING,
154+
ProjectStatus.MAINTAINING,
155+
]
156+
and not self.locked
157+
):
158+
msg = f"Project is {self.status=}, but it is not locked"
159+
raise ValueError(msg)
154160
if self.locked and not self.current_user_groupids:
155161
msg = "If the project is locked, the current_users list must contain at least the lock owner"
156162
raise ValueError(msg)

services/web/server/src/simcore_service_webserver/projects/_projects_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ async def _get_project_share_state(
16011601

16021602
return ProjectShareState(
16031603
status=ProjectStatus.OPENED,
1604-
locked=app_settings.WEBSERVER_REALTIME_COLLABORATION is None,
1604+
locked=bool(app_settings.WEBSERVER_REALTIME_COLLABORATION is None),
16051605
current_user_groupids=await limited_gather(
16061606
*[
16071607
users_service.get_user_primary_group_id(app, user_id=uid)

0 commit comments

Comments
 (0)