summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/models/caves.py13
-rw-r--r--core/views/caves.py25
2 files changed, 25 insertions, 13 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index 81c1789..bf495bc 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -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"),
diff --git a/core/views/caves.py b/core/views/caves.py
index 8d44b5c..5a28101 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -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"