summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-04-17 23:59:11 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2021-04-17 23:59:11 +0100
commiteea74406c9ba0e7554a75e98ae7bb6792a164e11 (patch)
treedc0e2d091fef34aef3d66f6117c5b2694bf865c9 /core
parentd4317b5fd33961847fda17f3a94afb2f7414b657 (diff)
downloadtroggle-eea74406c9ba0e7554a75e98ae7bb6792a164e11.tar.gz
troggle-eea74406c9ba0e7554a75e98ae7bb6792a164e11.tar.bz2
troggle-eea74406c9ba0e7554a75e98ae7bb6792a164e11.zip
fix template bug for newentrance
Diffstat (limited to 'core')
-rw-r--r--core/TESTS/tests_caves.py25
-rw-r--r--core/fixtures/expo_caves.json19
-rw-r--r--core/views/caves.py19
3 files changed, 56 insertions, 7 deletions
diff --git a/core/TESTS/tests_caves.py b/core/TESTS/tests_caves.py
index 84a0d97..2e05ce9 100644
--- a/core/TESTS/tests_caves.py
+++ b/core/TESTS/tests_caves.py
@@ -5,11 +5,13 @@ Modified for Expo April 2021.
import unittest
import re
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
+from troggle.core.models.caves import Cave
class FixturePageTests(TestCase):
# The fixtures have a password hash which is compatible with plain-text password 'secretword'
fixtures = ['auth_users', 'expo_areas', 'expo_caves']
+ ph = r'and leads in 800m of tortuous going to'
def setUp(self):
from django.contrib.auth.models import User
@@ -18,4 +20,25 @@ class FixturePageTests(TestCase):
def tearDown(self):
pass
-
+ def test_fix_cave_loaded(self):
+ c = Cave.objects.get(kataster_number='115')
+ self.assertEqual(str(c.description_file), "1623/115.htm")
+ self.assertEqual(str(c.url), "1623/115.htm")
+ self.assertEqual(str(c.filename), "1623-115.html")
+
+ ph = self.ph
+ phmatch = re.search(ph, c.underground_description)
+ self.assertIsNotNone(phmatch, "In fixture-loaded cave, failed to find expected text: '" + ph +"'")
+
+ def test_fix_cave_url(self):
+ ph = self.ph
+ response = self.client.get('1623/115.htm')
+ #self.assertEqual(response.status_code, 200)
+
+ content = response.content.decode()
+ phmatch = re.search(ph, content)
+ with open('cave-op.html', 'w') as f:
+ f.write(content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+
+ \ No newline at end of file
diff --git a/core/fixtures/expo_caves.json b/core/fixtures/expo_caves.json
index 9690c60..9dfa78e 100644
--- a/core/fixtures/expo_caves.json
+++ b/core/fixtures/expo_caves.json
@@ -1,3 +1,20 @@
[{"model": "core.cave", "pk": 43, "fields":
- {"new_since_parsing": false, "non_public": false, "official_name": "Schnellzugh&ouml;hle", "kataster_code": "6/t/S/W x", "kataster_number": "115", "unofficial_number": "40m", "explorers": "CUCC 1980-1985", "underground_description": "This is the main entrance through which the majority of the <a href=\"41.htm\">Stellerwegh&ouml;hle</a> system was explored. See the separate <a href=\"41/115.htm#ent115\">full guidebook description</a> for details, just an overview is given here.</p><p>The entrance leads to a non-obvious way on to the head of the short <b>Bell Pitch</b>, from where very awkward going leads out to a bigger passage to reach <b>The Ramp</b> a series of off-vertical pitches. The damper but technically easier <b>Inlet Pitches</b> drop to a Big Chamber, from where <b>Pete's Purgatory</b> starts, and leads in 800m of tortuous going to <b>The Confluence</b> and the larger streamway leading to the deepest point.</p><p>Better is the <b>Purgatory Bypass</b> which starts as dry fossil tubes, with a choice of routes to reach <b>Junction Chamber</b> where the <b>Big Rift</b> of <a href=\"41.htm\">Stellerwegh&ouml;hle</a> enters. Opposite, the huge fossil tube of <b>Dartford Tunnel</b> makes for easy progress to the Confluence, about halfway down the system. The continuing main streamway is interrupted by a bypassable sump and numerous pitches before a low airspace duck at the end of an unpromising canal leads to the spectacular <b>Orgasm Chasm</b>. Careful rigging avoids the water in this 140m shaft, ending in muddy passage and another short drop to a deep and terminal sump. ", "equipment": "", "references": "", "survey": "CUCC's parts surveyed to Grade 5 but not all drawn up - see <a href=\"41/survey.htm\">here</a>", "kataster_status": "", "underground_centre_line": "In dataset", "notes": "The Austrian Kataster has adopted a very perverse way of numbering things. Their numbers are as follows:</p><ul> <li>115a&nbsp;&nbsp;&nbsp;Stellerwegh&ouml;hle entrance&nbsp;&nbsp;&nbsp;41a</li> <li>115b&nbsp;&nbsp;&nbsp;Stellerwegh&ouml;hle entrance&nbsp;&nbsp;&nbsp;41b</li> <li>115c&nbsp;&nbsp;&nbsp;Stellerwegh&ouml;hle entrance&nbsp;&nbsp;&nbsp;41c ( where ? )</li> <li>115d&nbsp;&nbsp;&nbsp;Schnellzugh&ouml;hle entrance&nbsp;&nbsp;&nbsp;115</li> <li>115e&nbsp;&nbsp;&nbsp;unnamed entrance&nbsp;&nbsp;&nbsp;142</li></ul><p>", "length": "SMK system total 54000m", "depth": "from entrance; SMK system total 1032m", "extent": "SMK system total 2812m", "survex_file": "smk-system.svx", "description_file": "1623/115.htm", "url": "1623/115.htm", "filename": "1623-115.html", "area": [1, 8]}}
+ {"new_since_parsing": false, "non_public": false,
+ "official_name": "Schnellzugh&ouml;hle",
+ "kataster_code": "6/t/S/W x",
+ "kataster_number": "115",
+ "unofficial_number": "40m",
+ "explorers": "CUCC 1980-1985",
+ "underground_description": "This is the main entrance through which the majority of the <a href=\"41.htm\">Stellerwegh&ouml;hle</a> system was explored. See the separate <a href=\"41/115.htm#ent115\">full guidebook description</a> for details, just an overview is given here.</p><p>The entrance leads to a non-obvious way on to the head of the short <b>Bell Pitch</b>, from where very awkward going leads out to a bigger passage to reach <b>The Ramp</b> a series of off-vertical pitches. The damper but technically easier <b>Inlet Pitches</b> drop to a Big Chamber, from where <b>Pete's Purgatory</b> starts, and leads in 800m of tortuous going to <b>The Confluence</b> and the larger streamway leading to the deepest point.</p><p>Better is the <b>Purgatory Bypass</b> which starts as dry fossil tubes, with a choice of routes to reach <b>Junction Chamber</b> where the <b>Big Rift</b> of <a href=\"41.htm\">Stellerwegh&ouml;hle</a> enters. Opposite, the huge fossil tube of <b>Dartford Tunnel</b> makes for easy progress to the Confluence, about halfway down the system. The continuing main streamway is interrupted by a bypassable sump and numerous pitches before a low airspace duck at the end of an unpromising canal leads to the spectacular <b>Orgasm Chasm</b>. Careful rigging avoids the water in this 140m shaft, ending in muddy passage and another short drop to a deep and terminal sump. ",
+ "equipment": "",
+ "references": "",
+ "survey": "CUCC's parts surveyed to Grade 5 but not all drawn up - see <a href=\"41/survey.htm\">here</a>",
+ "kataster_status": "",
+ "underground_centre_line": "In dataset",
+ "notes": "The Austrian Kataster has adopted a very perverse way of numbering things. Their numbers are as follows:</p><ul> <li>115a&nbsp;&nbsp;&nbsp;Stellerwegh&ouml;hle entrance&nbsp;&nbsp;&nbsp;41a</li> <li>115b&nbsp;&nbsp;&nbsp;Stellerwegh&ouml;hle entrance&nbsp;&nbsp;&nbsp;41b</li> <li>115c&nbsp;&nbsp;&nbsp;Stellerwegh&ouml;hle entrance&nbsp;&nbsp;&nbsp;41c ( where ? )</li> <li>115d&nbsp;&nbsp;&nbsp;Schnellzugh&ouml;hle entrance&nbsp;&nbsp;&nbsp;115</li> <li>115e&nbsp;&nbsp;&nbsp;unnamed entrance&nbsp;&nbsp;&nbsp;142</li></ul><p>", "length": "SMK system total 54000m", "depth": "from entrance; SMK system total 1032m", "extent": "SMK system total 2812m",
+ "survex_file": "smk-system.svx",
+ "description_file": "1623/115.htm",
+ "url": "1623/115.htm",
+ "filename": "1623-115.html",
+ "area": [1, 8]}}
] \ No newline at end of file
diff --git a/core/views/caves.py b/core/views/caves.py
index 2b97aac..fed3614 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -226,9 +226,16 @@ def rendercave(request, cave, slug, cave_id=''):
editable = True
else:
editable = False
- print(" ! rendercave:'{}' svxstem:{} svx3d:'{}'".format(cave, svxstem, svx3d))
- return render(request,'cave.html', {'cave_editable': editable, 'settings': settings, 'cave': cave, 'cavepage': True,
- 'cave_id': cave_id, 'svxstem': svxstem, 'svx3d':svx3d})
+ #print(f" ! rendercave:'{cave}' svxstem:{svxstem} caveid:'{cave_id}' svx3d:'{svx3d}'")
+ try:
+ r = render(request,'cave.html', {'cave_editable': editable, 'settings': settings, 'cave': cave, 'cavepage': True,
+ 'cave_id': cave_id, 'svxstem': svxstem, 'svx3d':svx3d})
+ return r
+ except:
+ raise
+ return render(request,'errors/generic.html', {'cave_editable': editable, 'settings': settings, 'cave': cave, 'cavepage': True,
+ 'cave_id': cave_id, 'svxstem': svxstem, 'svx3d':svx3d})
+
def cavepage(request, karea, subpath):
'''Displays a cave description page
@@ -249,10 +256,12 @@ def cavepage(request, karea, subpath):
return expo.expopage(request, path)
except Cave.MultipleObjectsReturned:
caves = Cave.objects.filter(url = path)
+ # we should have a -several variant for the cave pages, not just the svxcaves:
return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves })
except:
- return render(request, 'pagenotfound.html', {'path': path})
-
+ raise
+ return render(request, 'pagenotfound.html', {'path': path}) # it does not seem possible to set the status_code to '404'
+
def cave(request, cave_id='', offical_name=''):
'''Displays a cave description page
accesssed by a fairly random id which might be anything