added stay form
This commit is contained in:
parent
a6f56cfcd3
commit
52626d16a8
@ -5,5 +5,4 @@
|
|||||||
<br />
|
<br />
|
||||||
<input type="submit" value="Next" />
|
<input type="submit" value="Next" />
|
||||||
<br />
|
<br />
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -47,6 +47,8 @@ def new_stay_0(request):
|
|||||||
boat_id = int(request.POST.get('search_results'))
|
boat_id = int(request.POST.get('search_results'))
|
||||||
boat = Boat.objects.get(pk=boat_id)
|
boat = Boat.objects.get(pk=boat_id)
|
||||||
if boat is not None:
|
if boat is not None:
|
||||||
|
request.method = 'GET'
|
||||||
|
|
||||||
request.session['new_stay_step'] = 1
|
request.session['new_stay_step'] = 1
|
||||||
request.session['new_stay_boat'] = boat_id
|
request.session['new_stay_boat'] = boat_id
|
||||||
insurance = boat.getInsurance()
|
insurance = boat.getInsurance()
|
||||||
@ -89,6 +91,7 @@ def new_stay_1(request):
|
|||||||
# User has not select a search result
|
# User has not select a search result
|
||||||
# So this must be the good insurance
|
# So this must be the good insurance
|
||||||
print('No search')
|
print('No search')
|
||||||
|
request.method = 'GET'
|
||||||
request.session['new_stay_step'] = 2
|
request.session['new_stay_step'] = 2
|
||||||
return new_stay(request)
|
return new_stay(request)
|
||||||
|
|
||||||
@ -115,6 +118,7 @@ def new_stay_2(request):
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
sailors_forms = SailorsFormSet(data=request.POST,
|
sailors_forms = SailorsFormSet(data=request.POST,
|
||||||
prefix='sai')
|
prefix='sai')
|
||||||
|
data = {'sailors_forms': sailors_forms}
|
||||||
|
|
||||||
for sailor_form in sailors_forms:
|
for sailor_form in sailors_forms:
|
||||||
if not sailor_form.is_valid():
|
if not sailor_form.is_valid():
|
||||||
@ -123,6 +127,9 @@ def new_stay_2(request):
|
|||||||
sailor = sailor_form.save(commit=False)
|
sailor = sailor_form.save(commit=False)
|
||||||
sailor.boat_id = request.session['new_stay_boat']
|
sailor.boat_id = request.session['new_stay_boat']
|
||||||
sailor.save()
|
sailor.save()
|
||||||
|
|
||||||
|
request.method = 'GET'
|
||||||
|
request.session['new_stay_step'] = 3
|
||||||
return new_stay_3(request)
|
return new_stay_3(request)
|
||||||
|
|
||||||
boat = Boat.objects.get(
|
boat = Boat.objects.get(
|
||||||
@ -153,8 +160,19 @@ def new_stay_2(request):
|
|||||||
|
|
||||||
def new_stay_3(request):
|
def new_stay_3(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
pass
|
stay_form = StayForm(request.POST)
|
||||||
|
data = {'stay_form': stay_form}
|
||||||
|
stay = stay_form.save(commit=False)
|
||||||
|
stay.boat_id = request.session['new_stay_boat']
|
||||||
|
pprint(stay)
|
||||||
|
|
||||||
|
if (stay.departure < stay.arrival):
|
||||||
|
return render(request, 'new_stay/new_stay-3.html', data)
|
||||||
|
|
||||||
|
data = {}
|
||||||
|
data['stay_form'] = StayForm()
|
||||||
|
|
||||||
return render(request, 'new_stay/new_stay-3.html', data)
|
return render(request, 'new_stay/new_stay-3.html', data)
|
||||||
|
|
||||||
def new_stay_4(request):
|
def new_stay_4(request):
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user