feat(M02): 개인 · 회사 층 양식 지우기 — DELETE /layers/{층}/templates/{종류}/{이름} · 개인 본인만 · 회사 관리자만 · 시스템 · 프로젝트 거절 · 판 다르면 409 · 이름 검사 400 + 까닭
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015LuapLYqN1GGFD8Y1PStD5
This commit is contained in:
@@ -100,7 +100,10 @@ def check_name(name: str) -> str:
|
||||
text = str(name or "").strip()
|
||||
bad = not text or text != name or text.startswith((".", "_")) or len(text) > 80
|
||||
if bad or any(ch in text for ch in '/\\:*?"<>|') or ".." in text:
|
||||
raise ValueError("양식 이름이 올바르지 않습니다.")
|
||||
raise ValueError(
|
||||
"양식 이름이 올바르지 않습니다 — 빈 이름 · 앞뒤 빈칸 · 80자 초과 · 앞머리 . _ · "
|
||||
'`/ \ .. : * ? " < > |` 는 못 씁니다.'
|
||||
)
|
||||
return text
|
||||
|
||||
|
||||
@@ -189,10 +192,20 @@ def write_template(
|
||||
return version_of(path) or ""
|
||||
|
||||
|
||||
def delete_template(layer_dir: str | Path, kind: str, name: str) -> bool:
|
||||
def delete_template(
|
||||
layer_dir: str | Path,
|
||||
kind: str,
|
||||
name: str,
|
||||
*,
|
||||
version: str | None = None,
|
||||
check_version: bool = False,
|
||||
) -> bool:
|
||||
"""양식 지움 · manifest 줄도 뺌. `check_version` 이면 지금 판과 달라 `StaleTemplate`."""
|
||||
path = template_path(layer_dir, kind, name)
|
||||
if not path.is_file():
|
||||
return False
|
||||
if check_version and version_of(path) != version:
|
||||
raise StaleTemplate(version_of(path))
|
||||
path.unlink()
|
||||
manifest = read_manifest(layer_dir)
|
||||
if manifest.pop(f"{kind}/{name}", None) is not None:
|
||||
|
||||
Reference in New Issue
Block a user