-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
103 lines (88 loc) · 2.44 KB
/
models.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
from dataclasses import dataclass
@dataclass
class Rakutan:
lecID: int
facultyName: str
lectureName: str
groups: str
credits: str
accepted: list
total: list
url: str
@classmethod
def from_dict(cls, dbRakutanDict: dict):
return Rakutan(
lecID=dbRakutanDict['lecID'],
facultyName=dbRakutanDict['facultyName'],
lectureName=dbRakutanDict['lectureName'],
groups=dbRakutanDict['groups'],
credits=dbRakutanDict['credits'],
accepted=dbRakutanDict['accepted'],
total=dbRakutanDict['total'],
url=dbRakutanDict['url']
)
@classmethod
def from_list(cls, dbRakutanList: list):
rakutanList = []
for rakutan in dbRakutanList:
rakutanList.append(cls.from_dict(rakutan))
return rakutanList
def to_dict(self):
return {
'lecID': self.lecID,
'facultyName': self.facultyName,
'lectureName': self.lectureName,
'groups': self.groups,
'credits': self.credits,
'accepted': self.accepted,
'total': self.total,
'url': self.url
}
@dataclass
class UserFav:
uid: str
lecID: int
@classmethod
def from_dict(cls, dbUserFavDict: dict):
return UserFav(
uid=dbUserFavDict['uid'],
lecID=dbUserFavDict['lecID']
)
@classmethod
def from_list(cls, dbUserFavList: list):
userFavList = []
for fav in dbUserFavList:
userFavList.append(cls.from_dict(fav))
return userFavList
def to_dict(self):
return {
'uid': self.uid,
'lecID': self.lecID
}
@dataclass
class Kakomon:
uid: str
lecID: int
url: str
sendTime: str
@classmethod
def from_dict(cls, dbKakomonDict: dict):
return Kakomon(
uid=dbKakomonDict['uid'],
lecID=dbKakomonDict['lecID'],
url=dbKakomonDict['url'],
sendTime=dbKakomonDict['sendTime']
)
@classmethod
def from_list(cls, dbKakomonList: list):
kakomonList = []
for kakomon in dbKakomonList:
kakomonList.append(cls.from_dict(kakomon))
return kakomonList
def to_dict(self):
return {
'uid': self.uid,
'lecID': self.lecID,
'url': self.url,
'sendTime': self.sendTime
}