{% extends "base.html" %}
{% block title %}Cave fix misplaced images and descriptive files
<!-- cave_kataster.html - this text visible because this template has been included -->
{% endblock %}

{% block content %}



<h2>Cave fix misplaced images and descriptive files</h2>

This page and the code behind it ( in troggle/core/views/cave_kataster.py) is for one-off data reformatting and rearrangment fixes. Once the fix has been done it never needs to be done again.
<p>This is in contrast to the <a href="/kataster/1623-1992-X01">katastering tool</a> which is used regularly: whenever a cave with a discovery unofficial name gets an official kataster number.
<p>
In the past we have reformatted the URLs and filenames for caves which were incompletely katastered, and for caves where for several months the images in the cave descriptions were put in the worng place by unfinished software. In the future we expect to have to tidy up the incoherent QMs system, move non-cave "guidebook" material out of the /1623/ directory tree, extract EXIF GPS data from photos and a lot more. Making the logbook entries have properly persistent internal IDs would also be a good thing.

<form action="{% url 'fix' areacode %}" method="post">
<p>

{% csrf_token %}
{{form.as_p}}
	<button  class="fancybutton"  style="padding: 0.5em 25px; font-size: 100%;" type = "submit" >
		See what the edits look like &rarr;
	</button>	

<div style="color:red; font-weight: bold; font-size: large">
{{warning|safe}}<p>
{{error|safe}}</div>

<h3>Rename the cave description directories in <var>expoweb/<a href="/{{areacode|safe}}">{{areacode|safe}}</a>/</var></h3>

Done.

<p><b><samp>
{% if misplaced %}
<samp><b>1623/l/ :</samp></b><br />
{% endif %}
{{misplaced|safe}}
</samp></b><br />

<h3>Fix the old-style URLS "115/ent.jpg" to "ent.jpg" or "/1623/115/ent.jpg" in <var>expoweb/<a href="/{{areacode|safe}}">{{areacode|safe}}</a>/</var></h3>
<p>
<ul style="list-style: disc">
<li> Edit all the '<samp>href=</samp>' and '<samp>src=</samp>' <small>URLS</small> (if they exist) inside all the <samp>cave_data</samp> and <samp>entrance_data</samp> files descriptive text to refer to the new directory
</ul>

<h3>Finally</h3>
<ul style="list-style: disc">
<li><samp>cd loser<br />
git add *<br />
git commit -m 'Moving misplaced files  {{cave.slug|safe}} in <span style="color:blue">{{areacode |safe}}</span>'<br />
git pull<br />
git push<br />
cd ../expoweb<br />
git add *<br />
git commit -m 'Moving misplaced files  {{cave.slug|safe}} in <span style="color:blue">{{areacode |safe}}</span>'<br />
git pull<br />
git push<br />
</samp>
<li>It is then vital to do a complete databaseReset as troggle has internally indexed all those {{cave.slug}} files, the indexes are now out of date and horrible things will happen when people try to use troggle with any cave that has been altered:<br />
<samp>uv run databaseReset reset <span style="color:blue">M{{areacode}}</span></samp><br />
OR we can do an online rename of the "Cave" object in the database [code yet to be written] by pressing the button above [button not yet implemented].
<li>Look in the reset import warnings and errors report to see if anything has gone wrong:
<var><a href="http://expo.survex.com/dataissues">expo.survex.com/dataissues</a></var><br />
(in fact, look at this before you do any of this, so you can see what chnages.)
</ul>

<h3>Ideal scenario</h3>
<p>
<p>Ideally you do this renumbering and fixups on a standalone instance of troggle running on a <var> &#9874; <a href="/handbook/troggle/troglaptop.html">troggle development laptop</a></var> 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 <em>and</em> 'cavern' runs without any new survex errors.

<h3>Copy this script and edit it to match the directory names on your PC</h3>
<textarea id="script" name="script" rows="{{rows}}" cols="110" style="font-size:small; font-weight: bold; background-color: LemonChiffon">
{{x_script}}
</textarea>

<br />
<!-- duplicate button at bottom of long page -->
	<button  class="fancybutton"  style="padding: 0.5em 25px; font-size: 100%;" type = "submit" >
		See what the edits look like &rarr;
	</button>	
</form>
<div style="color:red; font-weight: bold; font-size: large">
{{warning|safe}}<p>
{{error|safe}}</div>
{% endblock %}
