From f7bee92fcde777d573aeb7757ef9a39c0ee63631 Mon Sep 17 00:00:00 2001 From: kououken Date: Fri, 15 Feb 2019 14:59:42 -0800 Subject: [PATCH 1/3] Added 'number' attribute to fields in the policy file, then sorted by this number when displaying. --- back/backend/policy.py | 32 ++++++++++++++++---------------- back/backend/views.py | 6 ++---- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/back/backend/policy.py b/back/backend/policy.py index 1628b57..d28d540 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -39,7 +39,7 @@ general_section = Section( title="General Info", html_description="", 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", html_description="

Enter flight details here.

", fields={ - "international": {"label": "Is this an international flight?", "field_type": "boolean"}, - "departure_date": {"label": "Departure date", "field_type": "date"}, - "return_date": {"label": "Return date", "field_type": "date"}, - "fare": {"label": "Fare", "field_type": "decimal"}, - "layovers": {"label": "Transit wait", "field_type": "integer"}, - "fare_search_screenshot": {"label": "Screenshot of fare search", "field_type": "file"}, + "international": {"number": 0, "label": "Is this an international flight?", "field_type": "boolean"}, + "departure_date": {"number": 1, "label": "Departure date", "field_type": "date"}, + "return_date": {"number": 2, "label": "Return date", "field_type": "date"}, + "fare": {"number": 3, "label": "Fare", "field_type": "decimal"}, + "layovers": {"number": 4, "label": "Transit wait", "field_type": "integer"}, + "fare_search_screenshot": {"number": 5, "label": "Screenshot of fare search", "field_type": "file"}, } ) @@ -81,10 +81,10 @@ lodging_section = Section( html_description="

Enter hotel info here.\nPer diem rates can be found at " "this link

", fields={ - "check-in_date": {"label": "Check-in date", "field_type": "date"}, - "check-out_date": {"label": "Check-out date", "field_type": "date"}, - "rate": {"label": "Per diem nightly rate", "field_type": "decimal"}, - "cost": {"label": "Total Cost", "field_type": "decimal"} + "check-in_date": {"number": 0, "label": "Check-in date", "field_type": "date"}, + "check-out_date": {"number": 1, "label": "Check-out date", "field_type": "date"}, + "rate": {"number": 2, "label": "Per diem nightly rate", "field_type": "decimal"}, + "cost": {"number": 3, "label": "Total Cost", "field_type": "decimal"} } ) @@ -108,8 +108,8 @@ transport_section = Section( title="Local Transportation", html_description="

How much did you spend on local transportation, in total?

", fields={ - "duration": {"label": "How many days was your trip?", "field_type": "integer"}, - "cost": {"label": "Total cost", "field_type": "decimal"} + "duration": {"number":0, "label": "How many days was your trip?", "field_type": "integer"}, + "cost": {"number":1, "label": "Total cost", "field_type": "decimal"} } ) @@ -128,9 +128,9 @@ per_diem_section = Section( html_description="

Enter info about meals and incidentals here.\nPer diem rates can be found at " "this link

", fields={ - "duration": {"label": "How many days was your trip?", "field_type": "integer"}, - "rate": {"label": "What is the per diem rate for your destination?", "field_type": "decimal"}, - "cost": {"label": "Total Cost for meals and incidentals", "field_type": "decimal"} + "duration": {"number":0, "label": "How many days was your trip?", "field_type": "integer"}, + "rate": {"number":1, "label": "What is the per diem rate for your destination?", "field_type": "decimal"}, + "cost": {"number":2,"label": "Total Cost for meals and incidentals", "field_type": "decimal"} } ) diff --git a/back/backend/views.py b/back/backend/views.py index 6de2b1e..5bd2ca0 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -113,13 +113,11 @@ def report(request): s.save() # Create the fields - j = 0 for key in section.fields: field = section.fields[key] 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() - j = j+1 # Return the newly created report data = get_reports(report.id) @@ -292,4 +290,4 @@ def section_complete(section_pk): return True # return false if no field is filled - return False \ No newline at end of file + return False From 98f39d242d0b08a3b2f3e52176c4973527a4d9ea Mon Sep 17 00:00:00 2001 From: kououken Date: Fri, 15 Feb 2019 15:12:59 -0800 Subject: [PATCH 2/3] Patched policy link bug where links were opening in the same tab, navigating away from the page. --- back/backend/policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/backend/policy.py b/back/backend/policy.py index d28d540..0d57b96 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -79,7 +79,7 @@ pol.add_section(flight_section) lodging_section = Section( title="Hotel Info", html_description="

Enter hotel info here.\nPer diem rates can be found at " - "this link

", + "this link

", fields={ "check-in_date": {"number": 0, "label": "Check-in date", "field_type": "date"}, "check-out_date": {"number": 1, "label": "Check-out date", "field_type": "date"}, @@ -126,7 +126,7 @@ pol.add_section(transport_section) per_diem_section = Section( title="Per Diem", html_description="

Enter info about meals and incidentals here.\nPer diem rates can be found at " - "this link

", + "this link

", fields={ "duration": {"number":0, "label": "How many days was your trip?", "field_type": "integer"}, "rate": {"number":1, "label": "What is the per diem rate for your destination?", "field_type": "decimal"}, From dccc35b79466c39b861593b11c7caf99f34aad89 Mon Sep 17 00:00:00 2001 From: kououken Date: Fri, 15 Feb 2019 15:18:02 -0800 Subject: [PATCH 3/3] Fixed stupid single vs. double quote error. --- back/backend/policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/backend/policy.py b/back/backend/policy.py index 0d57b96..723a76b 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -79,7 +79,7 @@ pol.add_section(flight_section) lodging_section = Section( title="Hotel Info", html_description="

Enter hotel info here.\nPer diem rates can be found at " - "this link

", + "this link

", fields={ "check-in_date": {"number": 0, "label": "Check-in date", "field_type": "date"}, "check-out_date": {"number": 1, "label": "Check-out date", "field_type": "date"}, @@ -126,7 +126,7 @@ pol.add_section(transport_section) per_diem_section = Section( title="Per Diem", html_description="

Enter info about meals and incidentals here.\nPer diem rates can be found at " - "this link

", + "this link

", fields={ "duration": {"number":0, "label": "How many days was your trip?", "field_type": "integer"}, "rate": {"number":1, "label": "What is the per diem rate for your destination?", "field_type": "decimal"},