From 0bd38749558463e9eede3724388123c20a1f56f2 Mon Sep 17 00:00:00 2001 From: Alex Simoes Date: Mon, 7 Jul 2014 15:26:05 -0400 Subject: [PATCH] fix for redirecting countries with missing data i.e. bel -> blx --- oec/explore/views.py | 21 +++++++++++++++++---- oec/html/profile/country.html | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/oec/explore/views.py b/oec/explore/views.py index 24cbf8cb..f7ab7ae8 100644 --- a/oec/explore/views.py +++ b/oec/explore/views.py @@ -58,12 +58,21 @@ def sanitize(app_name, classification, trade_flow, origin, dest, product, year): c = Country.query.filter_by(id_3char=dest).first() dest = "zaf" msg = "{0} reports their trade under South Africa in the HS classification. ".format(c.get_name()) + if origin in ["bel", "lux"]: + c = Country.query.filter_by(id_3char=origin).first() + origin = "blx" + msg = "{0} reports their trade under Belgium-Luxembourg in the HS classification. ".format(c.get_name()) + if dest in ["bel", "lux"]: + c = Country.query.filter_by(id_3char=dest).first() + dest = "blx" + msg = "{0} reports their trade under Belgium-Luxembourg in the HS classification. ".format(c.get_name()) if msg: redirect_url = url_for('.explore', app_name=app_name, \ classification=classification, trade_flow=trade_flow, \ origin_id=origin, dest_id=dest, prod_id=product, year=year) - flash(msg+"") + return [msg, redirect_url] + def get_origin_dest_prod(origin_id, dest_id, prod_id, classification, year, trade_flow): prod_tbl = Hs if classification == "hs" else Sitc @@ -138,8 +147,8 @@ def explore(app_name, classification, trade_flow, origin_id, dest_id, \ classification=classification, trade_flow=trade_flow, \ origin_id=origin_id, dest_id=dest_id, prod_id=prod_id, \ year=new_year)) - - sanitize(app_name, classification, trade_flow, origin_id, dest_id, prod_id, year) + + redir = sanitize(app_name, classification, trade_flow, origin_id, dest_id, prod_id, year) '''Every possible build for accordion links''' all_builds = Build.query.all() @@ -167,7 +176,11 @@ def explore(app_name, classification, trade_flow, origin_id, dest_id, \ kwargs["sitc_id"] = prod else: kwargs["hs_id"] = prod - + + if redir: + flash(redir[0]) + return redirect(redir[1]) + return render_template("explore/index.html", current_build = current_build, all_builds = all_builds) diff --git a/oec/html/profile/country.html b/oec/html/profile/country.html index d4f4683d..e12fa18d 100644 --- a/oec/html/profile/country.html +++ b/oec/html/profile/country.html @@ -152,8 +152,8 @@

{{ b.get_question()|safe }}

var visualization = d3plus.viz() .attrs(attrs) .container("#viz") - .coords(raw_coords) .coords({ + "value": raw_coords, "center": [10,0], "padding": 0, "mute": ["anata"]