mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
Fixed survex file list for one or more caves
This commit is contained in:
parent
38d0e855c9
commit
83d058221d
@ -490,10 +490,9 @@ def GetCaveLookup():
|
|||||||
|
|
||||||
Used when parsing wallets contents.json file too in views/uploads.py
|
Used when parsing wallets contents.json file too in views/uploads.py
|
||||||
|
|
||||||
Does NOT detect duplicates! Needs fixing.
|
Needs to be a proper function that raises an exception if there is a duplicate.
|
||||||
Needs to be a proper funciton that raises an exception if there is a duplicate.
|
|
||||||
OR we could set it to return None if there are duplicates, and require the caller to
|
OR we could set it to return None if there are duplicates, and require the caller to
|
||||||
fall back on doing the actual database query it wants rather thna using this cache shortcut
|
fall back on doing the actual database query it wants rather than using this cache shortcut
|
||||||
"""
|
"""
|
||||||
|
|
||||||
duplicates = {}
|
duplicates = {}
|
||||||
@ -506,10 +505,7 @@ def GetCaveLookup():
|
|||||||
else:
|
else:
|
||||||
if cave == Gcavelookup[id]:
|
if cave == Gcavelookup[id]:
|
||||||
pass # same id, same cave
|
pass # same id, same cave
|
||||||
else: # same id but different cave
|
else: # same id but different cave, e.g. 122 => 1623-122 and 1626-122
|
||||||
# message = f" - Warning: ignoring alias id '{id:3}'. Caves '{Gcavelookup[id]}' and '{cave}'. "
|
|
||||||
# print(message)
|
|
||||||
# DataIssue.objects.create(parser="aliases", message=message)
|
|
||||||
duplicates[id] = 1
|
duplicates[id] = 1
|
||||||
|
|
||||||
global Gcavelookup
|
global Gcavelookup
|
||||||
@ -689,7 +685,7 @@ def GetCaveLookup():
|
|||||||
Gcavelookup[i[0]] = Gcavelookup[i[1]]
|
Gcavelookup[i[0]] = Gcavelookup[i[1]]
|
||||||
else:
|
else:
|
||||||
message = f" * Coding or cave existence mistake, cave for id '{i[1]}' does not exist. Expecting to set alias '{i[0]}' to it"
|
message = f" * Coding or cave existence mistake, cave for id '{i[1]}' does not exist. Expecting to set alias '{i[0]}' to it"
|
||||||
# print(message)
|
print(message)
|
||||||
DataIssue.objects.create(parser="aliases", message=message)
|
DataIssue.objects.create(parser="aliases", message=message)
|
||||||
|
|
||||||
addmore = {}
|
addmore = {}
|
||||||
|
@ -17,7 +17,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
|
|||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.logbooks import LogbookEntry
|
from troggle.core.models.logbooks import LogbookEntry
|
||||||
from troggle.core.models.caves import Cave
|
from troggle.core.models.caves import Cave, GetCaveLookup
|
||||||
from troggle.core.models.survex import SurvexFile, SurvexBlock, SurvexDirectory
|
from troggle.core.models.survex import SurvexFile, SurvexBlock, SurvexDirectory
|
||||||
from troggle.core.models.wallets import Wallet
|
from troggle.core.models.wallets import Wallet
|
||||||
from troggle.core.utils import only_commit
|
from troggle.core.utils import only_commit
|
||||||
@ -670,43 +670,41 @@ def survexdir(request):
|
|||||||
# print(f, f.cave)
|
# print(f, f.cave)
|
||||||
return render(request, "survexdir.html", {"survexdirs": sds, "survexfiles": survexfiles})
|
return render(request, "survexdir.html", {"survexdirs": sds, "survexfiles": survexfiles})
|
||||||
|
|
||||||
|
def get_directories(cave):
|
||||||
def survexcavesingle(request, survex_cave):
|
sds = []
|
||||||
|
sfs = cave.survexfile_set.all()
|
||||||
|
for sf in sfs:
|
||||||
|
sds.append(sf.survexdirectory)
|
||||||
|
return list(set(sds))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def survexcavesingle(request, cave_shortname):
|
||||||
"""parsing all the survex files of a single cave and showing that it's consistent and can find all
|
"""parsing all the survex files of a single cave and showing that it's consistent and can find all
|
||||||
the files and people. Should explicitly fix the kataster number thing.
|
the files and people.
|
||||||
kataster numbers are not unique across areas. This used to be a db constraint but we need to manage
|
|
||||||
this ourselves as we don't want the parser aborting with an error message.
|
|
||||||
|
|
||||||
Should use getCave() from models_caves
|
|
||||||
"""
|
"""
|
||||||
sc = survex_cave
|
|
||||||
try:
|
Gcavelookup = GetCaveLookup()
|
||||||
cave = Cave.objects.get(kataster_number=sc) # This may not be unique.
|
if cave_shortname in Gcavelookup:
|
||||||
return render(request, "svxcavesingle.html", {"settings": settings, "cave": cave})
|
cave = Gcavelookup[cave_shortname]
|
||||||
|
# print(f"survexcavesingle {cave_shortname=} => {cave=}")
|
||||||
except ObjectDoesNotExist:
|
cave.sds = get_directories(cave)
|
||||||
# can get here if the survex file is in a directory labelled with unofficial number not kataster number.
|
return render(request, "svxcaves.html", {"settings": settings, "caves": [cave]})
|
||||||
# maybe - and _ mixed up, or CUCC-2017- instead of 2017-CUCC-, or CUCC2015DL01 . Let's not get carried away..
|
else:
|
||||||
|
# not a cave or an ambiguous short name, e.g. "122"
|
||||||
# or it might be an exact search for a specific survefile but just missing the '.svx.
|
|
||||||
if (SVXPATH / Path(survex_cave + ".svx")).is_file():
|
# if (SVXPATH / Path(cave_shortname + ".svx")).is_file():
|
||||||
return svx(request, survex_cave)
|
# return svx(request, cave_shortname)
|
||||||
|
|
||||||
for unoff in [sc, sc.replace("-", "_"), sc.replace("_", "-"), sc.replace("-", ""), sc.replace("_", "")]:
|
|
||||||
try:
|
|
||||||
cave = Cave.objects.get(unofficial_number=unoff) # return on first one we find
|
|
||||||
return render(request, "svxcavesingle.html", {"settings": settings, "cave": cave})
|
|
||||||
except ObjectDoesNotExist:
|
|
||||||
continue # next attempt in for loop
|
|
||||||
return render(request, "errors/svxcavesingle404.html", {"settings": settings, "cave": sc})
|
|
||||||
|
|
||||||
except MultipleObjectsReturned:
|
|
||||||
caves = Cave.objects.filter(kataster_number=survex_cave)
|
|
||||||
return render(request, "svxcaveseveral.html", {"settings": settings, "caves": caves})
|
|
||||||
|
|
||||||
except:
|
|
||||||
return render(request, "errors/svxcavesingle404.html", {"settings": settings, "cave": sc})
|
|
||||||
|
|
||||||
|
caves = Cave.objects.filter(kataster_number=cave_shortname)
|
||||||
|
if len(caves) > 0:
|
||||||
|
# print(f"many {cave_shortname=} => {caves=}")
|
||||||
|
for cave in caves:
|
||||||
|
cave.sds = get_directories(cave)
|
||||||
|
# print(f"many {cave=} => {cave.sds=}")
|
||||||
|
return render(request, "svxcaves.html", {"settings": settings, "caves": caves})
|
||||||
|
else:
|
||||||
|
return render(request, "errors/svxcaves404.html", {"settings": settings, "cave": cave_shortname})
|
||||||
|
|
||||||
def check_cave_registered(area, survex_cave):
|
def check_cave_registered(area, survex_cave):
|
||||||
"""Checks whether a cave has been properly registered when it is found in the Loser repo
|
"""Checks whether a cave has been properly registered when it is found in the Loser repo
|
||||||
@ -714,8 +712,8 @@ def check_cave_registered(area, survex_cave):
|
|||||||
Currently Caves are only registered if they are listed in :expoweb: settings.CAVEDESCRIPTIONS
|
Currently Caves are only registered if they are listed in :expoweb: settings.CAVEDESCRIPTIONS
|
||||||
so we need to add in any more here.
|
so we need to add in any more here.
|
||||||
|
|
||||||
This function runs but does not seem to be used?!
|
This function is used in survexcaveslist(request)
|
||||||
A serious bodge anyway.
|
A serious bodge.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
cave = Cave.objects.get(kataster_number=survex_cave)
|
cave = Cave.objects.get(kataster_number=survex_cave)
|
||||||
|
@ -3,21 +3,18 @@
|
|||||||
{% block title %}List of survex files{% endblock %}
|
{% block title %}List of survex files{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% for cave in caves %}
|
||||||
{% autoescape off %}
|
{% autoescape off %}
|
||||||
<h1>Surveys for <a href="/{{cave.url}}">{{cave.official_name}}</a> - id:{{cave}}</h1>
|
<h1>Surveys for <a href="/{{cave.url}}">{{cave.official_name}}</a> - id:{{cave}}</h1>
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
<!-- the only thing passed into this template is the object identifier for a cave.
|
|
||||||
All the processing to extract the survex subdriectories and survex files is done in this template
|
|
||||||
|
|
||||||
CHANGE THAT and do the processing in python were it is easier to see what is going on and where
|
|
||||||
we don't need the SUrvexDirectory objects at all-->
|
|
||||||
|
|
||||||
<p>Cave description: <a href="/{{cave.url}}">{{cave.url}}</a>
|
<p>Cave description: <a href="/{{cave.url}}">{{cave.url}}</a>
|
||||||
<p>Wallets: <a href="/cave/scans/{{cave|safe}}">{{cave|safe}}</a>
|
<p>Wallets: <a href="/cave/scans/{{cave|safe}}">{{cave|safe}}</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{% for survexdirectory in cave.survexdirectory_set.all %} <!-- redo to use cave.survexfile_set.all() each of which has a .survexdirectory-->
|
{% for survexdirectory in cave.sds %} <!-- redo to use cave.survexfile_set.all() each of which has a .survexdirectory-->
|
||||||
<a href="#T_{{survexdirectory.primarysurvexfile.path}}">{{survexdirectory.path}}</a>
|
<a href="#T_{{survexdirectory.primarysurvexfile.path}}">{{survexdirectory.path}}</a>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p>If you were expecting to see a list of survex files here and a summary table of who did what and when, perhaps
|
<p>If you were expecting to see a list of survex files here and a summary table of who did what and when, perhaps
|
||||||
because you followed a link from <a href="/survexfile/caves/">the master caves' survex list</a> page which showed that such survex files clearly existed, and yet there is nothing here but a blank; then this will be because <br>
|
because you followed a link from <a href="/survexfile/caves/">the master caves' survex list</a> page which showed that such survex files clearly existed, and yet there is nothing here but a blank; then this will be because <br>
|
||||||
@ -42,7 +39,7 @@ to go to a form to correct the online data.
|
|||||||
Instructions for filling in this form are in this part
|
Instructions for filling in this form are in this part
|
||||||
<a href="/handbook/survey/caveentry.html"> of the survey handbook</a>.
|
<a href="/handbook/survey/caveentry.html"> of the survey handbook</a>.
|
||||||
</p>
|
</p>
|
||||||
{% for survexdirectory in cave.survexdirectory_set.all %}
|
{% for survexdirectory in cave.sds %}
|
||||||
<h3 id="T_{{survexdirectory.primarysurvexfile.path}}">{{survexdirectory.path}}</h3>
|
<h3 id="T_{{survexdirectory.primarysurvexfile.path}}">{{survexdirectory.path}}</h3>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Survex file</th><th>Block</th><th>Date</th><th>Explorers</th><th>length</th><th>Titles</th><th>Scans</th></tr>
|
<tr><th>Survex file</th><th>Block</th><th>Date</th><th>Explorers</th><th>length</th><th>Titles</th><th>Scans</th></tr>
|
||||||
@ -98,8 +95,9 @@ to go to a form to correct the online data.
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %} <!-- survexblock -->
|
||||||
{% endfor %}
|
{% endfor %} <!-- survexfile -->
|
||||||
</table>
|
</table>
|
||||||
{% endfor %}
|
{% endfor %} <!-- survexdirectory -->
|
||||||
|
{% endfor %} <!-- caves -->
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,101 +0,0 @@
|
|||||||
<!-- svxcaveseveral.html - this text visible because this template has been included -->
|
|
||||||
{% extends "base.html" %}
|
|
||||||
{% block title %}List of survex files{% endblock %}
|
|
||||||
{% block content %}
|
|
||||||
<!-- the only thing passed into this template is a list of object identifiers for caves.
|
|
||||||
All the processing to extract the survex subdriectories and survex files is done in this template -->
|
|
||||||
{% for cave in caves %}
|
|
||||||
|
|
||||||
{% autoescape off %}
|
|
||||||
<h1>Surveys for <a href="/{{cave.url}}">{{cave.official_name}}</a> - identifier:{{cave}}</h1>
|
|
||||||
{% endautoescape %}
|
|
||||||
|
|
||||||
<p>Cave description: <a href="/{{cave.url}}">{{cave.url}}</a>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
{% for survexdirectory in cave.survexdirectory_set.all %}
|
|
||||||
This cave has a linked survexdirectory: <a href="#T_{{survexdirectory.primarysurvexfile.path}}">{{survexdirectory.path}}</a> in the database. See the table below.
|
|
||||||
{% empty %}
|
|
||||||
<p>If you were expecting to see a list of survex files here and a summary table of who did what and when, perhaps
|
|
||||||
because you followed a link from <a href="/survexfile/caves/">the master caves' survex list</a> page which showed that such survex files clearly existed, and yet there is nothing here but a blank; then this will be because the survex (.svx) files have been stored on the server in the
|
|
||||||
<a href="/handbook/computing/repos.html"><var>:loser:</var></a> repository
|
|
||||||
but whoever was
|
|
||||||
responsible has not yet created the appropriate entries in the XML file in the
|
|
||||||
<a href="/handbook/computing/repos.html"><var>:expoweb:</var></a> repository.
|
|
||||||
It is the XML file which registers the cave description and ties together
|
|
||||||
the survex files with everything else.
|
|
||||||
<p>The process for registering a new cave is documented in
|
|
||||||
<a href="/handbook/survey/caveentry.html">this part of the survey handbook</a>.
|
|
||||||
{% endfor %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>If you can see a filename here: [ <a href="/survexfile/{{cave.survex_file}}">{{cave.survex_file}}</a> ]
|
|
||||||
which does <em>not</em> match any in the list below <em>including the directories beginning with </em><strong>caves-162X/</strong></em>
|
|
||||||
not just the filename</em>, then (if logged on) you can
|
|
||||||
<strong>click here <var><a href="/{{cave.slug}}_cave_edit/">/{{cave.slug}}_cave_edit</a></var></strong>
|
|
||||||
to go to a form to correct the online data.
|
|
||||||
Instructions for filling in this form are in this part
|
|
||||||
<a href="/handbook/survey/caveentry.html"> of the survey handbook</a>.
|
|
||||||
</p>
|
|
||||||
{% for survexdirectory in cave.survexdirectory_set.all %}
|
|
||||||
<h3 id="T_{{survexdirectory.primarysurvexfile.path}}">{{survexdirectory.path}}</h3>
|
|
||||||
<table>
|
|
||||||
<tr><th>Survex file</th><th>Block</th><th>Date</th><th>Explorers</th><th>length</th><th>Titles</th><th>Scans</th></tr>
|
|
||||||
{% for survexfile in survexdirectory.survexfile_set.all %}
|
|
||||||
<tr>
|
|
||||||
{% if survexfile.exists %}
|
|
||||||
<td rowspan="{{survexfile.survexblock_set.all|length|add:"1"}}">
|
|
||||||
{% else %}
|
|
||||||
<td class="survexnewfile" rowspan="{{survexfile.survexblock_set.all|length|add:"1"}}">
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if survexfile == survexdirectory.primarysurvexfile %}
|
|
||||||
<a href="{% url "svx" survexfile.path %}"><b>{% url "svx" survexfile.path %}</b></a>
|
|
||||||
{% else %}
|
|
||||||
<a href="{% url "svx" survexfile.path %}"><i><small>{% url "svx" survexfile.path %}</small></i></a><!-- would like to extract only the last bit. Some javascript useful ?-->
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% for survexblock in survexfile.survexblock_set.all %}
|
|
||||||
<tr>
|
|
||||||
<!-- Block -->
|
|
||||||
<td style="width:10 em"><a href="{% url "svx" survexfile.path %}">{{survexblock.name}}</a></td>
|
|
||||||
|
|
||||||
<!-- Date -->
|
|
||||||
<td style="white-space:nowrap">
|
|
||||||
{% if survexblock.expedition %}
|
|
||||||
<a href="{{survexblock.expedition.get_absolute_url}}">{{survexblock.date|date:"D d M Y"}}</a>
|
|
||||||
{% else %}
|
|
||||||
<!--{{survexblock.date}}-->
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<!-- Explorers -->
|
|
||||||
<td>
|
|
||||||
{% for personrole in survexblock.survexpersonrole_set.all %}
|
|
||||||
{% if personrole.personexpedition %}
|
|
||||||
<a href="{{personrole.personexpedition.get_absolute_url}}">{{personrole.personname}}</a>
|
|
||||||
{% else %}
|
|
||||||
{{personrole.personname}}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
<!-- length -->
|
|
||||||
<td style="padding-right: 3px; text-align:right">{{survexblock.legslength|stringformat:".1f"}}</td>
|
|
||||||
|
|
||||||
<!-- Titles -->
|
|
||||||
<td style="padding-left: 3px;">
|
|
||||||
{{survexblock.title}}
|
|
||||||
</td>
|
|
||||||
<!-- Scans -->
|
|
||||||
<td>
|
|
||||||
{% if survexblock.scanswallet %}
|
|
||||||
<b><a href="{{survexblock.scanswallet.get_absolute_url}}">{{survexblock.scanswallet.walletname}}</a></b>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
</table><p>
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endblock %}
|
|
6
urls.py
6
urls.py
@ -184,8 +184,8 @@ trogglepatterns = [
|
|||||||
# The survexfile pages
|
# The survexfile pages
|
||||||
path('survexdir', survex.survexdir, name="survexdir"),
|
path('survexdir', survex.survexdir, name="survexdir"),
|
||||||
|
|
||||||
path('survexfile', survex.survexcavesingle, {'survex_cave': ''}, name="survexcavessingle"),
|
path('survexfile', survex.survexcavesingle, {'cave_shortname': ''}, name="survexcavessingle"),
|
||||||
path('survexfile/', survex.survexcavesingle, {'survex_cave': ''}, name="survexcavessingle"),
|
path('survexfile/', survex.survexcavesingle, {'cave_shortname': ''}, name="survexcavessingle"),
|
||||||
path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"),
|
path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"),
|
||||||
path('survexfile/caves/', survex.survexcaveslist, name="survexcaveslist"), # auto slash not working
|
path('survexfile/caves/', survex.survexcaveslist, name="survexcaveslist"), # auto slash not working
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ trogglepatterns = [
|
|||||||
path('survexfile/<path:survex_file>.3d', survex.threed, name="threed"),
|
path('survexfile/<path:survex_file>.3d', survex.threed, name="threed"),
|
||||||
path('survexfile/<path:survex_file>.log', survex.svxlog, name="svxlog"),
|
path('survexfile/<path:survex_file>.log', survex.svxlog, name="svxlog"),
|
||||||
path('survexfile/<path:survex_file>.err', survex.err, name="err"),
|
path('survexfile/<path:survex_file>.err', survex.err, name="err"),
|
||||||
path('survexfile/<path:survex_cave>', survex.survexcavesingle, name="survexcavessingle"),
|
path('survexfile/<path:cave_shortname>', survex.survexcavesingle, name="survexcavessingle"),
|
||||||
|
|
||||||
path('survexfilewild', statistics.svxfilewild, name="svxfilewild"),
|
path('survexfilewild', statistics.svxfilewild, name="svxfilewild"),
|
||||||
path('survexfilewild/', statistics.svxfilewild, name="svxfilewild"),
|
path('survexfilewild/', statistics.svxfilewild, name="svxfilewild"),
|
||||||
|
Loading…
Reference in New Issue
Block a user