-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotypes.py
164 lines (124 loc) · 3.62 KB
/
otypes.py
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import json
from datetime import date, datetime
from functools import cached_property
from typing import Dict, List, Tuple, TypeAlias
import strawberry
from pydantic import BaseModel
from strawberry.fastapi import BaseContext
from strawberry.types import Info as _Info
from strawberry.types.info import RootValueType
from models import Event, EventReport, Holiday
from mtypes import (
Audience,
Bills_State_Status,
Bills_Status,
BudgetType,
Event_Location,
Event_Mode,
PyObjectId,
)
# custom context class
class Context(BaseContext):
@cached_property
def user(self) -> Dict | None:
if not self.request:
return None
user = json.loads(self.request.headers.get("user", "{}"))
return user
@cached_property
def cookies(self) -> Dict | None:
if not self.request:
return None
cookies = json.loads(self.request.headers.get("cookies", "{}"))
return cookies
# custom info type
Info: TypeAlias = _Info[Context, RootValueType]
# serialize PyObjectId as a scalar type
PyObjectIdType = strawberry.scalar(
PyObjectId, serialize=str, parse_value=lambda v: PyObjectId(v)
)
@strawberry.experimental.pydantic.type(model=EventReport, all_fields=True)
class EventReportType:
pass
@strawberry.experimental.pydantic.type(model=Event, all_fields=True)
class EventType:
pass
class RoomList(BaseModel):
locations: List[Event_Location]
@strawberry.experimental.pydantic.type(model=RoomList, all_fields=True)
class RoomListType:
pass
@strawberry.type
class BillsStatusType:
eventid: str
eventname: str
clubid: str
bills_status: Bills_Status
eventReportSubmitted: str
@strawberry.input
class InputBillsStatus:
eventid: str
state: Bills_State_Status
slo_comment: str | None = None
@strawberry.input
class BudgetInput(BudgetType):
pass
@strawberry.input
class InputEventDetails:
name: str
location: List[Event_Location] | None = None
description: str | None = None
clubid: str
collabclubs: List[str] | None = None
mode: Event_Mode | None = Event_Mode.hybrid
poster: str | None = None
datetimeperiod: List[datetime]
audience: List[Audience] | None = None
link: str | None = None
equipment: str | None = None
additional: str | None = None
population: int | None = None
budget: List[BudgetInput] | None = None
poc: str
@strawberry.input
class InputEditEventDetails:
name: str | None = None
eventid: str
collabclubs: List[str] | None = None
location: List[Event_Location] | None = None
description: str | None = None
clubid: str | None # not editable
mode: Event_Mode | None = Event_Mode.hybrid
poster: str | None = None
datetimeperiod: List[datetime] | None = None
audience: List[Audience] | None = None
link: str | None = None
equipment: str | None = None
additional: str | None = None
population: int | None = None
budget: List[BudgetInput] | None = None
poc: str | None = None
@strawberry.input
class InputDataReportDetails:
clubid: str | None
dateperiod: List[date] | None = None
fields: List[str]
status: str
@strawberry.experimental.pydantic.input(model=EventReport, all_fields=True)
class InputEventReport:
pass
@strawberry.type
class CSVResponse:
csvFile: str
successMessage: str
errorMessage: str
timelot_type = Tuple[datetime, datetime]
# Holidays Types
@strawberry.input
class InputHolidayDetails:
date: date
name: str
description: str | None = None
@strawberry.experimental.pydantic.type(model=Holiday, all_fields=True)
class HolidayType:
pass