2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Better error msgs for bad slugs

This commit is contained in:
Philip Sargent 2021-12-05 21:23:06 +00:00
parent bb97b7c862
commit b3aa99f008
6 changed files with 149 additions and 44 deletions

View File

@ -276,14 +276,18 @@ def cave(request, cave_id='', offical_name=''):
caves = Cave.objects.filter(kataster_number=cave_id)
return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves }) # not the right template, needs a specific one
except ObjectDoesNotExist:
return render(request, 'svxcavesingle404.html', {'settings': settings, "cave":cave_id })
return render(request, 'errors/svxcavesingle404.html', {'settings': settings, "cave":cave_id })
except:
return render(request, 'svxcavesingle404.html', {'settings': settings })
return render(request, 'errors/svxcavesingle404.html', {'settings': settings })
return rendercave(request, cave, cave.slug(), cave_id=cave_id)
def caveEntrance(request, slug):
cave = Cave.objects.get(caveslug__slug = slug)
try:
cave = Cave.objects.get(caveslug__slug = slug)
except:
return render(request,'errors/badslug.html', {'badslug': slug})
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
return render(request,'nonpublic.html', {'instance': cave})
else:

View File

@ -0,0 +1,63 @@
{% extends 'base.html' %}
{% block title %}Troggle Error - Bad Slug{% endblock %}
{% block content %}
<div class='middle'>
<h2>Bad Slug Error</h2>
</div>
<div class='middle3 login'>
<div class='space'></div>
<div class='align-center'>
<h3>There has been a Troggle error. </h3>
<h4>
A Cave or an Entrance has been referred to using a label (a 'slug') which does not work.
<p>This is the bad slug:
<font color="red">
{% if badslug %}
{{badslug}}
{% else %}
<p>We are terribly sorry but a fault has occurred. Something in the system is referring to something else which does not exist. </p>
{% endif %}
</font>
<p>
This is the previous page which had the bad slug reference on it: <font color="red">
<script type="text/javascript">
document.write(document.referrer);
</script>
</font>
</h4>
<p>
<p>It is also possible that the cave description page is being viewed using an alternative URL,
so that the local links in the page to other parts of the cave do not work.
<br>
e.g. /cave/1623-161 is not the correct way of looking at Kaninchenhohle,
<br>
you should be using <br>
/1623/161/top.htm instead.
<p>If that is the case, tell a nerd that we haven't fixed the fault that we thought we had fixed.
<div class='space'><p>&nbsp;</div>
<h3>What you should do now</h3>
<p>Please report the error by emailing the nerds at
<a href="mailto:expo-tech@lists.wookware.org">expo-tech@lists.wookware.org</a> with this information:
<ol>
<li>The bad slug text written in <font color="red">red</font> above.
<li>The previous page URL, also written in <font color="red">red</font> above
<li>Go back to this previous page <script type="text/javascript">
document.write("<a href='",document.referrer,"'>",document.referrer,"</a>");
</script>
and see if you can tell whether the bad slug was in HTML text which had been written manually, or whether it appeared to be a programming error.
</ol>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,35 +1,48 @@
{% extends 'base.html' %}
{% block title %}Website Error - {% endblock %}
{% block title %}Troggle Error - Generic{% endblock %}
{% block content %}
<div class='middle'>
<h2>Website Error</h2>
<h2>Troggle Error</h2>
</div>
<div style='width: 300px;' class='middle3 login'>
<div class='align-center'>
<div class='middle3 login'>
<div class='space'></div>
<div class='align-center'>
<h3>There has been an error.</h3>
<h3>There has been an error. This is either bad data or a bug in the software.</h3>
<h4>
<font color="red">
{% if message %}
{{message}}
{% else %}
<p>We are terribly sorry but an unknown fault has occurred. </p>
{% endif %})
{% endif %}
</font>
</h4>
<div class='space'><p>&nbsp;</div>
<h3>What you should do now</h3>
<p>Please report the error by emailing the nerds at
<a href="mailto:expo-tech@lists.wookware.org">expo-tech@lists.wookware.org</a> with this information:
<ol>
<li>The error message written in <font color="red">red</font> above.
<li>The previous page URL: <font color="red">
<script type="text/javascript">
document.write(document.referrer);
</script></font>
<li>Go back to this previous page <script type="text/javascript">
document.write("<a href='",document.referrer,"'>",document.referrer,"</a>");
</script>
and see if you can tell whether the bad page reference was in HTML text which had been written manually, or whether it appeared to be a programming error.
</ol>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,52 @@
<!-- svxcavesingle404.html - this text visible because this template has been included -->
{% extends "base.html" %}
{% block title %}Troggle Error - Bad Cave ID{% endblock %}
{% block content %}
<h1>Cave Identifier not found in database</h1>
<h3>Cave identifier looked for: <font color="red">'{{cave}}'</font></h3>
<ul>
<li>- unofficial number like this not found</li>
<li>- kataster number like this not found</li>
</ul>
<h3>You probably got here because a survex (.svx) file has been stored on the server in the
<a href="/handbook/computing/repos.html"><var>:loser:</var></a> repository
but whoever was
responsible has not yet created the appropriate XML file the
<a href="/handbook/computing/repos.html"><var>:expoweb:</var></a> repository
which registers the cave description and ties together
the survex files with everything else.
</h3>
<p>The process for registering a new cave is documented in
<a href="/handbook/survey/caveentry.html">this part of the survey handbook</a>.
<p>
<p>It is also possible that the cave description page is being viewed using an alternative URL,
so that the local links in the page to other parts of the cave do not work.
<br>
e.g. /cave/1623-161 is not the correct way of looking at Kaninchenhohle,
<br>
you should be using <br>
/1623/161/top.htm instead.
<p>If that is the case, tell a nerd that we haven't fixed the fault that we thought we had fixed.
<div class='space'><p>&nbsp;</div>
<h3>What you should do now</h3>
<p>Please report the error by emailing the nerds at
<a href="mailto:expo-tech@lists.wookware.org">expo-tech@lists.wookware.org</a> with this information:
<ol>
<li>The error message written in <font color="red">red</font> above.
<li>The previous page URL: <font color="red">
<script type="text/javascript">
document.write(document.referrer);
</script></font>
<li>Go back to this previous page <script type="text/javascript">
document.write("<a href='",document.referrer,"'>",document.referrer,"</a>");
</script>
and see if you can tell whether the bad page reference was in HTML text which had been written manually, or whether it appeared to be a programming error.
</ol>
{% endblock %}

