@@ -25,14 +25,19 @@ class Activity(Document):
25
25
user_id = IntField ()
26
26
27
27
28
- class Like (Activity ):
29
- config_polymorphic_identity = 'like'
30
-
28
+ class PerformerAware (Document ):
31
29
performed_by = StringField ()
32
30
performer_avatar = StringField (allow_none = True )
31
+
32
+
33
+ class PostAware (Document ):
33
34
post_id = IntField ()
34
35
post_image = StringField ()
35
36
37
+
38
+ class Like (Activity , PerformerAware , PostAware ):
39
+ config_polymorphic_identity = 'like'
40
+
36
41
def to_dict (self ):
37
42
return {
38
43
'id' : str (self .mongo_id ),
@@ -46,14 +51,9 @@ def to_dict(self):
46
51
}
47
52
48
53
49
- class Comment (Activity ):
54
+ class Comment (Activity , PerformerAware , PostAware ):
50
55
config_polymorphic_identity = 'comment'
51
56
52
- performed_by = StringField ()
53
- performer_avatar = StringField (allow_none = True )
54
- post_id = IntField ()
55
- post_image = StringField ()
56
-
57
57
def to_dict (self ):
58
58
return {
59
59
'id' : str (self .mongo_id ),
@@ -67,14 +67,9 @@ def to_dict(self):
67
67
}
68
68
69
69
70
- class Repost (Activity ):
70
+ class Repost (Activity , PerformerAware , PostAware ):
71
71
config_polymorphic_identity = 'repost'
72
72
73
- performed_by = StringField ()
74
- performer_avatar = StringField (allow_none = True )
75
- post_id = IntField ()
76
- post_image = StringField ()
77
-
78
73
def to_dict (self ):
79
74
return {
80
75
'id' : str (self .mongo_id ),
@@ -88,12 +83,9 @@ def to_dict(self):
88
83
}
89
84
90
85
91
- class Follow (Activity ):
86
+ class Follow (Activity , PerformerAware ):
92
87
config_polymorphic_identity = 'follow'
93
88
94
- performed_by = StringField ()
95
- performer_avatar = StringField (allow_none = True )
96
-
97
89
def to_dict (self ):
98
90
return {
99
91
'id' : str (self .mongo_id ),
@@ -105,14 +97,9 @@ def to_dict(self):
105
97
}
106
98
107
99
108
- class Mention (Activity ):
100
+ class Mention (Activity , PerformerAware , PostAware ):
109
101
config_polymorphic_identity = 'mention'
110
102
111
- performed_by = StringField ()
112
- performer_avatar = StringField (allow_none = True )
113
- post_id = IntField ()
114
- post_image = StringField ()
115
-
116
103
def to_dict (self ):
117
104
return {
118
105
'id' : str (self .mongo_id ),
@@ -126,13 +113,11 @@ def to_dict(self):
126
113
}
127
114
128
115
129
- class Badge (Activity ):
116
+ class Badge (Activity , PostAware ):
130
117
config_polymorphic_identity = 'badge'
131
118
132
119
badge_name = StringField ()
133
120
badge_image = StringField ()
134
- post_id = IntField ()
135
- post_image = StringField ()
136
121
137
122
def to_dict (self ):
138
123
return {
0 commit comments