-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgroups.py
More file actions
52 lines (34 loc) · 1.12 KB
/
groups.py
File metadata and controls
52 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from enum import Enum
from typing import List, Optional
from beanie import Document, PydanticObjectId
from pydantic import BaseModel
from app.models.authorization import Provenance
from app.models.users import UserOut
class Member(BaseModel):
user: UserOut
editor: bool = False
class GroupType(str, Enum):
"""Certain group types will be hidden from common lists. For example, 'project' type groups are associated with
specific projects and used to track their membership; those groups are managed using the project interface, not
the groups interface."""
STANDARD = "standard"
PROJECT = "project"
class GroupBase(BaseModel):
name: str
description: Optional[str]
users: List[Member] = []
type: GroupType = GroupType.STANDARD
project_id: Optional[PydanticObjectId] = None
class GroupIn(GroupBase):
pass
class GroupPatch(BaseModel):
id: str
name: Optional[str]
description: Optional[str]
class GroupDB(Document, GroupBase, Provenance):
views: int = 0
class Settings:
name = "groups"
class GroupOut(GroupDB):
class Config:
fields = {"id": "id"}