2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-02-08 14:28:09 +00:00

display drawings on wallet data

This commit is contained in:
2025-09-27 21:59:37 +03:00
parent 4d3821f572
commit deead77c08
4 changed files with 43 additions and 9 deletions

View File

@@ -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):

View File

@@ -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,