diff --git a/port/templates/new_stay/new_stay-3.html b/port/templates/new_stay/new_stay-3.html
index 187dce1..890da3f 100644
--- a/port/templates/new_stay/new_stay-3.html
+++ b/port/templates/new_stay/new_stay-3.html
@@ -5,5 +5,4 @@
- {% endif %}
{% endblock %}
diff --git a/port/views/index.py b/port/views/index.py
index 130f287..b36fd5d 100644
--- a/port/views/index.py
+++ b/port/views/index.py
@@ -47,6 +47,8 @@ def new_stay_0(request):
boat_id = int(request.POST.get('search_results'))
boat = Boat.objects.get(pk=boat_id)
if boat is not None:
+ request.method = 'GET'
+
request.session['new_stay_step'] = 1
request.session['new_stay_boat'] = boat_id
insurance = boat.getInsurance()
@@ -89,6 +91,7 @@ def new_stay_1(request):
# User has not select a search result
# So this must be the good insurance
print('No search')
+ request.method = 'GET'
request.session['new_stay_step'] = 2
return new_stay(request)
@@ -115,6 +118,7 @@ def new_stay_2(request):
if request.method == 'POST':
sailors_forms = SailorsFormSet(data=request.POST,
prefix='sai')
+ data = {'sailors_forms': sailors_forms}
for sailor_form in sailors_forms:
if not sailor_form.is_valid():
@@ -123,6 +127,9 @@ def new_stay_2(request):
sailor = sailor_form.save(commit=False)
sailor.boat_id = request.session['new_stay_boat']
sailor.save()
+
+ request.method = 'GET'
+ request.session['new_stay_step'] = 3
return new_stay_3(request)
boat = Boat.objects.get(
@@ -153,8 +160,19 @@ def new_stay_2(request):
def new_stay_3(request):
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)
+
def new_stay_4(request):
pass