50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class OrgRole(str, Enum):
|
|
OWNER = "owner"
|
|
ADMIN = "admin"
|
|
MANAGER = "manager"
|
|
MEMBER = "member"
|
|
VIEWER = "viewer"
|
|
|
|
@classmethod
|
|
def _ordering(cls) -> list:
|
|
return [cls.VIEWER, cls.MEMBER, cls.MANAGER, cls.ADMIN, cls.OWNER]
|
|
|
|
def __ge__(self, other: "OrgRole") -> bool:
|
|
return self._ordering().index(self) >= self._ordering().index(other)
|
|
|
|
def __gt__(self, other: "OrgRole") -> bool:
|
|
return self._ordering().index(self) > self._ordering().index(other)
|
|
|
|
def __le__(self, other: "OrgRole") -> bool:
|
|
return self._ordering().index(self) <= self._ordering().index(other)
|
|
|
|
def __lt__(self, other: "OrgRole") -> bool:
|
|
return self._ordering().index(self) < self._ordering().index(other)
|
|
|
|
|
|
class Organization(BaseModel):
|
|
id: str | None = None
|
|
name: str
|
|
slug: str
|
|
is_active: bool = True
|
|
plan: str = "standard"
|
|
created_at: datetime | None = None
|
|
updated_at: datetime | None = None
|
|
|
|
|
|
class OrganizationCreate(BaseModel):
|
|
name: str
|
|
slug: str
|
|
|
|
|
|
class OrganizationUpdate(BaseModel):
|
|
name: str | None = None
|
|
slug: str | None = None
|
|
is_active: bool | None = None
|
|
plan: str | None = None
|