Adding AttachmentPointNames

This commit is contained in:
Ian Roddis committed 2026-07-02 13:57:03 -03:00
1 parent ae50ec7049
commit 2767fb1c8e
14 files changed
+406 -3

No files matched your search

+12 -1
View File
@@ -11,11 +11,14 @@ import asyncio
from app.core.config import settings
from app.core.database import AsyncSessionLocal, init_db
from app.crud import attachment_point_name as apn_crud
from app.crud import part_type as part_type_crud
from app.crud import role as role_crud
from app.crud import sub_part_type as sub_part_type_crud
from app.crud import user as user_crud
ATTACHMENT_POINT_NAMES = ["Objective", "Occular"]
PART_TYPES = ["Flip Cover", "ARD", "Polarizer", "Adapter Ring", "Scope"]
SUB_PART_TYPES = {
@@ -59,6 +62,9 @@ PERMISSIONS = [
("clamp_connections:read", "View clamp connections"),
("clamp_connections:write", "Create and update clamp connections"),
("clamp_connections:delete", "Delete clamp connections"),
("attachment_point_names:read", "View attachment point names"),
("attachment_point_names:write", "Create and update attachment point names"),
("attachment_point_names:delete", "Delete attachment point names"),
("augmented_parts:read", "View augmented parts"),
("augmented_parts:write", "Create and update augmented parts"),
("augmented_parts:delete", "Delete augmented parts"),
@@ -68,7 +74,7 @@ PERMISSIONS = [
# Default roles -> permission names. "admin" gets everything.
ROLES = {
"admin": [name for name, _ in PERMISSIONS], # includes audit_log:read
"user": ["users:read", "iso_threads:read", "unc_threads:read", "manufacturers:read", "scope_models:read", "part_colours:read", "part_types:read", "sub_part_types:read", "imported_parts:read", "static_connections:read", "clamp_connections:read", "augmented_parts:read"],
"user": ["users:read", "iso_threads:read", "unc_threads:read", "manufacturers:read", "scope_models:read", "part_colours:read", "part_types:read", "sub_part_types:read", "imported_parts:read", "static_connections:read", "clamp_connections:read", "attachment_point_names:read", "augmented_parts:read"],
}
@@ -99,6 +105,11 @@ async def seed() -> None:
)
roles[role_name] = role
# Attachment point names
for apn_name in ATTACHMENT_POINT_NAMES:
if await apn_crud.get_by_name(db, apn_name) is None:
await apn_crud.create(db, name=apn_name)
# Part types
for pt_name in PART_TYPES:
if await part_type_crud.get_by_name(db, pt_name) is None: