updates sailsOn in step 3
This commit is contained in:
parent
52626d16a8
commit
b21af09fcb
|
@ -170,6 +170,14 @@ class SailsOn(Model):
|
|||
|
||||
present = BooleanField(default=True)
|
||||
|
||||
def update(self, sailson):
|
||||
self.is_captain = sailson.is_captain
|
||||
self.is_crew = sailson.is_crew
|
||||
self.is_owner = sailson.is_owner
|
||||
self.is_guest = sailson.is_guest
|
||||
self.is_pet = sailson.is_pet
|
||||
self.present = sailson.present
|
||||
|
||||
class BoatInsurance(Model):
|
||||
contract = IntegerField(blank=True,null=True)
|
||||
date = DateTimeField(auto_now_add=True)
|
||||
|
|
|
@ -121,11 +121,15 @@ def new_stay_2(request):
|
|||
data = {'sailors_forms': sailors_forms}
|
||||
|
||||
for sailor_form in sailors_forms:
|
||||
if not sailor_form.has_changed():
|
||||
return new_stay_3(request)
|
||||
if not sailor_form.is_valid():
|
||||
return render(request, 'new_stay/new_stay-2.html')
|
||||
else:
|
||||
sailor = sailor_form.save(commit=False)
|
||||
sailor_tmp = sailor_form.save(commit=False)
|
||||
sailor = SailsOn.objects.get(person=sailor_tmp.person)
|
||||
sailor.boat_id = request.session['new_stay_boat']
|
||||
sailor.update(sailor_tmp)
|
||||
sailor.save()
|
||||
|
||||
request.method = 'GET'
|
||||
|
@ -166,7 +170,9 @@ def new_stay_3(request):
|
|||
stay.boat_id = request.session['new_stay_boat']
|
||||
pprint(stay)
|
||||
|
||||
if (stay.departure < stay.arrival):
|
||||
if (stay.departure is not None
|
||||
and stay.arrival is not None
|
||||
and stay.departure < stay.arrival):
|
||||
return render(request, 'new_stay/new_stay-3.html', data)
|
||||
|
||||
data = {}
|
||||
|
|
Loading…
Reference in New Issue