|
26 | 26 | from typing import Optional |
27 | 27 |
|
28 | 28 | import Geohash |
| 29 | +from PyMatcha.models.block import Block |
29 | 30 | from PyMatcha.models.image import Image |
30 | 31 | from PyMatcha.models.like import Like |
31 | 32 | from PyMatcha.models.match import Match |
@@ -204,6 +205,7 @@ def to_dict(self) -> Dict: |
204 | 205 | returned_dict["likes"]["sent"] = [like.to_dict() for like in self.get_likes_sent()] |
205 | 206 | returned_dict["likes"]["received"] = [like.to_dict() for like in self.get_likes_received()] |
206 | 207 | returned_dict["last_seen"] = timeago_format(self.date_lastseen, datetime.datetime.utcnow()) |
| 208 | + returned_dict["blocks"] = [block.to_dict() for block in self.get_blocks()] |
207 | 209 | returned_dict.pop("password") |
208 | 210 | returned_dict.pop("previous_reset_token") |
209 | 211 |
|
@@ -233,59 +235,34 @@ def get_jwt_info(self): |
233 | 235 |
|
234 | 236 | def get_images(self): |
235 | 237 | logging.debug("Getting all images for user {}".format(self.id)) |
236 | | - image_list = Image.get_multis(user_id=self.id) |
237 | | - if not image_list: |
238 | | - return [] |
239 | | - else: |
240 | | - return image_list |
| 238 | + return Image.get_multis(user_id=self.id) |
241 | 239 |
|
242 | 240 | def get_tags(self): |
243 | 241 | logging.debug("Getting all tags for user {}".format(self.id)) |
244 | | - tag_list = Tag.get_multis(user_id=self.id) |
245 | | - if not tag_list: |
246 | | - return [] |
247 | | - else: |
248 | | - return tag_list |
| 242 | + return Tag.get_multis(user_id=self.id) |
249 | 243 |
|
250 | 244 | def get_views(self): |
251 | 245 | logging.debug("Getting all views for user profile {}".format(self.id)) |
252 | | - view_list = View.get_multis(profile_id=self.id) |
253 | | - if not view_list: |
254 | | - return [] |
255 | | - else: |
256 | | - return view_list |
| 246 | + return View.get_multis(profile_id=self.id) |
257 | 247 |
|
258 | 248 | def get_reports_received(self): |
259 | 249 | logging.debug("Getting all reports received for user {}".format(self.id)) |
260 | | - reports_received_list = Report.get_multis(reported_id=self.id) |
261 | | - if not reports_received_list: |
262 | | - return [] |
263 | | - else: |
264 | | - return reports_received_list |
| 250 | + return Report.get_multis(reported_id=self.id) |
265 | 251 |
|
266 | 252 | def get_reports_sent(self): |
267 | 253 | logging.debug("Getting all reports sent for user {}".format(self.id)) |
268 | | - reports_sent_list = Report.get_multis(reporter_id=self.id) |
269 | | - if not reports_sent_list: |
270 | | - return [] |
271 | | - else: |
272 | | - return reports_sent_list |
| 254 | + return Report.get_multis(reporter_id=self.id) |
273 | 255 |
|
274 | 256 | def get_likes_received(self): |
275 | 257 | logging.debug("Getting all likes received for user {}".format(self.id)) |
276 | | - likes_received_list = Like.get_multis(liked_id=self.id) |
277 | | - if not likes_received_list: |
278 | | - return [] |
279 | | - else: |
280 | | - return likes_received_list |
| 258 | + return Like.get_multis(liked_id=self.id) |
281 | 259 |
|
282 | 260 | def get_likes_sent(self): |
283 | 261 | logging.debug("Getting all likes sent for user {}".format(self.id)) |
284 | | - likes_sent_list = Like.get_multis(liker_id=self.id) |
285 | | - if not likes_sent_list: |
286 | | - return [] |
287 | | - else: |
288 | | - return likes_sent_list |
| 262 | + return Like.get_multis(liker_id=self.id) |
| 263 | + |
| 264 | + def get_blocks(self): |
| 265 | + return Block.get_multis(blocker_id=self.id) |
289 | 266 |
|
290 | 267 | def already_likes(self, liked_id: int) -> bool: |
291 | 268 | with self.db.cursor() as c: |
|
0 commit comments