mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
fixing cave slug <caveslug> issues
This commit is contained in:
parent
09dbe5b14b
commit
6d16f8f7ca
@ -114,6 +114,9 @@ class Cave(TroggleModel):
|
||||
slugs = self.caveslug_set.filter()
|
||||
if slugs:
|
||||
return slugs[0].slug
|
||||
|
||||
def newslug(self):
|
||||
return f"{self.areacode}-{self.number()}"
|
||||
|
||||
def ours(self):
|
||||
return bool(re.search(r"CUCC", self.explorers))
|
||||
@ -522,7 +525,7 @@ def GetCaveLookup():
|
||||
checkcaveid(cave, slug)
|
||||
|
||||
# These might alse create more duplicate entries
|
||||
# Yes, this should be set in, and imported from, settings.py
|
||||
# Yes, this should be set in, and imported from, an easily editable file
|
||||
# On reset, these aliases only work if the cave already properly exists with an entry in :expoweb:/cave_data/
|
||||
# but as the aliases are recomputed repeatedly, eventually they work on PENDING caves too
|
||||
aliases = [
|
||||
@ -646,6 +649,8 @@ def GetCaveLookup():
|
||||
("2002-x12", "2005-07"),
|
||||
("2002-x13", "1623-2005-06"),
|
||||
("2002-x14", "2005-05"),
|
||||
|
||||
# various funnies to cope with cave names used in logbooks
|
||||
("kh", "1623-161"),
|
||||
("161-kh", "1623-161"),
|
||||
("204-steinBH", "1623-204"),
|
||||
@ -659,10 +664,12 @@ def GetCaveLookup():
|
||||
("fgh", "1623-290"),
|
||||
("fishface", "1623-290"),
|
||||
("gsh", "1623-291"),
|
||||
("1623-2023-lc-01", "1623-318"),
|
||||
("tempest", "1623-2023-lc-01"),
|
||||
|
||||
("1623-2023-kt-02", "2023-kt-02"),
|
||||
|
||||
|
||||
# from the git output after Becka's changes, used to construct this list..
|
||||
# rename caves-1623/{2023-ASH-15/2023-ASH-15.svx => 303/303.svx} (94%)
|
||||
# rename caves-1623/{2023-mg-02/2023-mg-02.svx => 304/304.svx} (90%)
|
||||
# rename caves-1623/{2023-mg-01/2023-mg-01.svx => 305/305.svx} (94%)
|
||||
@ -694,7 +701,7 @@ def GetCaveLookup():
|
||||
("2023-jss-01", "1623-315"),
|
||||
("2023-kt-01", "1623-316"),
|
||||
|
||||
# 1626 aliases2023-mg-01/2023-mg-01.svx => 305
|
||||
# 1626
|
||||
("langgustl", "1626-354"),
|
||||
("2018-dm-07", "1626-359"),
|
||||
("1626-2018-dm-07", "1626-359"),
|
||||
|
@ -93,7 +93,7 @@ def pad5(x):
|
||||
|
||||
|
||||
def padnumber(x):
|
||||
return re.sub("\d+", pad5, x)
|
||||
return re.sub("\d+", pad5, x) # SyntaxWarning: invalid escape sequence '\d'
|
||||
|
||||
|
||||
def numericalcmp(x, y):
|
||||
@ -102,7 +102,7 @@ def numericalcmp(x, y):
|
||||
|
||||
def caveKey(c):
|
||||
"""This function goes into a lexicographic sort function, and the values are strings,
|
||||
but we want to sort numberically on kataster number before sorting on unofficial number.
|
||||
but we want to sort numerically on kataster number before sorting on unofficial number.
|
||||
"""
|
||||
if not c.kataster_number:
|
||||
return "9999." + c.unofficial_number
|
||||
@ -284,7 +284,7 @@ def rendercave(request, cave, slug, cave_id=""):
|
||||
print(f" ! rendercave: slug:'{slug}' FAIL TO MANAGE survex file:'{cave.survex_file}'")
|
||||
# NOTE the template itself loads the 3d file using javascript before it loads anything else.
|
||||
# Django cannot see what this javascript is doing, so we need to ensure that the 3d file exists first.
|
||||
# So only do this render if a valid .3d file exists. TO BE DONE -Not yet as CaveView is currently disabled
|
||||
# So only do this render if a valid .3d file exists. TO BE DONE
|
||||
# see design docum in troggle/templates/cave.html
|
||||
# see rendercave() in troggle/core/views/caves.py
|
||||
templatefile = "cave.html"
|
||||
@ -507,10 +507,11 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
"""
|
||||
slugname = f"{slug}{letter}"
|
||||
nents = Entrance.objects.filter(slug=slugname).count()
|
||||
print(f"NUM ents {slugname=} => {nents}")
|
||||
print(f"check_new_slugname_ok() {slugname=} {letter=} => {nents}")
|
||||
if nents == 0:
|
||||
# looks good, but we need to check the CaveaAndEntrance object too
|
||||
e = entrance #Entrance.objects.get(slug=slugname) # does not exist yet!
|
||||
e.save()
|
||||
gcl = GetCaveLookup()
|
||||
c = gcl[slug]
|
||||
nce = CaveAndEntrance.objects.filter(cave=c, entrance=e).count()
|
||||
@ -593,12 +594,16 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
entrance = entform.save(commit=False)
|
||||
# entrance = ce.entrance # the one we created earlier?
|
||||
|
||||
if entranceletter:
|
||||
slugname, letter = check_new_slugname_ok(cave.slug(), entranceletter)
|
||||
else:
|
||||
slugname, letter = check_new_slugname_ok(cave.slug(), "")
|
||||
ce.entranceletter = letter
|
||||
|
||||
try:
|
||||
if entranceletter:
|
||||
slugname, letter = check_new_slugname_ok(cave.slug(), entranceletter)
|
||||
else:
|
||||
slugname, letter = check_new_slugname_ok(cave.slug(), "")
|
||||
ce.entranceletter = letter
|
||||
|
||||
except Exception as e:
|
||||
print(f"- EXCEPTION entranceletter {caveslug=} {entslug=} {entranceletter=} {path=}\n{e}")
|
||||
raise
|
||||
entrance.slug = slugname
|
||||
entrance.cached_primary_slug = slugname
|
||||
entrance.filename = slugname + ".html"
|
||||
|
@ -749,11 +749,14 @@ def read_cave(filename, mvf=None, cave=None):
|
||||
# New 2024 June 28th.
|
||||
slugs = getXML(cavecontents, "caveslug", maxItems=1, context=context)
|
||||
if len(slugs) > 1:
|
||||
message = f" ! - More than one slug for a cave: {cave}, slugs: {slugs}. Ignoring all except first."
|
||||
message = f" ! - More than one slug for a cave: {cave}, slugs: {slugs}."
|
||||
DataIssue.objects.create(parser="caves", message=message, url=context)
|
||||
print(message)
|
||||
# slug = slugs[0]
|
||||
|
||||
# but ignore <caveslug> read from the file
|
||||
slug = filename[:-5] # strip off the ".html" at the end of the filename
|
||||
slugs = [slug]
|
||||
#print(f"{filename=} {slug=}")
|
||||
|
||||
|
||||
@ -926,7 +929,7 @@ def readcaves():
|
||||
|
||||
with transaction.atomic():
|
||||
print(" - Reading Caves from cave descriptions xml files")
|
||||
mvscript = "mvscript.sh"
|
||||
mvscript = "mvscript.sh" # in .gitignore so no problem creating it on server in /troggle/
|
||||
with open(mvscript, "w") as mvf: # overwrite
|
||||
mvf.write(f"cd {CAVEDESCRIPTIONS}\n")
|
||||
for filename in next(os.walk(CAVEDESCRIPTIONS))[2]: # Should be a better way of getting a list of files
|
||||
|
@ -24,7 +24,7 @@
|
||||
<li><a href="/pathsreport">Folder paths used</a> -folders settings used by this troggle installation
|
||||
<li><a href="/aliases/2023">Expoer name aliases</a> -short names recognised by troggle
|
||||
<li><a href="/dataissues">Data Issues on Imports</a> - warnings and errors from the recent data import
|
||||
<li><a href="/survexfilewild/2023">Wild survex files</a> - survex files contianing blocks with no related wallet
|
||||
<li><a href="/survexfilewild/2023">Wild survex files</a> - survex files containing blocks with no related wallet
|
||||
<li><a href="/survexdir">Survex Directories</a> - Every Cave has an associated directory and a Primary survex file
|
||||
<li><a href="/surveximport">Survex import record</a> - indented *include and begin/end tree<br /><li><a href="/survexdebug">Survex debug report</a> - warnings and details<br />
|
||||
<li><a href="/therionissues">Therion Import issues</a> - warnings from the recent data import<br /><br />
|
||||
|
@ -17,7 +17,7 @@ the form documented at
|
||||
|
||||
<cave>
|
||||
<non_public>{{ cave.non_public }}</non_public>{% for slug in cave.caveslug_set.all %}<!-- 'False' or 'True'. True if the cave should only be visible to logged-in users. Caves are normally public, so enter 'False' unless you know otherwise. -->
|
||||
<caveslug>{{ slug.slug|default_if_none:"1623-000"|safe }}</caveslug>{% endfor %}<!--(Required). Internal I.D. used to refer to this cave in entrance data files. Typically the same as the filebase, e.g. '1623-195' -->
|
||||
<caveslug>{{ slug.slug|default_if_none:"1623-000"|safe }}</caveslug>{% endfor %}<!--No longer required, we use the filename instead e.g. 1623-315 for 1623-315.html -->
|
||||
<official_name>{{ cave.official_name|default_if_none:""|safe }}</official_name><!-- Name of the cave (normally in German) Use ü for u+Umlaut and ö for o+umlaut eg Höhle for Hohle and Glück for Gluck-->
|
||||
<area>{{cave.areacode |safe }}</area><!-- e.g. "1623" -->
|
||||
<kataster_code>{{ cave.kataster_code|default_if_none:"-"|safe }}</kataster_code><!-- 'length-or-depth/type exploration'
|
||||
@ -40,7 +40,7 @@ code used in the Austrian kataster e.g '1/S +' - https://expo/.survex.com/katast
|
||||
{% for ce in cave.entrances.all %}
|
||||
<entrance>
|
||||
<entranceslug>{{ ce.entrance.slug|default_if_none:""|safe }}</entranceslug><!-- Internal ID to refer to each entrance instance in the entrance files (typically the same as that filename (e.g. 1623-161c). Matches the 'slug' field in the entrance file -->
|
||||
<letter>{{ ce.entranceletter|default_if_none:""|safe }}</letter><!--Leave blank for single-entrance cave. If there is more than one entrace then the letter needs to be given. Generally matches the entranceslug ID. -->
|
||||
<letter>{{ ce.entranceletter|default_if_none:""|safe }}</letter><!--Leave blank for single-entrance cave. If there is more than one entrance then the letter needs to be given. Must match the entranceslug ID. -->
|
||||
</entrance>
|
||||
{% endfor %}
|
||||
<explorers>{{ cave.explorers|default_if_none:""|safe }}</explorers><!-- 'CUCC Expo' and year(s) of exploration. To distinguish from caves explored by foreign groups. Individual names can be given too if it was a small cave. -->
|
||||
|
@ -51,7 +51,8 @@
|
||||
<input type=submit value="Search"></form></li>
|
||||
{% if editable %}<li><a href="{% if local %}https://expo.survex.com{% endif %}{% url "editexpopage" path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %}
|
||||
{% if cave_editable %}<li><a href="{% if local %}https://expo.survex.com{% endif %}{% url "edit_cave" cave.url_parent cave.slug %}" class="editlink"><strong>Edit this cave</strong></a></li>{% endif %}
|
||||
<li> {% if settings.DEVSERVER %}<b style="color:red">RUNNING ON LOCALSERVER</b>{% endif %}
|
||||
<li> {% if settings.DEVSERVER %}<b style="color:red">RUNNING ON LOCALSERVER</b> <br>slug:{{ cave.slug }}<br>newslug:{{ cave.newslug }}<br>url:{{ cave.url }}{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user