Create the Profile.follow() method
This commit is contained in:
		| @@ -317,6 +317,23 @@ class Profile(db.Model):  # pylint: disable=too-few-public-methods | ||||
|  | ||||
|         return NotImplemented | ||||
|  | ||||
|     def follow(self, follower): | ||||
|         """Make ``follower`` follow this profile | ||||
|         """ | ||||
|  | ||||
|         if not isinstance(follower, Profile): | ||||
|             raise TypeError('Folloer must be a Profile object') | ||||
|  | ||||
|         user_follow = UserFollow(follower=follower, followed=self, accepted_at=datetime.utcnow()) | ||||
|         db.session.add(user_follow) | ||||
|         notification = Notification(profile=self, | ||||
|                                     actor=follower, | ||||
|                                     item=self, | ||||
|                                     action=NotificationAction.follow) | ||||
|         db.session.add(notification) | ||||
|  | ||||
|         return user_follow | ||||
|  | ||||
|  | ||||
| class Event(db.Model): | ||||
|     """Database model for events | ||||
|   | ||||
		Reference in New Issue
	
	Block a user