View File

@ -1,27 +0,0 @@
<!-- svxcavesingle404.html - this text visible because this template has been included -->
{% extends "base.html" %}
{% block title %}List of survex files{% endblock %}
{% block content %}
<h1>Cave not found in database</h1>
<h3>Cave number looked for: '{{cave}}'</h3>
<ul>
<li>- unofficial number like this not found</li>
<li>- kataster number like this not found</li>
</ul>
<h3>You probably got here because a survex (.svx) file has been stored on the server in the
<a href="/handbook/computing/repos.html"><var>:loser:</var></a> repository
but whoever was
responsible has not yet created the appropriate XML file the
<a href="/handbook/computing/repos.html"><var>:expoweb:</var></a> repository
which registers the cave description and ties together
the survex files with everything else.
</h3>
<p>The process for registering a new cave is documented in
<a href="/handbook/survey/caveentry.html">this part of the survey handbook</a>.
<p>
{% endblock %}

View File

@ -121,14 +121,14 @@ trogglepatterns = [
re_path(r'^cave/3d/(?P<cave_id>[^/]+)$', caves.cave3d, name="cave3d"),
re_path(r'^cave/description/([^/]+)/?$', caves.caveDescription),
re_path(r'^cave/(?P<cave_id>[^/]+)/?$', caves.cave, name="cave"),
re_path(r'^cave/(?P<cave_id>[^/]+)/?$', caves.cave, name="cave"), #!!!BAD, local links fail
re_path(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # view_caves.ent
re_path(r'^cave/(?P<slug>[^/]+)/edit/$', caves.edit_cave, name="edit_cave"),
re_path(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
re_path(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance), # lists all entrances
re_path(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance), # lists all entrances !!!BAD, local links fail
re_path(r'^entrance/(?P<caveslug>[^/]+)/(?P<slug>[^/]+)/edit/', caves.edit_entrance, name = "editentrance"), #edit existing entrance
re_path(r'^entrance/new/(?P<caveslug>[^/]+)$', caves.edit_entrance, name = "newentrance"), # new entrance for a cave