{% extends "base.html" %} {% block title %}Cave re-labelling from unofficial identifier to official Kataster number {% endblock %} {% block content %}

Cave re-labelling from unofficial identifier to official Kataster number

Cave {{cave.slug|safe}} '{{cave.official_name|safe}}'

{% if cave.kataster_number %} This cave has already been "katastered". area:{{cave.areacode |safe}} number:{{cave.kataster_number |safe}} {% else %} This cave needs to be "katastered". If you have the new number issued by the Austrians, we can do it now. {% csrf_token %} {{form.as_p}} {% endif %}

{{warning|safe}}

{{error|safe}}

Rename the .html files in expoweb

{{cave_data|safe}}
   <kataster_number></kataster_number>
    → <kataster_number>{{knum}}</kataster_number>
   <survex_file>{{cave.survex_file}} </survex_file>
    → <survex_file>caves-{{cave.areacode}}/{{knum}}/{{knum}}.svx </survex_file>

{% for e in entrance_data %} {{e|safe}}
{% endfor %}

Rename the cave description directory in expoweb

There are 82 69 cave description sub-files, i.e. single pages with a larger image and caption using the t/i/l convention, are not in
1623/[cave]/l/*.html but are directly in
1623/l/[cave]*.html
due to early versions of Martin's image insertion tool for editing cave descriptions. 21 of these do did not even have filenames beginning with [cave], the cave unofficial identifier, but are all digits. They seem to be all 2023 discoveries or caves which have had images added to their descriptions in 2023.

{% if misplaced %} 1623/l/ :
{% endif %} {{misplaced|safe}}

If we don't edit these, things will still work, i.e. cave description images will still appear, but the names of the files no longer match the new kataster name of the cave. Fixing this - so that these files are stored together with the rest of the stuff just for that cave - could be included in in this renaming tool, but is perhaps better done as another job - which needs doing as troggle does some weird perversions to display these images. Some of these caves may never be katastered.

Rename the survex directory in loser

{{loser_name|safe}}/

{% for f in loser_data %}    {{f|safe}}
{% endfor %}

Here are all the survex files which are involved with this cave, the first one on this list should be the same as the one shown above. Any others will need fixing manually:
{% for svx in cave.survexfile_set.all %} {{svx}}.svx
{%endfor %}

Sort out the *fix point(s) in both loser and in expoweb

Without fully parsing the entire survex *include tree (which this code does not do), it is impossible to find the *fix declaration file from the 'station' fields in the entrance_data files. However we conventionally store the *fix in a "known" place, so we try.

Edit these Entrance files:

{% for e in entrances %} entrance_data/{{e}}.html{% if e.tag_station%}
   
tag_station: {{e.tag_station}}{% endif %} {% if e.other_station%}
   
other_station: {{e.other_station}}{% endif %}
{% endfor %}

Check the wallet links to survex files in drawings

Edit these Wallet files

and if any of them are any of these survex files:
{% for svx in cave.survexfile_set.all %} {{svx}}.svx
{%endfor %}
then the wallet needs editing: do this online (click on the wallet id link above) before you run any of the katastering script. Doing it online will also do all the git commit stuff for you.

If doing this manually, it is much easier to do this using the online wallet edit form than to mess with the raw format of the JSON files, which we never touch and so will be unfamiliar to everyone.

Set the historic alias forwarder in expoweb

This will cause lots of errors until the cave "{{cave.areacode |safe}}-{{knum}}" has been created by a full database reset OR we can do an online rename of the "Cave" object in the database [code yet to be written] by pressing this button [button not yet implemented].

Finally

Ideal scenario

Ideally you do this renumbering on a standalone instance of troggle running on a troggle development laptop and you don't push any of the git commits to the server until you have got all the niggles out of the conversion, i.e. the databaseReset runs locally without any warnings or errors introduced by your renaming and 'cavern' runs without any new survex errors.

Copy this script and edit it to match the directory names on your PC


{{warning|safe}}

{{error|safe}}

{% endblock %}