Add Message.has_recipient() method.

This commit is contained in:
Lance Edgar 2016-02-05 14:41:32 -06:00
parent 30a84767c9
commit 000b795fb0

View file

@ -74,6 +74,16 @@ class Message(Base):
kwargs['recipient'] = user
self.recipients.append(MessageRecipient(**kwargs))
def has_recipient(self, user):
"""
Returns boolean indicating whether the given user is listed among the
message's recipients.
"""
for recipient in self.recipients:
if recipient.recipient is user:
return True
return False
class MessageRecipient(Base):
"""