From c5cdaf27ddc109ac9f80f4ac88dc7440d46b931f Mon Sep 17 00:00:00 2001 From: Taka Date: Thu, 23 Jun 2022 03:28:07 +1000 Subject: [PATCH] Return a spacer image as a flag for nationalities that don't have one. --- vasl_templates/webapp/snippets.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vasl_templates/webapp/snippets.py b/vasl_templates/webapp/snippets.py index b4a42fd..359547c 100644 --- a/vasl_templates/webapp/snippets.py +++ b/vasl_templates/webapp/snippets.py @@ -216,6 +216,11 @@ def get_flag( nat ): with app.open_resource( fname, "rb" ) as fp: return _get_small_image( fp, key, height ) except FileNotFoundError: + if nat in globvars.template_pack["nationalities"]: + # NOTE: If the nationalitity is valid but has no flag, we return a spacer image, so that + # the scenario card doesn't show a "broken image" image. + fname = os.path.join( "static/images/spacer.png" ) + return send_file( fname ) abort( 404 ) return None # stop pylint from complaining :-/