diff --git a/core/views/cave_kataster.py b/core/views/cave_kataster.py index 692890e..cbfe3b3 100644 --- a/core/views/cave_kataster.py +++ b/core/views/cave_kataster.py @@ -43,23 +43,33 @@ def kataster(request, slug): global cavefilename, cave_data, entrance_data, loser_name, loser_data - mvscript = f"cd {settings.CAVEDESCRIPTIONS }\n" + mvscript = "" + + ent_dir = settings.ENTRANCEDESCRIPTIONS # settings.EXPOWEB / "entrance_data" + mvscript += f"cd {settings.ENTRANCEDESCRIPTIONS }\n" + entrance_data = [] + # entrance_ids =[] + for ent in ent_dir.iterdir(): + if str(ent.name).startswith(str(cave)): + print(ent.name) + entrance_data.append("entrance_data/"+ent.name) + # entrance_ids.append(ent.name.replace(".html","")) + mvscript += f"mv {ent.name} {ent.name.replace(str(cave.unofficial_number),str(knum))}\n" + + mvscript += f"\ncd {settings.CAVEDESCRIPTIONS }\n" cavefilename = str(cave) + ".html" target= f"{cave.areacode}-{str(knum)}" cave_data = Path( "cave_data", cavefilename ) if not (settings.CAVEDESCRIPTIONS / cavefilename).is_file: # settings.EXPOWEB / cave_data cave_data = "does not exist" + + mvscript += f'sed -i "//s//{knum}/" {cavefilename}\n' + mvscript += f'sed -i "//s/[^<]*/caves-{cave.areacode}\/{knum}\/{knum}.svx/" {cavefilename}\n' + mvscript += f'sed -i "//s/{str(cave)}/{cave.areacode}-{knum}/" {cavefilename}\n' + mvscript += f"mv {cavefilename} {target}.html\n" - ent_dir = settings.ENTRANCEDESCRIPTIONS # settings.EXPOWEB / "entrance_data" - mvscript += f"\ncd {settings.ENTRANCEDESCRIPTIONS }\n" - entrance_data = [] - for ent in ent_dir.iterdir(): - if str(ent.name).startswith(str(cave)): - print(ent.name) - entrance_data.append("entrance_data/"+ent.name) - mvscript += f"mv {ent.name} {ent.name.replace(str(cave.unofficial_number),str(knum))}\n" loser_data = [] loser_dir, loser_name = get_loser_dir(cave) if (loser_dir).is_dir(): @@ -134,9 +144,10 @@ def kataster(request, slug): # Restart script with POST data script = "# Conversion script - VERY INCOMPLETE AS YET\n# When doing it by hand, it is less error-prone to do the file re-namings last,\n" - script += "# but in a script it does not matter so much so long as everything is consistent and tested.\n" + script += "# after the edits, but in a script it does not matter so much\n" + script += "# so long as everything is consistent and tested.\n" script += "# Except that reversing changes using git does not always restore directories exactly\n# (because of .gitignore).\n\n" - script += "# Be careful with the directory names, they might not be the same on your PC as on the server\n\n" + script += "# Be careful with the directory names, they will usually NOT be the same on your PC as on the server\n\n" warning ="" @@ -158,7 +169,7 @@ def kataster(request, slug): script += f'\necho "{alias}" >> {aliasfile}' - script_rows = str(min(35,3+script.count('\n'))) + script_rows = str(max(35,3+script.count('\n'))) return render( request, "cave_kataster.html", diff --git a/templates/cave_kataster.html b/templates/cave_kataster.html index 0e664c6..19a1480 100644 --- a/templates/cave_kataster.html +++ b/templates/cave_kataster.html @@ -63,6 +63,8 @@ This cave needs to be "katastered". If you have the new number issued by the Aus

Rename the cave description directory in expoweb

+[ TO DO ] +

  • Edit all the 'href=' URLS (if they exist) inside all the cave_data and entrance_data files descriptive text to refer to the new directory
  • Rename the directory (if it exists) inside the areacode directory, e.g. rename /{{cave.areacode}}/{{cave.unofficial_number}}/ as /{{cave.areacode}}/{{knum}}/ (if {{knum}} is the correct new kataster number). Do this last. @@ -85,22 +87,57 @@ This cave needs to be "katastered". If you have the new number issued by the Aus
  • Run 'cavern caves-{{cave.areacode |safe}}/{{knum}}/{{knum}}.svx' and check it all works as you hope
  • Run 'cavern caves-{{cave.areacode |safe}}/caves.svx' and check it all works as you hope
+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

    -
  • Find the *fix point for each entrance (one or more in each entrance_data file) in expoweb. There are two fields on an Entrance where there might be a location: 'tag_station', or 'other_station'. These refer to a survex survey point, which might be *fix elsewhere or one of the survey points in one of the cave survex files. -
  • Change the name of each *fix point in the relevant survex file in loser -
  • Make the same name change(s) in each entrance file (in each entrance_data file) in expoweb +
  • Find the survex station point for each entrance (one or more in each entrance_data file) in expoweb. There are two fields on an Entrance where there might be a location: 'tag_station', or 'other_station'. These refer to a survex survey point, which might be *fix elsewhere or one of the survey points in one of the cave survex files. +
  • Change the name of each survex point in the relevant survex file in loser (usually done by renaming the *begin/*end block +and patching any *equate statements) +
  • Make the same name change(s) in each entrance (i.e. in each entrance_data file) 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 in area 1623 we conventionally store the *fix in a "known" place. This does not work for area 1626.

Edit these Entrance files:
+[ TO DO ]

{% 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
+

    +{% for w in cave.wallets.all %} +
  • {{w.walletname}} : survex files {{w.survexfiles}} +{%endfor %} +
+ + +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

  • Add the line
    @@ -138,9 +175,10 @@ OR we can do an online rename of the "Cave" object in the database [code yet to

    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

    - +