summaryrefslogtreecommitdiffstats
path: root/core/views/survex.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-03-05 18:20:18 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2023-03-05 18:20:18 +0000
commit4a2106183a2351321d780615e42abddc08874b3b (patch)
treed1f8cc9cc2ceb22048f42c7a8f9babb75f25e99e /core/views/survex.py
parent06ac840dd077e38d6158411884524fbfd10c03bd (diff)
downloadtroggle-4a2106183a2351321d780615e42abddc08874b3b.tar.gz
troggle-4a2106183a2351321d780615e42abddc08874b3b.tar.bz2
troggle-4a2106183a2351321d780615e42abddc08874b3b.zip
Bugfix for new survex file
Diffstat (limited to 'core/views/survex.py')
-rw-r--r--core/views/survex.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/views/survex.py b/core/views/survex.py
index e9f7c9f..7f62f58 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -129,6 +129,7 @@ class SvxForm(forms.Form):
if not fname.is_file():
print(">>> >>> WARNING - svx file not found, showing TEMPLATE SVX", fname, flush=True)
self.template = True
+ self.survexfile = False
return survextemplatefile
refs = SurvexFile.objects.filter(path=self.data["filename"])
if len(refs)==1:
@@ -298,13 +299,17 @@ def svx(request, survex_file):
svxincludes = re.findall(r"(?i)\*include\s+(\S+)", form.data["code"] or "")
svxfile = form.survexfile # only valid once form.GetDiscCode() called
+ print(svxfile)
try:
svxblocksall = svxfile.survexblock_set.all()
except AttributeError: # some survexfiles just *include files and have no blocks themselves
svxblocksall = []
# collect all the survex blocks which actually have a valid date
- svxblocks = svxfile.survexblock_set.filter(date__isnull=False).order_by('date')
+ if svxfile:
+ svxblocks = svxfile.survexblock_set.filter(date__isnull=False).order_by('date')
+ else:
+ svxblocks = []
events = events_on_dates(svxblocks)