diff --git a/core/views/survex.py b/core/views/survex.py index 3ab7dd9..7ac206a 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -18,7 +18,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie import troggle.settings as settings from troggle.core.models.logbooks import LogbookEntry from troggle.core.models.caves import Cave -from troggle.core.models.survex import SurvexFile, SurvexBlock +from troggle.core.models.survex import SurvexFile, SurvexBlock, SurvexDirectory from troggle.core.models.wallets import Wallet from troggle.core.utils import only_commit from troggle.parsers.survex import parse_one_file @@ -642,6 +642,27 @@ def survexcaveslist(request): }, ) +def survexdir(request): + """report on all the SurvexDirectory objects + We are trying to find out how mismatches have crept in. + """ + + sds = SurvexDirectory.objects.all().order_by("cave") + for sd in sds: + sd.primarybad = True + if f"{sd.primarysurvexfile}".startswith(str(sd.path)): + sd.primarybad = False + + sd.cavebad = True + munge = f"caves-{sd.cave}".lower() + if str(sd.path).lower().replace("/","-").startswith(munge): + sd.cavebad = False + + sd.pathbad = True + if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file(): + sd.pathbad = False + return render(request, "survexdir.html", {"survexdirs": sds}) + def survexcavesingle(request, survex_cave): """parsing all the survex files of a single cave and showing that it's consistent and can find all diff --git a/parsers/survex.py b/parsers/survex.py index cebeb91..52ecc70 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -68,6 +68,8 @@ class SurvexLeg: def IdentifyCave(cavepath): """Given a file path for a survex file, or a survex-block path, return the cave object + + This is clearly getting it badly wrong, see /survexdirs report. """ caveslist = GetCaveLookup() if cavepath.lower() in caveslist: @@ -1171,6 +1173,8 @@ class LoadingSurvex: it sets the primarysurvexfile. This is correct as it should be set on the first file in the directory, where first is defined by the *include ordering. Which is what we are doing. + + This does NOT set the current cave id in the SurvexDirectory, that happens later """ if not headpath: return self.svxdirs[""] diff --git a/templates/controlPanel.html b/templates/controlPanel.html index bc71ae2..b50821c 100644 --- a/templates/controlPanel.html +++ b/templates/controlPanel.html @@ -25,6 +25,7 @@
  • Expoer name aliases -short names recognised by troggle
  • Data Issues on Imports - warnings and errors from the recent data import
  • Wild survex files - survex files contianing blocks with no related wallet +
  • Survex Directories - Every Cave has an associated directory and a Primary survex file
  • Survex import record - indented *include and begin/end tree
  • Survex debug report - warnings and details
  • Therion Import issues - warnings from the recent data import

  • Django admin - Deep magic access to all models and data diff --git a/templates/survexdir.html b/templates/survexdir.html new file mode 100644 index 0000000..7600077 --- /dev/null +++ b/templates/survexdir.html @@ -0,0 +1,22 @@ + +{% extends "base.html" %} +{% block title %}List of survex directories{% endblock %} +{% block content %} + +{% autoescape off %} +

    SurvexDirectory objects

    +{% endautoescape %} + + + + +{% for sd in survexdirs %} + + + + + + +{% endfor %} +
    CaveCaveIDPathPrimary
    {{sd.cave}}{{sd.cave.id}}{{sd.path}}{{sd.primarysurvexfile}}.svx MISMATCH {% endif %}
    +{% endblock %} diff --git a/urls.py b/urls.py index f9e1b84..513a1eb 100644 --- a/urls.py +++ b/urls.py @@ -182,6 +182,8 @@ trogglepatterns = [ path('controlpanel', controlpanel, name="controlpanel"), # The survexfile pages + path('survexdir', survex.survexdir, name="survexdir"), + path('survexfile', survex.survexcavesingle, {'survex_cave': ''}, name="survexcavessingle"), path('survexfile/', survex.survexcavesingle, {'survex_cave': ''}, name="survexcavessingle"), path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"),