feat: user init & refactors

This commit is contained in:
swve 2023-11-12 23:16:34 +01:00
parent b4dcc14749
commit a50fc67104
25 changed files with 356 additions and 358 deletions

30
apps/api/src/db/roles.py Normal file
View file

@ -0,0 +1,30 @@
from enum import Enum
from typing import Optional
from sqlalchemy import JSON, Column
from sqlmodel import Field, SQLModel
class RoleTypeEnum(str, Enum):
ORGANIZATION = "ORGANIZATION"
ORGANIZATION_API_TOKEN = "ORGANIZATION_API_TOKEN"
GLOBAL = "GLOBAL"
class RoleBase(SQLModel):
name: str
description: Optional[str] = ""
rights: dict = Field(default={}, sa_column=Column(JSON))
class Role(RoleBase, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
org_id: int = Field(default=None, foreign_key="organization.id")
role_type: RoleTypeEnum = RoleTypeEnum.GLOBAL
role_uuid: str
creation_date: str
update_date: str
class RoleCreate(RoleBase):
org_id: int = Field(default=None, foreign_key="organization.id")
pass