From eea74406c9ba0e7554a75e98ae7bb6792a164e11 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 17 Apr 2021 23:59:11 +0100 Subject: [PATCH] fix template bug for newentrance --- core/TESTS/tests_caves.py | 25 ++++++++++++++++++++++++- core/fixtures/expo_caves.json | 19 ++++++++++++++++++- core/views/caves.py | 19 ++++++++++++++----- settings.py | 1 + templates/caveindex.html | 2 +- templates/errors/generic.html | 28 +--------------------------- templates/pagenotfound.html | 2 +- urls.py | 22 ++++++++++++---------- 8 files changed, 72 insertions(+), 46 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ö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 Stellerweghöhle system was explored. See the separate full guidebook description for details, just an overview is given here.

The entrance leads to a non-obvious way on to the head of the short Bell Pitch, from where very awkward going leads out to a bigger passage to reach The Ramp a series of off-vertical pitches. The damper but technically easier Inlet Pitches drop to a Big Chamber, from where Pete's Purgatory starts, and leads in 800m of tortuous going to The Confluence and the larger streamway leading to the deepest point.

Better is the Purgatory Bypass which starts as dry fossil tubes, with a choice of routes to reach Junction Chamber where the Big Rift of Stellerweghöhle enters. Opposite, the huge fossil tube of Dartford Tunnel 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 Orgasm Chasm. 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 here", "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:

", "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 Stellerweghöhle system was explored. See the separate full guidebook description for details, just an overview is given here.

The entrance leads to a non-obvious way on to the head of the short Bell Pitch, from where very awkward going leads out to a bigger passage to reach The Ramp a series of off-vertical pitches. The damper but technically easier Inlet Pitches drop to a Big Chamber, from where Pete's Purgatory starts, and leads in 800m of tortuous going to The Confluence and the larger streamway leading to the deepest point.

Better is the Purgatory Bypass which starts as dry fossil tubes, with a choice of routes to reach Junction Chamber where the Big Rift of Stellerweghöhle enters. Opposite, the huge fossil tube of Dartford Tunnel 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 Orgasm Chasm. 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 here", + "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:

", "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 diff --git a/settings.py b/settings.py index 46bbbcd..cc7cdc4 100644 --- a/settings.py +++ b/settings.py @@ -71,6 +71,7 @@ MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200 DEFAULT_LOGBOOK_PARSER = "Parseloghtmltxt" DEFAULT_LOGBOOK_FILE = "logbook.html" # All years since 2010 use the default value for Logbook parser +# but several don't work, and are skipped by the parsing code, e.g. 1983 LOGBOOK_PARSER_SETTINGS = { "2010": ("2010/logbook.html", "Parseloghtmltxt"), "2009": ("2009/2009logbook.txt", "Parselogwikitxt"), diff --git a/templates/caveindex.html b/templates/caveindex.html index d4443d4..af0f56c 100644 --- a/templates/caveindex.html +++ b/templates/caveindex.html @@ -28,7 +28,7 @@

New Cave
- New Entrance
+ New Entrance
Cave Number Index - kept updated

1623

diff --git a/templates/errors/generic.html b/templates/errors/generic.html index a132ec0..66655a1 100644 --- a/templates/errors/generic.html +++ b/templates/errors/generic.html @@ -1,38 +1,12 @@ {% extends 'base.html' %} -{% block extrahead %} - -{% endblock %} {% block title %}Website Error - {% endblock %} {% block content %}

Website Error

- - {% endblock%} +
diff --git a/templates/pagenotfound.html b/templates/pagenotfound.html index d59ffaa..fe87445 100644 --- a/templates/pagenotfound.html +++ b/templates/pagenotfound.html @@ -34,7 +34,7 @@ div#editLinks a{
{% endblock%} -

Probably a mistake. But you can use this link +

Probably a mistake. But you can try this link or this one to fix a real error.

or 'Edit this page' in the menu on the left to create this page if you are logged in.