From e1a9321014984da06df2191bd20690efbf34ce60 Mon Sep 17 00:00:00 2001
From: Todd Dembrey <todd.dembrey@torchbox.com>
Date: Wed, 8 Aug 2018 10:44:26 +0100
Subject: [PATCH] Correct the ordering of the address to put the country last

---
 opentech/apply/funds/blocks.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/opentech/apply/funds/blocks.py b/opentech/apply/funds/blocks.py
index a2e55732d..ccc4bb0db 100644
--- a/opentech/apply/funds/blocks.py
+++ b/opentech/apply/funds/blocks.py
@@ -47,8 +47,16 @@ class AddressFieldBlock(ApplicationMustIncludeFieldBlock):
         icon = 'home'
 
     def format_data(self, data):
+        # Based on the fields listed in addressfields/widgets.py
+        order_fields = [
+            'thoroughfare', 'premise', 'localityname', 'administrativearea', 'postalcode', 'country'
+        ]
         address = json.loads(data)
-        return ', '.join(address.values())
+        return ', '.join(
+            address[field]
+            for field in order_fields
+            if address[field]
+        )
 
 
 class FullNameBlock(ApplicationMustIncludeFieldBlock):
-- 
GitLab