refactor(5-1): 층 쓰기 권한 판단 한 벌 — M02_Layer_Access.can_write · 거울 시험
- M02_Layer_Access 에 can_write(session, here) 더함(옛 Library_Delete.can_write 몸 옮김) - Library_Delete.can_write = access.can_write 별칭 · Library_Same_Router._can_write 는 access.can_write 부름(옛 이름 걷음은 5-8) - 새 거울 시험 test_858_1_access_mirror — 화면 accessFor ↔ 서버 can_write · grant 409 · 88 갈래 같음 - M02_MasterTemplete_Layer.ts 머리 글 한 줄(짝 시험 자리 · 코드 불변) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""M02 층 권한 한 벌 — 나무 · 항목(`Router_Items`) · 양식 · 남의 층 목록(`Router_Layers`)이 함께 씀
|
||||
(PLAN 27-1c). 화면 쪽 짝 = `M02_MasterTemplete_Layer.ts` 의 `accessFor`.
|
||||
(PLAN 27-1c). 화면 쪽 짝 = `M02_MasterTemplete_Layer.ts` 의 `accessFor` · 거울 시험
|
||||
`test_858_1_access_mirror.py`. 서고 지우기 · 합치기 쓰기 판단도 `can_write` 한 벌(858-B).
|
||||
|
||||
「회사 C 를 맡음」(`manages` · 39-6) = SYSTEM_ADMIN · 또는 C 의 회사 관리자(ADMIN · 마스터).
|
||||
system 읽기 = 로그인 누구나 · 수정 = SYSTEM_ADMIN
|
||||
@@ -94,6 +95,16 @@ def require(
|
||||
return got
|
||||
|
||||
|
||||
def can_write(session: dict[str, Any] | None, here: tuple[str, str | None]) -> bool:
|
||||
"""층 `here` = (층, 주인) 에 쓸 수 있나 — 읽기 못 함 · 회사 없음 · 모양 틀림도 False."""
|
||||
if session is None:
|
||||
return False
|
||||
try:
|
||||
return grant(session, here[0], here[1]).write
|
||||
except HTTPException:
|
||||
return False
|
||||
|
||||
|
||||
def folder(got: Grant, create: bool = False) -> Path:
|
||||
"""회사 · 개인 층 폴더 — 남의 층은 그 층 폴더가 있어야 함 · `create` = 쓰기(부르는 쪽이 소속을
|
||||
본 뒤 뼈대를 만듦)."""
|
||||
|
||||
@@ -22,8 +22,6 @@ from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Layer_Access as access
|
||||
@@ -37,13 +35,7 @@ _ADD = re.compile(r"^add:#(\d+)(.*)$")
|
||||
_PATCH = ("덮개", "고름", "자재표시")
|
||||
|
||||
|
||||
def can_write(session: dict[str, Any] | None, at: refs.Here) -> bool:
|
||||
if session is None:
|
||||
return False
|
||||
try:
|
||||
return access.grant(session, at[0], at[1]).write
|
||||
except HTTPException:
|
||||
return False
|
||||
can_write = access.can_write # 쓰기 판단 한 벌(858-B) — 이름은 5-8 에서 걷음
|
||||
|
||||
|
||||
def _hits(doc: dict[str, Any], rids: dict[str, str]) -> list[tuple[str, str]]:
|
||||
|
||||
@@ -34,6 +34,7 @@ from pydantic import BaseModel
|
||||
from common_util.common_util_auth import verify_session
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Layer_Access as access
|
||||
from M02_MasterTemplete import M02_Library_Delete as deleting
|
||||
from M02_MasterTemplete import M02_Library_Flat as flat
|
||||
from M02_MasterTemplete import M02_Library_Same as same
|
||||
@@ -106,7 +107,7 @@ def _user_index() -> dict[str, list[tuple[Path, str, str]]]:
|
||||
|
||||
|
||||
def _can_write(session: Session, at: refs.Here) -> bool:
|
||||
return deleting.can_write(session, at)
|
||||
return access.can_write(session, at)
|
||||
|
||||
|
||||
def _retarget(doc: dict[str, Any], olds: set[str], new: refs.Ref) -> dict[str, Any]:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* `#/m02-master-template?open=구조물조합|옵션|도면|일위대가조합|단가산출&root=master|company|personal&owner=…&company=…&pre=…`
|
||||
* (옛 `?layer=` 도 root 로 읽음 · `pre` = 일위대가 사전조합 층 · 134-3) · 고칠 권한(`accessFor` — 서버 `M02_Layer_Access` 와 짝 · 27-1c) ·
|
||||
* 회사 없음 안내 · 회사용 읽기만일 때 [개인용 복사] 막대.
|
||||
* 짝 거울 시험 = `resources/tester/test_858_1_access_mirror.py`(`accessFor` ↔ 서버 `can_write` · `grant` 409).
|
||||
* ========================================================================== */
|
||||
|
||||
import { ROUTES } from "@config/config_frontend";
|
||||
|
||||
Reference in New Issue
Block a user