Skip to content

Commit

Permalink
fix for redirecting countries with missing data i.e. bel -> blx
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandersimoes committed Jul 7, 2014
1 parent 8403418 commit 0bd3874
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions oec/explore/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+"<script>redirect('"+redirect_url+"', 10)</script>")
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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion oec/html/profile/country.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ <h3>{{ b.get_question()|safe }}</h3>
var visualization = d3plus.viz()
.attrs(attrs)
.container("#viz")
.coords(raw_coords)
.coords({
"value": raw_coords,
"center": [10,0],
"padding": 0,
"mute": ["anata"]
Expand Down

0 comments on commit 0bd3874

Please sign in to comment.