From deead77c087dce753a4f4a8895c9eacd94f5a34b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 27 Sep 2025 21:59:37 +0300 Subject: [PATCH] display drawings on wallet data --- core/models/wallets.py | 33 +++++++++++++++++++++++++++------ core/views/wallets_edit.py | 7 ++++++- templates/dwgfiles.html | 2 +- templates/walletform.html | 10 +++++++++- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/core/models/wallets.py b/core/models/wallets.py index 2055b48..ef8216f 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -434,15 +434,31 @@ class Wallet(models.Model): files_list = self.get_fnames() files = [] sexytopo = False + topodroid = False + zipfiles = False for f in files_list: if isinstance(f, Path): # ignore directories which have been turned into strings files.append(f) if str(f).endswith(".data.json"): # we have sexytopo data sexytopo = True + if str(f)=="manifest" or str(f)=="survey.sql": # we probably have topodroid.. + topodroid = True + if str(f).endswith(".zip") or str(f).endswith(".top"): # might be anything + zipfiles = True + + if zipfiles: + print(f".zip file or .top file found at {self.walletname}") + waldata["electronic survey"] = True + + if topodroid: + waldata["electronic survey"] = True + print(f"topodroid found at {self.walletname}") if sexytopo: waldata["electronic survey"] = True + print(f"sexytopo found at {self.walletname}") for f in files: + # This list 'files' is only used to calculate tick lists and to colour the boxes if str(f).endswith("ext-elevation.json"): files.remove(f) if str(f).endswith(".plan.json"): @@ -466,12 +482,15 @@ class Wallet(models.Model): plan_drawing_required = not (plan_scanned or waldata["plan drawn"] or waldata["plan not required"]) if plan_drawing_required: if waldata["electronic survey"]: - ticks["P"] = "seagreen" + ticks["P"] = "maroon" else: ticks["P"] = "red" else: - ticks["P"] = "green" - + if waldata["electronic survey"]: + ticks["P"] = "limegreen" + else: + ticks["P"] = "green" + # Elev drawing required elev_scanned = reduce(operator.or_, [f.stem.startswith("elev") for f in files], False) elev_scanned = reduce(operator.or_, [f.stem.endswith("elev") for f in files], elev_scanned) # sexytopo does this, so we need to be clear @@ -479,11 +498,14 @@ class Wallet(models.Model): elev_drawing_required = not (elev_scanned or waldata["elev drawn"] or waldata["elev not required"]) if elev_drawing_required: if waldata["electronic survey"]: - ticks["E"] = "seagreen" + ticks["E"] = "maroon" else: ticks["E"] = "red" else: - ticks["E"] = "green" + if waldata["electronic survey"]: + ticks["E"] = "limegreen" + else: + ticks["E"] = "green" # Tunnel / Therion ticks["T"] = "red" # default is that it is not tunnelled @@ -505,7 +527,6 @@ class Wallet(models.Model): else: ticks["W"] = "red" - return ticks def __str__(self): diff --git a/core/views/wallets_edit.py b/core/views/wallets_edit.py index df050c0..4fad419 100644 --- a/core/views/wallets_edit.py +++ b/core/views/wallets_edit.py @@ -16,7 +16,7 @@ from django.shortcuts import render import settings from troggle.core.models.caves import Cave from troggle.core.models.logbooks import LogbookEntry # , PersonLogEntry -from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole +from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole, DrawingFile from troggle.core.models.troggle import DataIssue, Expedition, Person from troggle.core.models.wallets import YEAR_RANGE, Wallet, make_valid_date from troggle.core.utils import ( @@ -951,6 +951,10 @@ def walletedit(request, path=None): # print(f"--- {wallet} {thiswallet} walletdate={thiswallet.walletdate} immediately before form render") except: thiswallet = None + drawings = [] + drawingfiles = DrawingFile.objects.filter(dwgwallets=thiswallet) + for d in drawingfiles: + drawings.append(d.dwgpath) context = { "year": year, "recent_year": recent_year, @@ -963,6 +967,7 @@ def walletedit(request, path=None): "waldata": waldata, "svxfiles": svxfiles, "survex": waldata["survex file"], + "drawings": drawings, "survexsize": survexsize, "checked": checked, "trips": trips, diff --git a/templates/dwgfiles.html b/templates/dwgfiles.html index 23a307f..fcb64f3 100644 --- a/templates/dwgfiles.html +++ b/templates/dwgfiles.html @@ -18,7 +18,7 @@ necessarily what is currently in the wallet. {% for dwgfile in dwgfiles %} - {{dwgfile.dwgpath}} + {{dwgfile.dwgpath}} {{dwgfile.filesize}} {{dwgfile.npaths}} diff --git a/templates/walletform.html b/templates/walletform.html index e466047..1df7537 100644 --- a/templates/walletform.html +++ b/templates/walletform.html @@ -164,6 +164,14 @@ and also the exported files in standard formats: svx, svg etc. See why
{% endif %} + {% if drawings %}Drawings:
+ + {% for d in drawings %} +   {{d}}
+ {% endfor %} +
+
+ {% endif %} {% endfor %} @@ -226,7 +234,7 @@ and also the exported files in standard formats: svx, svg etc. See why
- +