db2c414c1a
Users can now hold multiple roles, each with its own editable set of create/edit/delete-style permissions across assets, shots, tasks, task assignment, review approve/retake, submissions, uploads, and notes (including internal vs. client note visibility). The 4 existing roles (coordinator/director/artist/developer) are migrated into the new system as system roles, seeded to reproduce today's actual behavior exactly; admins can create custom roles (e.g. "Reviewer", "Outsourcing") via the new Role Management page and assign multiple roles to a user via a new "Manage Roles" action on the Team page. Backend: - New Role/Permission models and role_permissions/user_roles tables, plus a one-off, idempotent seed/backfill migration script. - New require_permission()/user_has_permission() dependency, wired into the actual mutation endpoints across shots/assets/tasks/reviews, always preserving existing ownership- and self-service-based access (e.g. artists editing their own task status, own notes, own uploads, own submissions) as an unconditional fallback alongside the new permission checks - nothing that worked before now requires a role. - New endpoints: PUT/DELETE on task submissions (wires up soft-deletion columns that existed on the model but were never exposed), plus full role CRUD and per-user role assignment. - Along the way: fixed newly-created users not being linked to their matching system role (silently leaving them with zero permissions), and unified an inconsistency between the single vs. bulk task status endpoints that allowed different roles to bulk-update status. Frontend: - Role Management page with a grouped, human-readable permission editor (icons, plain-language action labels, per-resource select-all, live selected count) replacing an earlier dense matrix prototype. - hasPermission() added to the existing usePermission() composable without touching its current isAdmin/isCoordinatorOrAdmin consumers. - Note composer gets an Internal/Client toggle; submissions gain inline edit/delete actions gated the same ownership-or-permission way as notes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
78 lines
1.6 KiB
Python
78 lines
1.6 KiB
Python
from pydantic import BaseModel, EmailStr
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
from models.user import UserRole
|
|
from schemas.role import RoleSummary
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
email: EmailStr
|
|
first_name: str
|
|
last_name: str
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
password: str
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
first_name: Optional[str] = None
|
|
last_name: Optional[str] = None
|
|
role: Optional[UserRole] = None
|
|
is_admin: Optional[bool] = None
|
|
is_approved: Optional[bool] = None
|
|
|
|
|
|
class UserResponse(UserBase):
|
|
id: int
|
|
role: UserRole
|
|
is_admin: bool
|
|
is_approved: bool
|
|
avatar_url: Optional[str] = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
roles: List[RoleSummary] = []
|
|
permissions: Optional[List[str]] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class UserApproval(BaseModel):
|
|
is_approved: bool
|
|
|
|
|
|
class UserRoleUpdate(BaseModel):
|
|
role: UserRole
|
|
|
|
|
|
class UserAdminUpdate(BaseModel):
|
|
is_admin: bool
|
|
|
|
|
|
class UserAdminCreate(BaseModel):
|
|
email: EmailStr
|
|
password: str
|
|
first_name: str
|
|
last_name: str
|
|
role: UserRole
|
|
is_approved: bool = True
|
|
is_admin: bool = False
|
|
|
|
|
|
class UserAdminEdit(BaseModel):
|
|
first_name: Optional[str] = None
|
|
last_name: Optional[str] = None
|
|
email: Optional[EmailStr] = None
|
|
role: Optional[UserRole] = None
|
|
is_approved: Optional[bool] = None
|
|
is_admin: Optional[bool] = None
|
|
|
|
|
|
class UserPasswordReset(BaseModel):
|
|
new_password: str
|
|
|
|
|
|
class UserPasswordChange(BaseModel):
|
|
current_password: str
|
|
new_password: str |