Added 'number' attribute to fields in the policy file, then sorted by this number when displaying.
This commit is contained in:
parent
4077bd1d0b
commit
f7bee92fcd
2 changed files with 18 additions and 20 deletions
|
@ -39,7 +39,7 @@ general_section = Section(
|
||||||
title="General Info",
|
title="General Info",
|
||||||
html_description="",
|
html_description="",
|
||||||
fields={
|
fields={
|
||||||
"destination": {"label": "Destination City", "field_type": "string"},
|
"destination": {"number": 0, "label": "Destination City", "field_type": "string"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,12 +57,12 @@ flight_section = Section(
|
||||||
title="Flight Info",
|
title="Flight Info",
|
||||||
html_description="<p>Enter flight details here.</p>",
|
html_description="<p>Enter flight details here.</p>",
|
||||||
fields={
|
fields={
|
||||||
"international": {"label": "Is this an international flight?", "field_type": "boolean"},
|
"international": {"number": 0, "label": "Is this an international flight?", "field_type": "boolean"},
|
||||||
"departure_date": {"label": "Departure date", "field_type": "date"},
|
"departure_date": {"number": 1, "label": "Departure date", "field_type": "date"},
|
||||||
"return_date": {"label": "Return date", "field_type": "date"},
|
"return_date": {"number": 2, "label": "Return date", "field_type": "date"},
|
||||||
"fare": {"label": "Fare", "field_type": "decimal"},
|
"fare": {"number": 3, "label": "Fare", "field_type": "decimal"},
|
||||||
"layovers": {"label": "Transit wait", "field_type": "integer"},
|
"layovers": {"number": 4, "label": "Transit wait", "field_type": "integer"},
|
||||||
"fare_search_screenshot": {"label": "Screenshot of fare search", "field_type": "file"},
|
"fare_search_screenshot": {"number": 5, "label": "Screenshot of fare search", "field_type": "file"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ lodging_section = Section(
|
||||||
html_description="<p>Enter hotel info here.\nPer diem rates can be found at "
|
html_description="<p>Enter hotel info here.\nPer diem rates can be found at "
|
||||||
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'>this link</a></p>",
|
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'>this link</a></p>",
|
||||||
fields={
|
fields={
|
||||||
"check-in_date": {"label": "Check-in date", "field_type": "date"},
|
"check-in_date": {"number": 0, "label": "Check-in date", "field_type": "date"},
|
||||||
"check-out_date": {"label": "Check-out date", "field_type": "date"},
|
"check-out_date": {"number": 1, "label": "Check-out date", "field_type": "date"},
|
||||||
"rate": {"label": "Per diem nightly rate", "field_type": "decimal"},
|
"rate": {"number": 2, "label": "Per diem nightly rate", "field_type": "decimal"},
|
||||||
"cost": {"label": "Total Cost", "field_type": "decimal"}
|
"cost": {"number": 3, "label": "Total Cost", "field_type": "decimal"}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ transport_section = Section(
|
||||||
title="Local Transportation",
|
title="Local Transportation",
|
||||||
html_description="<p>How much did you spend on local transportation, in total?</p>",
|
html_description="<p>How much did you spend on local transportation, in total?</p>",
|
||||||
fields={
|
fields={
|
||||||
"duration": {"label": "How many days was your trip?", "field_type": "integer"},
|
"duration": {"number":0, "label": "How many days was your trip?", "field_type": "integer"},
|
||||||
"cost": {"label": "Total cost", "field_type": "decimal"}
|
"cost": {"number":1, "label": "Total cost", "field_type": "decimal"}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@ per_diem_section = Section(
|
||||||
html_description="<p>Enter info about meals and incidentals here.\nPer diem rates can be found at "
|
html_description="<p>Enter info about meals and incidentals here.\nPer diem rates can be found at "
|
||||||
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'>this link</a></p>",
|
"<a href='https://www.gsa.gov/travel/plan-book/per-diem-rates'>this link</a></p>",
|
||||||
fields={
|
fields={
|
||||||
"duration": {"label": "How many days was your trip?", "field_type": "integer"},
|
"duration": {"number":0, "label": "How many days was your trip?", "field_type": "integer"},
|
||||||
"rate": {"label": "What is the per diem rate for your destination?", "field_type": "decimal"},
|
"rate": {"number":1, "label": "What is the per diem rate for your destination?", "field_type": "decimal"},
|
||||||
"cost": {"label": "Total Cost for meals and incidentals", "field_type": "decimal"}
|
"cost": {"number":2,"label": "Total Cost for meals and incidentals", "field_type": "decimal"}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -113,13 +113,11 @@ def report(request):
|
||||||
s.save()
|
s.save()
|
||||||
|
|
||||||
# Create the fields
|
# Create the fields
|
||||||
j = 0
|
|
||||||
for key in section.fields:
|
for key in section.fields:
|
||||||
field = section.fields[key]
|
field = section.fields[key]
|
||||||
f = Field.objects.create(section_id=s, field_name=key, label=field['label'],
|
f = Field.objects.create(section_id=s, field_name=key, label=field['label'],
|
||||||
number=j, field_type=field['field_type'], completed=False)
|
number=field['number'], field_type=field['field_type'], completed=False)
|
||||||
f.save()
|
f.save()
|
||||||
j = j+1
|
|
||||||
|
|
||||||
# Return the newly created report
|
# Return the newly created report
|
||||||
data = get_reports(report.id)
|
data = get_reports(report.id)
|
||||||
|
@ -292,4 +290,4 @@ def section_complete(section_pk):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# return false if no field is filled
|
# return false if no field is filled
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue