From 89e38397b9d66cf95467aa6196ad4b2ad2f6eac1 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 28 Jul 2025 18:17:54 +0200 Subject: [PATCH] Shorter, faster default caves index list --- core/views/caves.py | 52 +++++++++++++---- templates/cave_red_star.html | 5 ++ templates/caveindex.html | 63 +++----------------- templates/cavesallindex.html | 110 +++++++++++++++++++++++++++++++++++ urls.py | 2 + 5 files changed, 168 insertions(+), 64 deletions(-) create mode 100644 templates/cave_red_star.html create mode 100644 templates/cavesallindex.html diff --git a/core/views/caves.py b/core/views/caves.py index df6d4fc..67d0b23 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -205,8 +205,48 @@ def getnotablecaves(): print(notablecaves) return notablecaves - def caveindex(request): + caves1623 = list(Cave.objects.filter(areacode="1623")) + caves1626 = list(Cave.objects.filter(areacode="1626")) + caves1623.sort(key=caveKey) + caves1626.sort(key=caveKey) + + allcaves = caves1623 + caves1626 + caves_this_year = [] + for c in allcaves: + if c.unofficial_number.startswith(current_expo()): + caves_this_year.append(c) + caves_this_year.sort(key=caveKey) + + caves_last_year = [] + for c in allcaves: + last_year = str(int(current_expo()) - 1) + if c.unofficial_number.startswith(last_year): + caves_last_year.append(c) + caves_this_year.sort(key=caveKey) + + caves_previous_year = [] + for c in allcaves: + previous_year = str(int(current_expo()) - 2) + if c.unofficial_number.startswith(previous_year): + caves_previous_year.append(c) + caves_previous_year.sort(key=caveKey) + + return render( + request, + "caveindex.html", + {"caves1623": caves1623, + "caves1626": caves1626, + "caves1627": "", + "caves1624": "", + "notablecaves": getnotablecaves(), + "caves_this_year": caves_this_year, + "caves_last_year": caves_last_year, + "caves_previous_year": caves_previous_year, + "cavepage": True, "year": current_expo()}, + ) + +def cavesall(request): """Should use Django order-by for lazy sorting, not here. But only after we have a proper slug system in place for Caves """ # allcaves = Cave.objects.all() @@ -230,23 +270,15 @@ def caveindex(request): caves_this_year.append(c) caves_this_year.sort(key=caveKey) - caves_last_year = [] - for c in allcaves: - last_year = str(int(current_expo()) - 1) - if c.unofficial_number.startswith(last_year): - caves_last_year.append(c) - caves_this_year.sort(key=caveKey) - return render( request, - "caveindex.html", + "cavesallindex.html", {"caves1623": caves1623, "caves1626": caves1626, "caves1627": caves1627, "caves1624": caves1624, "notablecaves": getnotablecaves(), "caves_this_year": caves_this_year, - "caves_last_year": caves_last_year, "cavepage": True, "year": current_expo()}, ) diff --git a/templates/cave_red_star.html b/templates/cave_red_star.html new file mode 100644 index 0000000..ce0ec80 --- /dev/null +++ b/templates/cave_red_star.html @@ -0,0 +1,5 @@ +Red star * against a name indicates that no survex file is explicitly associated with the cave
+Blue star * against a name indicates that no survex file is explicitly associated with the cave but it is marked as 'fully explored'
+Blue triangle against a name indicates that the cave is 'pending' creation properly.
+Orange triangle against a name indicates that the cave has no Entrance (and is not 'pending').
+Black triangle against a name indicates that the cave has an Entrance, but no entrances have valid located survey stations. \ No newline at end of file diff --git a/templates/caveindex.html b/templates/caveindex.html index 2b8288b..d912385 100644 --- a/templates/caveindex.html +++ b/templates/caveindex.html @@ -1,10 +1,10 @@ {% extends "cavebase.html" %} -{% block title %}Cave Index{% endblock %} +{% block title %}Recent Caves Index{% endblock %} {% block content %} -

Cave Index

+

Recent Caves Index

Notable caves

-Red star * against a name indicates that no survex file is explicitly associated with the cave
-Blue star * against a name indicates that no survex file is explicitly associated with the cave but it is marked as 'fully explored'
-Blue triangle against a name indicates that the cave is 'pending' creation properly.
-Orange triangle against a name indicates that the cave has no Entrance (and is not 'pending').
-Black triangle against a name indicates that the cave has an Entrance, but no entrances have valid located survey stations. +{% include 'cave_red_star.html' %} +

+See All Caves for all the caves in areas 1623, 1626, 1624, 1627

New Cave
@@ -51,59 +49,16 @@ Black triangle against a name indicat -

1623

+

Previous year's caves

-{% for cave in caves1623 %} +{% for cave in caves_previous_year %} {% include 'cavelist_columns.html' %} {% endfor %}
- -

- New Cave
- Cave Number Index - kept updated -

- -

1626

-
- - {% for cave in caves1626 %} - {% include 'cavelist_columns.html' %} - {% endfor %} -
-
- -

- New Cave
- Cave Number Index - kept updated -

- - -

1627

-
- - {% for cave in caves1627 %} - {% include 'cavelist_columns.html' %} - {% endfor %} -
-
- -

- New Cave
- Cave Number Index - kept updated -

- -

1624

-
- - {% for cave in caves1624 %} - {% include 'cavelist_columns.html' %} - - {% endfor %} -
- -
+

+See All Caves for all the caves in areas 1623, 1626, 1624, 1627

New Cave
diff --git a/templates/cavesallindex.html b/templates/cavesallindex.html new file mode 100644 index 0000000..05d62b4 --- /dev/null +++ b/templates/cavesallindex.html @@ -0,0 +1,110 @@ +{% extends "cavebase.html" %} + +{% block title %}Cave Index{% endblock %} + +{% block content %} + +

Cave Index

+

Notable caves

+ + +{% include 'cave_red_star.html' %} + +

Go to Recent Caves for a shorter list of recent caves. + +

+ New Cave
+ Cave Number Index - kept updated +

+ + + +

This year's caves

+
+ +{% for cave in caves_this_year %} + {% include 'cavelist_columns.html' %} +{% endfor %} +
+
+ +

Last year's caves

+
+ +{% for cave in caves_last_year %} + {% include 'cavelist_columns.html' %} +{% endfor %} +
+
+ +

1623

+
+ +{% for cave in caves1623 %} + {% include 'cavelist_columns.html' %} +{% endfor %} +
+
+ +

+ New Cave
+ Cave Number Index - kept updated +

+ +

1626

+
+ + {% for cave in caves1626 %} + {% include 'cavelist_columns.html' %} + {% endfor %} +
+
+ +

+ New Cave
+ Cave Number Index - kept updated +

+ + +

1627

+
+ + {% for cave in caves1627 %} + {% include 'cavelist_columns.html' %} + {% endfor %} +
+
+ +

+ New Cave
+ Cave Number Index - kept updated +

+ +

1624

+
+ + {% for cave in caves1624 %} + {% include 'cavelist_columns.html' %} + + {% endfor %} +
+ +
+ +

+ New Cave
+ Cave Number Index - kept updated +

+{% endblock %} diff --git a/urls.py b/urls.py index 0459a66..3a4616b 100644 --- a/urls.py +++ b/urls.py @@ -11,6 +11,7 @@ from troggle.core.views.caves import ( cave3d, cave_debug, caveindex, + cavesall, cavepage, caveQMs, caveslist, @@ -157,6 +158,7 @@ trogglepatterns = [ path('people_ids', people_ids, name="people_ids"), path('folk_export', folk_export, name="folk_export"), path('caveslist', caveslist, name="caveslist"), + path('cavesall', cavesall, name="cavesall"), path('entrances', entranceindex, name="entranceindex"), path('enttags', entrancetags, name="entrancetags"),