line_id_code_full: блокируем ячейку по line_id_code, не позволяем редактировать ячейку, если не было cell_edit_start
This commit is contained in:
parent
27e79a3df5
commit
f0358f640d
@ -272,7 +272,7 @@ class ConnectionManager:
|
|||||||
for lock_key in lock_keys:
|
for lock_key in lock_keys:
|
||||||
self.cell_locks.pop(lock_key, None)
|
self.cell_locks.pop(lock_key, None)
|
||||||
|
|
||||||
def is_locked_by_other(
|
def is_cell_available_for_edit(
|
||||||
self,
|
self,
|
||||||
con_key: ConnectionKeyEnum,
|
con_key: ConnectionKeyEnum,
|
||||||
user_id: int,
|
user_id: int,
|
||||||
@ -280,10 +280,10 @@ class ConnectionManager:
|
|||||||
form_key,
|
form_key,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
if not cell_key:
|
if not cell_key:
|
||||||
return False
|
return True
|
||||||
cell_key = frozenset(cell_key.items())
|
cell_key = frozenset(cell_key.items())
|
||||||
lock_owner_id = self.cell_locks.get((con_key, frozenset(form_key.items()), cell_key))
|
lock_owner_id = self.cell_locks.get((con_key, frozenset(form_key.items()), cell_key))
|
||||||
return lock_owner_id is not None and lock_owner_id != user_id
|
return lock_owner_id is not None and lock_owner_id == user_id
|
||||||
|
|
||||||
def is_row_locked_by_other(
|
def is_row_locked_by_other(
|
||||||
self,
|
self,
|
||||||
@ -662,7 +662,7 @@ def resolve_cell_key(event_data: dict) -> dict | None:
|
|||||||
if not data or "line_id" not in data or "column" not in data:
|
if not data or "line_id" not in data or "column" not in data:
|
||||||
return None
|
return None
|
||||||
return {
|
return {
|
||||||
"line_id": data["line_id"],
|
"line_id": data.get("line_id_code", data["line_id"]),
|
||||||
"column": data["column"],
|
"column": data["column"],
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +750,7 @@ async def process_websocket(
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
case "cell_updated":
|
case "cell_updated":
|
||||||
if manager.is_locked_by_other(
|
if not manager.is_cell_available_for_edit(
|
||||||
con_key=con_key,
|
con_key=con_key,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
cell_key=cell_key,
|
cell_key=cell_key,
|
||||||
@ -762,18 +762,18 @@ async def process_websocket(
|
|||||||
websocket,
|
websocket,
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
if cell_key and not manager.acquire_cell_lock(
|
# if cell_key and not manager.acquire_cell_lock(
|
||||||
con_key=con_key,
|
# con_key=con_key,
|
||||||
user_id=user_id,
|
# user_id=user_id,
|
||||||
cell_key=cell_key,
|
# cell_key=cell_key,
|
||||||
form_key=kwargs_process,
|
# form_key=kwargs_process,
|
||||||
):
|
# ):
|
||||||
data["error"] = "Ячейка уже редактируется другим пользователем"
|
# data["error"] = "Ячейка уже редактируется другим пользователем"
|
||||||
await manager.send_back(
|
# await manager.send_back(
|
||||||
data,
|
# data,
|
||||||
websocket,
|
# websocket,
|
||||||
)
|
# )
|
||||||
continue
|
# continue
|
||||||
case "row_deleted":
|
case "row_deleted":
|
||||||
if manager.is_row_locked_by_other(
|
if manager.is_row_locked_by_other(
|
||||||
con_key=con_key,
|
con_key=con_key,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user