mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
A group can now be given locations as well as single printers: it then reaches every printer in them, including printers added there later. Printer access moves out of the group editor to Settings -> Authentication -> Printer access, built for large fleets: groups and printers searchable and filtered by location, model and access, edited by group or by printer, saved together. "Who has access" in the printer card menu opens it on that printer. - group_locations table; the scope is picked printers plus printers whose location matches. - Moving a printer into or out of a location a limited group has is admin-only, and open connections are rescoped. The edit dialog names the groups a move affects. Locations are trimmed on save. - Clearing a printer's location in the edit dialog now clears it.
101 lines
2.1 KiB
Python
101 lines
2.1 KiB
Python
"""Pydantic schemas for Group CRUD operations."""
|
|
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class GroupBrief(BaseModel):
|
|
"""Brief group info for embedding in other responses."""
|
|
|
|
id: int
|
|
name: str
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class GroupCreate(BaseModel):
|
|
"""Schema for creating a new group."""
|
|
|
|
name: str
|
|
description: str | None = None
|
|
permissions: list[str] = []
|
|
# Printer scope (#1727): when set, members only see these printers plus
|
|
# every printer in these locations
|
|
restrict_printers: bool = False
|
|
printer_ids: list[int] = []
|
|
locations: list[str] = []
|
|
|
|
|
|
class GroupUpdate(BaseModel):
|
|
"""Schema for updating a group."""
|
|
|
|
name: str | None = None
|
|
description: str | None = None
|
|
permissions: list[str] | None = None
|
|
restrict_printers: bool | None = None
|
|
printer_ids: list[int] | None = None
|
|
locations: list[str] | None = None
|
|
|
|
|
|
class GroupResponse(BaseModel):
|
|
"""Schema for group response."""
|
|
|
|
id: int
|
|
name: str
|
|
description: str | None
|
|
permissions: list[str]
|
|
is_system: bool
|
|
restrict_printers: bool = False
|
|
printer_ids: list[int] = []
|
|
locations: list[str] = []
|
|
user_count: int = 0
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class GroupDetailResponse(GroupResponse):
|
|
"""Schema for detailed group response including users."""
|
|
|
|
users: list["UserBrief"] = []
|
|
|
|
|
|
class UserBrief(BaseModel):
|
|
"""Brief user info for embedding in group response."""
|
|
|
|
id: int
|
|
username: str
|
|
is_active: bool
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class PermissionInfo(BaseModel):
|
|
"""Schema for permission information."""
|
|
|
|
value: str
|
|
label: str
|
|
|
|
|
|
class PermissionCategory(BaseModel):
|
|
"""Schema for a category of permissions."""
|
|
|
|
name: str
|
|
permissions: list[PermissionInfo]
|
|
|
|
|
|
class PermissionsListResponse(BaseModel):
|
|
"""Schema for listing all permissions by category."""
|
|
|
|
categories: list[PermissionCategory]
|
|
all_permissions: list[str]
|
|
|
|
|
|
# Update forward references
|
|
GroupDetailResponse.model_rebuild()
|