From dc2b8ad4310af2a2fe842a991ff8dfdda0099a3f Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 31 Aug 2022 09:27:14 +0300 Subject: fixes for crashes,svx files in wallets --- core/models/survex.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'core/models/survex.py') diff --git a/core/models/survex.py b/core/models/survex.py index d165d14..fe39136 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -281,19 +281,24 @@ class Wallet(models.Model): waldata["survex file"] = [waldata["survex file"]] ngood = 0 nbad = 0 - ticks["S"] = "black" - for svx in waldata["survex file"]: - if svx !="": - if (Path(settings.SURVEX_DATA) / svx).is_file(): + ticks["S"] = "purple" + for sx in waldata["survex file"]: + #this logic appears in several places, inc uploads.py). Refactor. + if sx !="": + if Path(sx).suffix.lower() != ".svx": + sx = sx + ".svx" + if (Path(settings.SURVEX_DATA) / sx).is_file(): ngood += 1 else: nbad += 1 if nbad == 0 and ngood >= 1: ticks["S"] = "green" - if nbad >= 1 and ngood >= 1: + elif nbad >= 1 and ngood >= 1: ticks["S"] = "orange" - if nbad >= 1 and ngood == 0: + elif nbad >= 1 and ngood == 0: ticks["S"] = "red" + else: + ticks["S"] = "black" # Cave Description if waldata["description written"]: -- cgit v1.2.3