Fixed cave sort-order in cave index

This commit is contained in:
Philip Sargent 2021-04-16 16:01:35 +01:00
parent 16ef4fa9fb
commit 49277216ba
2 changed files with 20 additions and 13 deletions

View File

@ -69,14 +69,18 @@ def padnumber(x):
def numericalcmp(x, y):
return cmp(padnumber(x), padnumber(y))
def caveKey(x):
"""python3 function for sort. Done in a hurry.
Note that cave kataster numbers are not always integers.
This needs to be fixed make a decent sort order.
def caveKey(c):
"""This function goes into a lexicogrpahic sort function, and the values are strings,
but we want to sort numberically on kataster number before sorting on unofficial number.
"""
if not x.kataster_number:
return "~"
return x.kataster_number
if not c.kataster_number:
return "9999." + c.unofficial_number
else:
if int(c.kataster_number) >= 100:
return "99." + c.kataster_number
if int(c.kataster_number) >= 10:
return "9." + c.kataster_number
return c.kataster_number
def getnotablecaves():
notablecaves = []

View File

@ -17,20 +17,22 @@
<h3>1626</h3>
<ul class="searchable">
<div style="column-count: 2;">
<table class="searchable">
{% for cave in caves1626 %}
<li> <a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }} {{cave.official_name|safe}}</a> {% if cave.unofficial_number %}({{cave.unofficial_number }}){% endif %}{% else %}{{cave.unofficial_number }} {{cave.official_name|safe}}</a> {% endif %}
</li>
<tr><td><a href="{{ cave.url }}">{% if cave.kataster_number %}{{ cave.kataster_number }} {{cave.official_name|safe}}</a> {% if cave.unofficial_number %}({{cave.unofficial_number }}){% endif %}{% else %}{{cave.unofficial_number }} {{cave.official_name|safe}}</a> {% endif %} </td></tr>
{% endfor %}
</ul>
</table>
</div>
<p style="text-align:right">
<a href="{% url "newcave" %}">New Cave</a><br>
<a href="/noinfo/cave-number-index">Cave Number Index - kept updated</a>
</p>
<h3>1623</h3>
<div style="column-count: 3;">
<table class="searchable">
{% for cave in caves1623 %}
@ -38,6 +40,7 @@
{% endfor %}
</table>
</div>
<p style="text-align:right">
<a href="{% url "newcave" %}">New Cave</a><br>