summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/views/scans.py18
-rw-r--r--templates/cavewallets.html37
-rw-r--r--templates/manywallets.html2
-rw-r--r--urls.py10
4 files changed, 60 insertions, 7 deletions
diff --git a/core/views/scans.py b/core/views/scans.py
index 097c69f..8ecec0a 100644
--- a/core/views/scans.py
+++ b/core/views/scans.py
@@ -9,6 +9,7 @@ from django.shortcuts import render
from django.http import HttpResponse
from troggle.core.models.survex import Wallet, SingleScan
+from troggle.core.models.caves import GetCaveLookup
from troggle.core.views.expo import getmimetype
#import parsers.surveys
@@ -47,10 +48,11 @@ def walletindex(request, path):
def scansingle(request, path, file):
'''sends a single binary file to the user for display - browser decides how using mimetype
'''
+
try:
wallet = Wallet.objects.get(walletname=urlunquote(path))
singlescan = SingleScan.objects.get(wallet=wallet, name=file)
- # print(" - scansingle {}:{}:{}:".format(path, file, getmimetype(file)))
+ print(" - scansingle {}:{}:{}:".format(path, file, getmimetype(file)))
return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(file)) # any type of image
except:
message = f'Scan folder or scan item error or not found \'{path}\' and \'{file}\'.'
@@ -66,3 +68,17 @@ def allwallets(request):
manywallets = Wallet.objects.all()
# manywallets = Wallet.objects.all().prefetch_related('singlescan') fails as the link is defined on 'singlescan' not on 'wallet'
return render(request, 'manywallets.html', { 'manywallets':manywallets, 'settings': settings })
+
+def cavewallets(request, cave_id):
+ '''Returns all the wallets for just one cave,
+ '''
+ Gcavelookup = GetCaveLookup()
+ if cave_id in Gcavelookup:
+ cave = Gcavelookup[cave_id]
+ else:
+ return render(request,'errors/badslug.html', {'badslug': cave_id})
+
+ print(f'cavewallets {cave_id=} {cave=}')
+
+ manywallets = Wallet.objects.filter(survexblock__survexfile__cave=cave)
+ return render(request, 'cavewallets.html', { 'manywallets':manywallets, 'settings': settings })
diff --git a/templates/cavewallets.html b/templates/cavewallets.html
new file mode 100644
index 0000000..670ce51
--- /dev/null
+++ b/templates/cavewallets.html
@@ -0,0 +1,37 @@
+{% extends "base.html" %}
+
+{% block title %}All Survey scans folders (wallets){% endblock %}
+
+{% block content %}
+
+<h3>Survey scans folders (wallets) for a specific cave</h3>
+<p>Each wallet contains the scanned original in-cave survey notes and sketches of
+plans and elevations. It also contains scans of centre-line survex output on which
+hand-drawn passage sections are drawn. These hand-drawn passages will eventually be
+traced to produce Tunnel or Therion drawings and eventually the final complete cave survey.
+
+
+<table width=95%>
+<tr><th>Scans folder</th><th>Files</th><th>Survex blocks</th><th>Cave</th></tr>
+{% for scanswallet in manywallets %}
+ <tr>
+ <td style="padding:2px"><a href="{{scanswallet.get_absolute_url}}">{{scanswallet.walletname}}</a></td>
+ <td align="right" style="padding:2px">{{scanswallet.singlescan_set.all|length}}</td>
+ <td style="padding:2px">
+ {% for survexblock in scanswallet.survexblock_set.all %}
+ <a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a>
+ {% endfor %}
+ </td>
+ <td style="padding:2px">
+ {% for survexblock in scanswallet.survexblock_set.all %}
+ {% ifchanged survexblock.survexfile.cave %}
+ <a href="/{{survexblock.survexfile.cave.url}}">/{{survexblock.survexfile.cave.slug}}</a>
+ {% endifchanged %}
+
+ {% endfor %}
+ </td>
+ </tr>
+{% endfor %}
+</table>
+
+{% endblock %} \ No newline at end of file
diff --git a/templates/manywallets.html b/templates/manywallets.html
index 46dd302..7fc04cb 100644
--- a/templates/manywallets.html
+++ b/templates/manywallets.html
@@ -27,7 +27,7 @@ see https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related
<td style="padding:2px">
{% for survexblock in scanswallet.survexblock_set.all %}
{% ifchanged survexblock.survexfile.cave %}
- <a href="/{{survexblock.survexfile.cave.url}}">/{{survexblock.survexfile.cave.slug}}</a>
+ <a href="/cave/scans/{{survexblock.survexfile.cave.slug}}">/{{survexblock.survexfile.cave.slug}}</a>
{% endifchanged %}
{% endfor %}
diff --git a/urls.py b/urls.py
index 56c6fa5..e02c4f0 100644
--- a/urls.py
+++ b/urls.py
@@ -8,7 +8,7 @@ from django.contrib import auth
from django.urls import path, reverse, resolve
from troggle.core.views import statistics, survex
-from troggle.core.views.scans import scansingle, allwallets
+from troggle.core.views.scans import scansingle, allwallets, cavewallets
from troggle.core.views.drawings import dwgallfiles, dwgfilesingle
from troggle.core.views.uploads import dwgupload, scanupload, photoupload
from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage
@@ -133,8 +133,7 @@ trogglepatterns = [
re_path(r'^(?P<slug>[^/]+)_cave_edit/$', edit_cave, name="edit_cave"), # edit_cave needed by cave.html template for url matching
re_path(r'^(.*)_edit$', editexpopage, name="editexpopage"),
re_path(r'^(?P<karea>\d\d\d\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand /1623/264 or 1623/161/top.htm
- # Note that urls eg '/1623/161/l/rl89a.htm' are handled by cavepage which redirects them to 'expopage'
- # Note that _edit$ for a cave description page in a subfolder e.g. /1623/204/204.html_edit gets caught here and breaks with 404
+ # Note that urls eg '/1623/161/l/rl89a.htm' are handled by cavepage which redirects them to 'expopage' # Note that _edit$ for a cave description page in a subfolder e.g. /1623/204/204.html_edit gets caught here and breaks with 404
# Entrances
re_path(r'^cave/entrance/([^/]+)/?$', caveEntrance), # lists all entrances !!!BAD, local links fail
@@ -168,7 +167,8 @@ trogglepatterns = [
# The survey scans in the wallets. This short-cuts SCANS_URL which is not actually used anywhere!
path('survey_scans/', allwallets, name="allwallets"),
path('survey_scans/<path:path>/', scanupload, name="singlewallet"), # replaced singlewallet()
- path('survey_scans/<path:path>/<file>', scansingle, name="scansingle"),
+ path('survey_scans/<path:path>/<file>', scansingle, name="scansingle"), # works, but html href goes direct to /expofiles/ too
+ re_path(r'^cave/scans/(?P<cave_id>[^/]+)$', cavewallets, name="cavewallets"), # like allwallets, but for just one cave
# The tunnel and therion drawings files pages
path('dwgfiles', dwgallfiles, name="dwgallfiles"),
@@ -176,7 +176,7 @@ trogglepatterns = [
path('dwgdataraw/<path:path>', dwgfilesingle, name="dwgfilesingle"),
# QMs pages - must precede other /caves pages?
- re_path(r'^cave/qms/([^/]+)/?$', caveQMs, name="caveQMs"), # Fixed. July 2022
+ re_path(r'^cave/qms/([^/]+)/?$', caveQMs, name="caveQMs"),
re_path(r'^cave/qms/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDXV\?]?)-?(?P<blockname>[a-zA-Z]+.*)?$', qm, name="qm"), # Dogs breakfast
# the resolution of a QM uses several fields together, there is no clean slug field. Artefact of history.