From 4a2106183a2351321d780615e42abddc08874b3b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 5 Mar 2023 18:20:18 +0000 Subject: Bugfix for new survex file --- core/views/survex.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/views/survex.py') 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) -- cgit v1.2.3