Bugfix for new survex file

This commit is contained in:
Philip Sargent 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)

View File

@ -79,6 +79,10 @@ else:
# BUT many of these are set up by opinionated Django even if 'django.contrib.auth.urls' is NOT included.
# Some overlap with 'admin.site.urls' needs to be investigated.
# admin.site.urls is urls() which maps to get_urls() which is a function declared
# in django/contrib/admin/sites.py which for me is
# /home/philip/p11d5/lib/python3.11/site-packages/django/contrib/admin/sites.py
trogglepatterns = [
path('expofiles/', include(expofilesurls)), # intercepted by Apache, if it is running.
path('expofiles', include(expofilesurls)), # curious interaction with the include() here, not just a slash problem.
@ -90,7 +94,7 @@ trogglepatterns = [
re_path(r'^people/?$', notablepersons, name="notablepersons"),
re_path(r'^admin/doc/', include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/).
re_path(r'^admin/', admin.site.urls), # includes admin login & logout urls
re_path(r'^admin/', admin.site.urls), # includes admin login & logout urls & /admin/jsi18n/
# Uploads - uploading a file
path('walletedit/', walletedit, name='walletedit'),