summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/TESTS/tests_caves.py25
-rw-r--r--core/fixtures/expo_caves.json19
-rw-r--r--core/views/caves.py19
-rw-r--r--settings.py1
-rw-r--r--templates/caveindex.html2
-rw-r--r--templates/errors/generic.html30
-rw-r--r--templates/pagenotfound.html2
-rw-r--r--urls.py22
8 files changed, 73 insertions, 47 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
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 @@
<p style="text-align:right">
<a href="{% url "newcave" %}">New Cave</a><br>
- <a href="{% url "newentrance" %}">New Entrance</a><br>
+ <a href="{% url "newentrance" "1623-000" %}">New Entrance</a><br>
<a href="/noinfo/cave-number-index">Cave Number Index - kept updated</a>
</p>
<h3>1623</h3>
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 %}
-<style>
-div#editLinks {
- Zposition:absolute;
- background: #999;
- bottom:0px;
- right:0px;
- font-family: "Courier New", Courier, monospace;
- filter:alpha(opacity=75);
- -moz-opacity:.75;
- opacity:.75;
- text-align:right;
-}
-
-div#editLinks a{
- color:#FFF;
-}
-</style>
-{% endblock %}
+
{% block title %}Website Error - {% endblock %}
{% block content %}
<div class='middle'>
<h2>Website Error</h2>
</div>
- <div id="editLinks"> {% block loginInfo %}
- <a href="/">Home</a> |
- <a id="cuccLink" href="http://camcaving.uk/">CUCC</a> |
- <a id="expoWebsiteLink" href="http://expo.survex.com">expo.survex</a> |
- {% if user.username %}User:{{ user.username }}
- {% if user.person %}(<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>){% endif %}
- | <a <a href='/accounts/logout/'>Log out</a> {% else %} <a href='/accounts/login/'>Log in</a> {% endif %}
- </div>
- {% endblock%}
+
<div style='width: 300px;' class='middle3 login'>
<div class='align-center'>
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{
</div>
{% endblock%}
-<p>Probably a mistake. But you can use <a href="{%url "editexpopage" path %}">this link</a>
+<p>Probably a mistake. But you can try <a href="{%url "editexpopage" path %}">this link</a> or <a href="{{ path }}/edit">this one</a> to fix a real error.
<p>
or 'Edit this page' in the menu on the left to create this page if you are logged in.
<ul>
diff --git a/urls.py b/urls.py
index 74e6737..2895afe 100644
--- a/urls.py
+++ b/urls.py
@@ -100,13 +100,6 @@ trogglepatterns = [
url(r'^getQMs/(?P<caveslug>.*)', caves.get_qms, name = "get_qms"),
url(r'^getEntrances/(?P<caveslug>.*)', caves.get_entrances, name = "get_entrances"),
-# QMs pages - must precede other /caves pages
- url(r'^cave/qms/([^/]+)/?$', caves.caveQMs), # blank page usually
- url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', caves.qm, name="qm"),
- url(r'^cave/(?P<cave_id>[^/]+)/qm\.csv/?$', other.downloadQMs, name="downloadqms"),
- url(r'^newqmnumber/?$', other.ajax_QM_number, ), # blank page if no ch given
-# url(r'^downloadqms$', other.downloadQMs), # MultiValueDictKeyError
-
# Cave description pages
url(r'^cave/new/$', caves.edit_cave, name="newcave"),
url(r'^cave/3d/(?P<cave_id>[^/]+)$', caves.cave3d, name="cave3d"),
@@ -117,12 +110,13 @@ trogglepatterns = [
url(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance),
url(r'^cave/description/([^/]+)/?$', caves.caveDescription),
url(r'^cave/logbook/([^/]+)/?$', caves.caveLogbook),
- url(r'^(?P<karea>162\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand /1623/264 BUT url links may break
+ url(r'^(?P<karea>\d\d\d\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand /1623/264 BUT url links may break
+ # Note that urls eg '1623/161/l/rl89a.htm' are handled by cavepage which redirects them to 'expopage'
# Entrances
- url(r'^entrance/new/$', caves.edit_entrance, name = "newentrance"),
url(r'^entrance/(?P<caveslug>[^/]+)/(?P<slug>[^/]+)/edit/', caves.edit_entrance, name = "editentrance"),
-
+ url(r'^entrance/new/(?P<caveslug>[^/]+)$', caves.edit_entrance, name = "newentrance"),
+
url(r'^statistics/?$', statistics.stats, name="stats"),
url(r'^stats/?$', statistics.stats, name="stats"),
@@ -154,6 +148,14 @@ trogglepatterns = [
# url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', surveys.tunnelfileinfo, name="tunnelfileinfo"), # parses tunnel for info
url(r'^tunneldataraw/(?P<path>.+?\.xml)/upload$', surveys.tunnelfileupload, name="tunnelfileupload"),
+
+# QMs pages - must precede other /caves pages
+ url(r'^cave/qms/([^/]+)/?$', caves.caveQMs), # blank page usually
+ url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', caves.qm, name="qm"),
+ url(r'^cave/(?P<cave_id>[^/]+)/qm\.csv/?$', other.downloadQMs, name="downloadqms"),
+ url(r'^newqmnumber/?$', other.ajax_QM_number, ), # blank page if no ch given
+# url(r'^downloadqms$', other.downloadQMs), # MultiValueDictKeyError
+
# Prospecting Guide document
url(r'^prospecting_guide/$', prospecting),
url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),