Bugfix for new survex file

This commit is contained in:
2023-03-05 18:20:18 +00:00
parent 06ac840dd0
commit 4a2106183a
2 changed files with 11 additions and 2 deletions

View File

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