示例#1
0
 def setUp(self):
     self.client = Client()
     self.person1 = User.objects.get(username='******').person
     self.person2 = User.objects.get(username='******').person
     self.person3 = User.objects.get(username='******').person
     self.person4 = User.objects.get(username='******').person
     self.checkin_data = {
         'address': 'Sofia',
         'duration': 30,
         'rating': 3,
     }
     self.checkin_form = CheckinForm(self.checkin_data)
     self.checkin_form.instance = CheckinDetails(creator=self.person1)
示例#2
0
文件: views.py 项目: jorgii/fuck-book
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())