summaryrefslogtreecommitdiffstats
path: root/core/views_caves.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/views_caves.py')
-rw-r--r--core/views_caves.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/core/views_caves.py b/core/views_caves.py
index 943e797..8613790 100644
--- a/core/views_caves.py
+++ b/core/views_caves.py
@@ -72,16 +72,30 @@ def caveKey(x):
"""
return x.kataster_number
+def getnotablecaves():
+ notablecaves = []
+ for kataster_number in settings.NOTABLECAVESHREFS:
+ try:
+ cave = Cave.objects.get(kataster_number=kataster_number)
+ notablecaves.append(cave)
+ except:
+ print(" ! FAILED to get only one cave per kataster_number for: "+kataster_number)
+ caves = Cave.objects.all().filter(kataster_number=kataster_number)
+ for c in caves:
+ print(c.kataster_number, c.slug())
+ if c.slug() != None:
+ notablecaves.append(c)
+ return notablecaves
+
+
def caveindex(request):
caves = Cave.objects.all()
- notablecavehrefs = settings.NOTABLECAVESHREFS
- notablecaves = [Cave.objects.get(kataster_number=kataster_number) for kataster_number in notablecavehrefs ]
caves1623 = list(Cave.objects.filter(area__short_name = "1623"))
caves1626 = list(Cave.objects.filter(area__short_name = "1626"))
#python2 to python3 issue https://realpython.com/python-sort/
caves1623.sort(key=caveKey)
caves1626.sort(key=caveKey)
- return render(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':notablecaves, 'cavepage': True})
+ return render(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':getnotablecaves(), 'cavepage': True})
def cave3d(request, cave_id=''):
cave = getCave(cave_id)