mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 11:28:23 +00:00
Shorter, faster default caves index list
This commit is contained in:
@@ -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()},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user