Example #1
0
 def test_create(self):
     checkin = CheckinDetails.objects.create(creator=self.person4, rating=3, duration=30)
     created_diary = Diary.create(creator=self.person4, participants=[self.person1, self.person2, self.person4], checkins=checkin)
     self.assertIsInstance(created_diary, Diary)
     self.assertEqual(created_diary.creator, self.person4)
     self.assertItemsEqual(created_diary.participants.all(), [self.person1, self.person2, self.person4])
     self.assertItemsEqual(created_diary.checkins.all(), [checkin])
Example #2
0
def checkin(request):
    this_person = request.user.person
    current_checkin = CheckinDetails(creator=this_person)
    checkin_form = CheckinForm(request.POST or None, instance=current_checkin)

    if request.method == 'POST':
        if checkin_form.is_valid():
            checkin_form.save()

            attached_diary = Diary.get_diary_for_exact_people(*list(current_checkin.participants.all()))
            if attached_diary:
                attached_diary.add_checkins_to_diary(current_checkin)
            else:
                Diary.create(creator=current_checkin.creator, participants=list(current_checkin.participants.all()), checkins=current_checkin)

            this_person_settings = Person.objects.get(id=this_person.id)

            return redirect('/diary/')
    csrf(request)
    return render(request, "checkin.html", locals())
Example #3
0
 def test_create(self):
     checkin = CheckinDetails.objects.create(creator=self.person4,
                                             rating=3,
                                             duration=30)
     created_diary = Diary.create(
         creator=self.person4,
         participants=[self.person1, self.person2, self.person4],
         checkins=checkin)
     self.assertIsInstance(created_diary, Diary)
     self.assertEqual(created_diary.creator, self.person4)
     self.assertItemsEqual(created_diary.participants.all(),
                           [self.person1, self.person2, self.person4])
     self.assertItemsEqual(created_diary.checkins.all(), [checkin])
 def test_create(case):
     diary = Diary.create()
     case.assert_(isinstance(diary, Diary))
 def test_write(case):
     diary = Diary.create()
     page = diary.write('本日は晴天なり')
     case.assert_(isinstance(page, Page))