fix management_form bug in sailors form
This commit is contained in:
parent
bbc42ed5c5
commit
a6f56cfcd3
@ -4,6 +4,8 @@
|
|||||||
{% if sailors_forms.initial|length <= 0 %}
|
{% if sailors_forms.initial|length <= 0 %}
|
||||||
<em>No one is yet assigned for this boat</em>
|
<em>No one is yet assigned for this boat</em>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<!-- necessary to work with formsets -->
|
||||||
|
{{ sailors_forms.management_form }}
|
||||||
|
|
||||||
Previous passengers :
|
Previous passengers :
|
||||||
<table>
|
<table>
|
||||||
@ -19,7 +21,8 @@
|
|||||||
{% for sailors_form in sailors_forms %}
|
{% for sailors_form in sailors_forms %}
|
||||||
<tr>
|
<tr>
|
||||||
{% with id=sailors_form.person.value %}
|
{% with id=sailors_form.person.value %}
|
||||||
<td>{{ persons|get:id }}</td>
|
<td>{{ persons|get:id }}
|
||||||
|
{{ sailors_form.person }}</td>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
<td>{{ sailors_form.is_captain }}</td>
|
<td>{{ sailors_form.is_captain }}</td>
|
||||||
<td>{{ sailors_form.is_crew }}</td>
|
<td>{{ sailors_form.is_crew }}</td>
|
||||||
|
9
port/templates/new_stay/new_stay-3.html
Normal file
9
port/templates/new_stay/new_stay-3.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{% extends "index.html" %}
|
||||||
|
{% load dict %}
|
||||||
|
{% block form %}
|
||||||
|
{{ stay_form }}
|
||||||
|
<br />
|
||||||
|
<input type="submit" value="Next" />
|
||||||
|
<br />
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
@ -112,6 +112,19 @@ def new_stay_1(request):
|
|||||||
|
|
||||||
def new_stay_2(request):
|
def new_stay_2(request):
|
||||||
# Person
|
# Person
|
||||||
|
if request.method == 'POST':
|
||||||
|
sailors_forms = SailorsFormSet(data=request.POST,
|
||||||
|
prefix='sai')
|
||||||
|
|
||||||
|
for sailor_form in sailors_forms:
|
||||||
|
if not sailor_form.is_valid():
|
||||||
|
return render(request, 'new_stay/new_stay-2.html')
|
||||||
|
else:
|
||||||
|
sailor = sailor_form.save(commit=False)
|
||||||
|
sailor.boat_id = request.session['new_stay_boat']
|
||||||
|
sailor.save()
|
||||||
|
return new_stay_3(request)
|
||||||
|
|
||||||
boat = Boat.objects.get(
|
boat = Boat.objects.get(
|
||||||
pk=request.session.get('new_stay_boat'))
|
pk=request.session.get('new_stay_boat'))
|
||||||
|
|
||||||
@ -139,6 +152,9 @@ def new_stay_2(request):
|
|||||||
return render(request, 'new_stay/new_stay-2.html', data)
|
return render(request, 'new_stay/new_stay-2.html', data)
|
||||||
|
|
||||||
def new_stay_3(request):
|
def new_stay_3(request):
|
||||||
pass
|
if request.method == 'POST':
|
||||||
|
pass
|
||||||
|
|
||||||
|
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