def most_popular(cls):
     guest_list = [invite.guest for invite in Invite.all()]
     guest_dict = {
         guest: guest_list.count(guest)
         for guest in set(guest_list)
     }
     most_popular = max(guest_dict.values())
     return [
         key for key, value in guest_dict.items() if value == most_popular
     ][0]
 def number_of_attendees(self):
     dinner_guest_list = [
         invite for invite in Invite.all()
         if invite.dinner_party == self and invite.accepted == True
     ]
     return len(dinner_guest_list)
 def guests(self):
     return [
         invite.guest for invite in Invite.all()
         if invite.dinner_party == self
     ]
 def invites(self):
     return [
         invite for invite in Invite.all() if invite.dinner_party == self
     ]
コード例 #5
0
 def invites(self):
     return [invite for invite in Invite.all() if invite.guest == self]
コード例 #6
0
 def number_of_attendees(self):
     attendee_list = [invite.guest for invite in Invite.all() if invite.accepted == True]
     return len(attendee_list)
 def test_invite_class_methods(self):
     self.assertItemsEqual(
         Invite._all, [invite_1, invite_2, invite_3, invite_4, invite_5])
     self.assertItemsEqual(
         Invite.all(), [invite_1, invite_2, invite_3, invite_4, invite_5])
 def number_of_invites(self):
     return len([invite for invite in Invite.all() if invite.guest == self])