feat: add repair parts tracking
This commit is contained in:
1 parent
6e550c1c13
commit
eab9646960
23 files changed
+2386
-4
No files matched your search
@@ -691,7 +691,32 @@ def repair_completion_request(path: str) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def repair_parts_request(path: str) -> bool:
|
||||
parts = path.split("/")
|
||||
return (
|
||||
len(parts) == 5
|
||||
and parts[:3] == ["", "api", "repairs"]
|
||||
and parts[4] == "parts"
|
||||
) or (
|
||||
len(parts) == 7
|
||||
and parts[:3] == ["", "api", "repairs"]
|
||||
and parts[4] == "parts"
|
||||
and parts[6] == "void"
|
||||
)
|
||||
|
||||
|
||||
def component_request(path: str) -> bool:
|
||||
parts = path.split("/")
|
||||
return path == "/api/components" or (
|
||||
len(parts) == 4 and parts[:3] == ["", "api", "components"]
|
||||
)
|
||||
|
||||
|
||||
def required_api_permission(method: str, path: str) -> str | None:
|
||||
if component_request(path):
|
||||
return "components.create" if method == "POST" else "components.read"
|
||||
if repair_parts_request(path):
|
||||
return "repairs.read" if method == "GET" else "repairs.parts.manage"
|
||||
if path.startswith("/api/admin/"):
|
||||
return "users.manage"
|
||||
if method == "POST" and path.endswith("/change-mac") and path.startswith("/api/miners/"):
|
||||
|
||||
Reference in new issue
Block a user