forked from expo/troggle
fix template bug for newentrance
This commit is contained in:
@@ -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 +"'")
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
[{"model": "core.cave", "pk": 43, "fields":
|
||||
{"new_since_parsing": false, "non_public": false, "official_name": "Schnellzughö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ö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ö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 Stellerweghöhle entrance 41a</li> <li>115b Stellerweghöhle entrance 41b</li> <li>115c Stellerweghöhle entrance 41c ( where ? )</li> <li>115d Schnellzughöhle entrance 115</li> <li>115e unnamed entrance 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ö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ö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ö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 Stellerweghöhle entrance 41a</li> <li>115b Stellerweghöhle entrance 41b</li> <li>115c Stellerweghöhle entrance 41c ( where ? )</li> <li>115d Schnellzughöhle entrance 115</li> <li>115e unnamed entrance 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]}}
|
||||
]
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user