File size: 1,820 Bytes
b7a7f32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from datetime import datetime
from typing import Optional, List, Union

from pydantic import BaseModel
from typing import Any
from schemas.user import UserReturnMin, TeacherShort
from schemas.course import Course
from schemas.file import FileClassSessionReturn


# shared properties
class ClassSessionBase(BaseModel):
    start_time: datetime
    end_time: datetime
    instructor: List[int]
    course_id: int
    group_id: int
    description: str


# properties to recieve via
class ClassSessionCreate(ClassSessionBase):
    pass


# properties to recive via API on Update
class ClassSessionUpdate(ClassSessionBase):
    start_time: datetime = None
    end_time: datetime = None
    instructor: List[int] = None
    course_id: int = None
    description: str = None
    group_id: int = None


class AttendanceUpdate(BaseModel):
    attendant: List[int]


# properties to return via the api
class ClassSessionInDBBase(ClassSessionBase):
    id: Optional[int]

    class Config:
        orm_mode = True


class ClassSession(ClassSessionInDBBase):
    instructor: List[TeacherShort]


class ClassSessionReturn(BaseModel):
    id: int
    start_time: datetime
    end_time: datetime
    instructor: List[TeacherShort]
    course: Course
    group_id: int
    description: str
    files: List[FileClassSessionReturn] = None

    class Config:
        orm_mode = True


class AttendantOfClassSession(BaseModel):
    id: str
    full_name: str
    roll: Optional[int]

    class Config:
        orm_mode = True


class ClassSessionTeacherReturn(ClassSessionReturn):
    attendant: List[AttendantOfClassSession]


class ClassSessionInDB(ClassSessionInDBBase):
    pass


class ParticipantOfClassSession(BaseModel):
    id: int
    full_name: str
    profile_image: Union[str, None]

    class Config:
        orm_mode = True