mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
wallets for just one cave
This commit is contained in:
parent
3e869ae76a
commit
8245ee103e
@ -9,6 +9,7 @@ from django.shortcuts import render
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
from troggle.core.models.survex import Wallet, SingleScan
|
from troggle.core.models.survex import Wallet, SingleScan
|
||||||
|
from troggle.core.models.caves import GetCaveLookup
|
||||||
from troggle.core.views.expo import getmimetype
|
from troggle.core.views.expo import getmimetype
|
||||||
#import parsers.surveys
|
#import parsers.surveys
|
||||||
|
|
||||||
@ -47,10 +48,11 @@ def walletindex(request, path):
|
|||||||
def scansingle(request, path, file):
|
def scansingle(request, path, file):
|
||||||
'''sends a single binary file to the user for display - browser decides how using mimetype
|
'''sends a single binary file to the user for display - browser decides how using mimetype
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
wallet = Wallet.objects.get(walletname=urlunquote(path))
|
wallet = Wallet.objects.get(walletname=urlunquote(path))
|
||||||
singlescan = SingleScan.objects.get(wallet=wallet, name=file)
|
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
|
return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(file)) # any type of image
|
||||||
except:
|
except:
|
||||||
message = f'Scan folder or scan item error or not found \'{path}\' and \'{file}\'.'
|
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()
|
||||||
# manywallets = Wallet.objects.all().prefetch_related('singlescan') fails as the link is defined on 'singlescan' not on 'wallet'
|
# 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 })
|
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 })
|
||||||
|
37
templates/cavewallets.html
Normal file
37
templates/cavewallets.html
Normal file
@ -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 %}
|
@ -27,7 +27,7 @@ see https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related
|
|||||||
<td style="padding:2px">
|
<td style="padding:2px">
|
||||||
{% for survexblock in scanswallet.survexblock_set.all %}
|
{% for survexblock in scanswallet.survexblock_set.all %}
|
||||||
{% ifchanged survexblock.survexfile.cave %}
|
{% 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 %}
|
{% endifchanged %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
10
urls.py
10
urls.py
@ -8,7 +8,7 @@ from django.contrib import auth
|
|||||||
from django.urls import path, reverse, resolve
|
from django.urls import path, reverse, resolve
|
||||||
|
|
||||||
from troggle.core.views import statistics, survex
|
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.drawings import dwgallfiles, dwgfilesingle
|
||||||
from troggle.core.views.uploads import dwgupload, scanupload, photoupload
|
from troggle.core.views.uploads import dwgupload, scanupload, photoupload
|
||||||
from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage
|
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'^(?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'^(.*)_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
|
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 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 _edit$ for a cave description page in a subfolder e.g. /1623/204/204.html_edit gets caught here and breaks with 404
|
|
||||||
|
|
||||||
# Entrances
|
# Entrances
|
||||||
re_path(r'^cave/entrance/([^/]+)/?$', caveEntrance), # lists all entrances !!!BAD, local links fail
|
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!
|
# 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/', allwallets, name="allwallets"),
|
||||||
path('survey_scans/<path:path>/', scanupload, name="singlewallet"), # replaced singlewallet()
|
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
|
# The tunnel and therion drawings files pages
|
||||||
path('dwgfiles', dwgallfiles, name="dwgallfiles"),
|
path('dwgfiles', dwgallfiles, name="dwgallfiles"),
|
||||||
@ -176,7 +176,7 @@ trogglepatterns = [
|
|||||||
path('dwgdataraw/<path:path>', dwgfilesingle, name="dwgfilesingle"),
|
path('dwgdataraw/<path:path>', dwgfilesingle, name="dwgfilesingle"),
|
||||||
|
|
||||||
# QMs pages - must precede other /caves pages?
|
# 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
|
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.
|
# the resolution of a QM uses several fields together, there is no clean slug field. Artefact of history.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user