@@ -17,7 +17,6 @@ class PendingPost:
1717 u_message_id: id of the original message of the post
1818 g_message_id: id of the post in the group
1919 admin_group_id: id of the admin group
20- credit_username: username of the user that sent the post if it's a credit post
2120 date: when the post was sent
2221 """
2322
@@ -26,19 +25,15 @@ class PendingPost:
2625 g_message_id : int
2726 admin_group_id : int
2827 date : datetime
29- credit_username : str | None = None
3028
3129 @classmethod
32- def create (
33- cls , user_message : Message , g_message_id : int , admin_group_id : int , credit_username : str | None = None
34- ) -> "PendingPost" :
30+ def create (cls , user_message : Message , g_message_id : int , admin_group_id : int ) -> "PendingPost" :
3531 """Creates a new post and inserts it in the table of pending posts
3632
3733 Args:
3834 user_message: message sent by the user that contains the post
3935 g_message_id: id of the post in the group
4036 admin_group_id: id of the admin group
41- credit_username: username of the user that sent the post if it's a credit post
4237
4338 Returns:
4439 instance of the class
@@ -52,7 +47,6 @@ def create(
5247 u_message_id = u_message_id ,
5348 g_message_id = g_message_id ,
5449 admin_group_id = admin_group_id ,
55- credit_username = credit_username ,
5650 date = date ,
5751 ).save_post ()
5852
@@ -82,7 +76,6 @@ def from_group(cls, g_message_id: int, admin_group_id: int) -> "PendingPost | No
8276 u_message_id = pending_post ["u_message_id" ],
8377 admin_group_id = pending_post ["admin_group_id" ],
8478 g_message_id = pending_post ["g_message_id" ],
85- credit_username = pending_post ["credit_username" ],
8679 date = pending_post ["message_date" ],
8780 )
8881
@@ -108,7 +101,6 @@ def from_user(cls, user_id: int) -> "PendingPost | None":
108101 u_message_id = pending_post ["u_message_id" ],
109102 admin_group_id = pending_post ["admin_group_id" ],
110103 g_message_id = pending_post ["g_message_id" ],
111- credit_username = pending_post ["credit_username" ],
112104 date = pending_post ["message_date" ],
113105 )
114106
@@ -146,15 +138,10 @@ def get_all(admin_group_id: int, before: datetime | None = None) -> list["Pendin
146138
147139 def save_post (self ) -> "PendingPost" :
148140 """Saves the pending_post in the database"""
149- columns = ("user_id" , "u_message_id" , "g_message_id" , "admin_group_id" , "message_date" )
150- values = (self .user_id , self .u_message_id , self .g_message_id , self .admin_group_id , self .date )
151- if self .credit_username is not None :
152- columns += ("credit_username" ,)
153- values += (self .credit_username ,)
154141 DbManager .insert_into (
155142 table_name = "pending_post" ,
156- columns = columns ,
157- values = values ,
143+ columns = ( "user_id" , "u_message_id" , "g_message_id" , "admin_group_id" , "message_date" ) ,
144+ values = ( self . user_id , self . u_message_id , self . g_message_id , self . admin_group_id , self . date ) ,
158145 )
159146 return self
160147
@@ -173,14 +160,6 @@ def get_votes(self, vote: bool) -> int:
173160 where_args = (self .g_message_id , self .admin_group_id , vote ),
174161 )
175162
176- def get_credit_username (self ) -> str | None :
177- """Gets the username of the user that credited the post
178-
179- Returns:
180- username of the user that credited the post, or None if the post is not credited
181- """
182- return self .credit_username
183-
184163 def get_list_admin_votes (self , vote : "bool | None" = None ) -> "list[int] | list[tuple[int, bool]]" :
185164 """Gets the list of admins that approved or rejected the post
186165
@@ -278,6 +257,5 @@ def __repr__(self) -> str:
278257 f"u_message_id: { self .u_message_id } \n "
279258 f"admin_group_id: { self .admin_group_id } \n "
280259 f"g_message_id: { self .g_message_id } \n "
281- f"credit_username: { self .credit_username } \n "
282260 f"date : { self .date } ]"
283261 )
0 commit comments