From d9d4181dda0afbcc7c7d5da85853fc5a614dcd0c Mon Sep 17 00:00:00 2001 From: Philip Sargent <philip.sargent@gmail.com> Date: Sun, 29 Jan 2023 12:11:47 +0000 Subject: [PATCH] Add new survex import report --- core/utils.py | 2 ++ core/views/statistics.py | 28 +++++++++++++++++++++++++--- templates/controlPanel.html | 2 +- templates/survexreport.html | 28 ++++++++++++++++++++++++++++ urls.py | 1 + 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 templates/survexreport.html diff --git a/core/utils.py b/core/utils.py index 0b18e3b..29c2643 100644 --- a/core/utils.py +++ b/core/utils.py @@ -205,6 +205,8 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}): We are not using new_since_parsing - it is a fossil from Aaron Curtis's design in 2006. So it is always false. NOTE: this takes twice as long as simply creating a new object with the given values. + + As of Jan.2023 this function is not used anywhere in troggle. """ try: diff --git a/core/views/statistics.py b/core/views/statistics.py index 28bc721..65aca94 100644 --- a/core/views/statistics.py +++ b/core/views/statistics.py @@ -21,8 +21,12 @@ from troggle.parsers.people import (GetPersonExpeditionNameLookup, foreign_friends) #from django.views.generic.list import ListView +'''Very simple report pages summarizing data about the whole set of expeditions and of +the status of data inconsistencies +''' def therionissues(request): + """Page displaying contents of a file produced during data import""" logname = "therionrefs.log" logpath = (Path(settings.PYTHON_PATH, logname)) therionlog = [] @@ -40,11 +44,29 @@ def therionissues(request): newlog.append(line) return render(request, 'therionreport.html', {"therionlog":newlog}) -'''Very simple report pages summarizing data about the whole set of expeditions and of -the status of data inconsistencies -''' +def surveximport(request): + """Page displaying contents of a file produced during data import""" + logname = "svxlinear.log" + logpath = (Path(settings.PYTHON_PATH, logname)) + contents = [] + newlog = [] + + if Path(logpath).is_file: + with open(logpath, "r") as f: + contents = f.readlines() + print(f"{logpath} has {len(contents)} entries") + else: + print(f"{logpath} NOT FOUND {len(contents)}") + + for line in contents: + line = line.replace(" ", " ") + newlog.append(line) + return render(request, 'survexreport.html', {"log":newlog}) + def pathsreport(request): + """The CONSTANTs declared in the settings and localsettings and how they have + been evaluated for this specific installation - live """ pathsdict = OrderedDict() try: pathsdict = { diff --git a/templates/controlPanel.html b/templates/controlPanel.html index 825a664..7b5903e 100644 --- a/templates/controlPanel.html +++ b/templates/controlPanel.html @@ -24,7 +24,7 @@ <li><a href="/pathsreport">Folder paths used</a> -folders settings used by this troggle installation <li><a href="/aliases/2022">Expoer name aliases</a> -short names recognised by troggle <li><a href="/dataissues">Data Issues on Imports</a> - warnings and errors from the recent data import -<li><a href="/therionissues">Therion Import issues</a> - warnings from the recent data import<br /><br /> +<li><a href="/surveximport">Survex import record</a> - indented *include and begin/end tree<br /><li><a href="/therionissues">Therion Import issues</a> - warnings from the recent data import<br /><br /> <li><a href="/admin/">Django admin</a> - Deep magic access to all models and data </ul> <h3>This control panel is being redeveloped</h3> diff --git a/templates/survexreport.html b/templates/survexreport.html new file mode 100644 index 0000000..aec0435 --- /dev/null +++ b/templates/survexreport.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% block title %}Data import report{% endblock %} + +{% block content %} +<h1>Expo Survex import report</h1> + + +<h3>*include and begin/end import</h3> +<p>The number at the left-hand margin is the depth of the *include nesting. The indented number to the left of the *begin or *end line shows the depth of the begin/end survex block nesting. *title lines are indnted further to make them more easily visible. +<p>An extra line *edulcni is inserted to show where an included file ends. The *include and *edulcni lines omit the ".svx" from the end of the filename. +<p>The survex files which are NOT part of the main include tree have been collected together and included under a constructed file "_unseens" following the line "0 *include _unseens" into a begin/end block labelled "troggle_unseens". +<hr> +<p>Go to <a href="/controlpanel">Control panel</a> - for other import reports +<hr> +<p style="font-family: Consolas, Lucida Console, monospace;"> +{% for line in log %} +{{line|safe}}<br /> +{% empty %} +<b>No import report file found. Re-import using databaseReset.py</b> +{% endfor %} + +<p>This report is generated from <code>templates/survexreport.html</code> and +by <code>survexreport(request)</code> in <code>core/views/statistics.py </code> +<hr> +<p>Go to <a href="/controlpanel">Control panel</a> - for other import reports +<p>Go to <a href="/handbook/troggle/trogmanual.html">Troggle maintenance manuals</a> +{% endblock %} + diff --git a/urls.py b/urls.py index dcbf573..f7fcc3b 100644 --- a/urls.py +++ b/urls.py @@ -148,6 +148,7 @@ trogglepatterns = [ path('pathsreport', statistics.pathsreport, name="pathsreport"), path('dataissues', statistics.dataissues, name="dataissues"), path('therionissues', statistics.therionissues, name="therionissues"), + path('surveximport', statistics.surveximport, name="surveximport"), path('eastings', statistics.eastings, name="eastings"), path('aliases/<int:year>',statistics.aliases, name="aliases"),