def test_get_diaries_for_people(self): expected_diary_list = [self.diary1, self.diary2, self.empty_diary] received_diary_list = Diary.get_diaries_for_people(self.person1) self.assertItemsEqual(expected_diary_list, received_diary_list) expected_diary_list = [self.diary1, self.diary2] received_diary_list = Diary.get_diaries_for_people(self.person1, self.person2) self.assertItemsEqual(expected_diary_list, received_diary_list)
def test_get_diaries_for_people(self): expected_diary_list = [self.diary1, self.diary2, self.empty_diary] received_diary_list = Diary.get_diaries_for_people(self.person1) self.assertItemsEqual(expected_diary_list, received_diary_list) expected_diary_list = [self.diary1, self.diary2] received_diary_list = Diary.get_diaries_for_people( self.person1, self.person2) self.assertItemsEqual(expected_diary_list, received_diary_list)
def diary(request): checkins_by_diary = OrderedDict() diary_list = sorted( list(Diary.get_diaries_for_people(request.user.person).all()), key=lambda x: x.datetime_created, reverse=True ) for diary in diary_list: checkins_by_diary[diary] = sorted(list(diary.checkins.all()), key=lambda x: x.datetime_created, reverse=True) return render(request, "diary.html", locals())
def diary(request): checkins_by_diary = OrderedDict() diary_list = sorted(list(Diary.get_diaries_for_people(request.user.person).all()), key=lambda x: x.datetime_created, reverse=True) for diary in diary_list: checkins_by_diary[diary] = sorted(list(diary.checkins.all()), key=lambda x: x.datetime_created, reverse=True) return render(request, "diary.html", locals())