forked from expo/troggle
Wallets by year and by cave
This commit is contained in:
parent
724234949f
commit
c1ba6a39a5
@ -190,6 +190,16 @@ class Wallet(models.Model):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
return waldata
|
return waldata
|
||||||
|
|
||||||
|
def year(self):
|
||||||
|
if self.walletname[4] != "#":
|
||||||
|
return None
|
||||||
|
year = int(self.walletname[0:4])
|
||||||
|
if year < 1976 or year > 2050:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return str(year)
|
||||||
|
|
||||||
|
|
||||||
# Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it
|
# Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it
|
||||||
def date(self):
|
def date(self):
|
||||||
|
@ -20,6 +20,9 @@ by looking inside the file before being served.
|
|||||||
|
|
||||||
need to check if inavlid query string is invalid, or produces multiple replies
|
need to check if inavlid query string is invalid, or produces multiple replies
|
||||||
and render a user-friendly error page.
|
and render a user-friendly error page.
|
||||||
|
|
||||||
|
Note that datewallet(), caveifywallet() etc do NOT save the object to the db. They are ephemeral, just for the page rendering of the
|
||||||
|
manywallets dict.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def populatewallet(w):
|
def populatewallet(w):
|
||||||
@ -42,13 +45,13 @@ def populatewallet(w):
|
|||||||
|
|
||||||
def datewallet(w, earliest):
|
def datewallet(w, earliest):
|
||||||
blocks = SurvexBlock.objects.filter(scanswallet = w)
|
blocks = SurvexBlock.objects.filter(scanswallet = w)
|
||||||
for b in blocks:
|
for b in blocks:
|
||||||
if b.date < earliest:
|
if b.date:
|
||||||
earliest = b.date
|
if b.date < earliest:
|
||||||
|
earliest = b.date
|
||||||
w.date = earliest
|
w.date = earliest
|
||||||
|
|
||||||
def caveifywallet(w):
|
def caveifywallet(w):
|
||||||
print('*')
|
|
||||||
blocks = SurvexBlock.objects.filter(scanswallet = w)
|
blocks = SurvexBlock.objects.filter(scanswallet = w)
|
||||||
for b in blocks:
|
for b in blocks:
|
||||||
# NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath
|
# NB b.cave is not populated by parser. Use b.survexfile.cave instead, or we could parse b.survexpath
|
||||||
@ -64,7 +67,38 @@ def walletslistyear(request, year):
|
|||||||
return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'})
|
return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'})
|
||||||
else:
|
else:
|
||||||
year = str(year)
|
year = str(year)
|
||||||
return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'})
|
#return render(request, 'errors/generic.html', {'message': 'This page logic not implemented yet'})
|
||||||
|
earliest = datetime.datetime.now().date()
|
||||||
|
|
||||||
|
manywallets = []
|
||||||
|
wallets = Wallet.objects.all()
|
||||||
|
for w in wallets:
|
||||||
|
|
||||||
|
if year == w.year():
|
||||||
|
print(w.year(), w)
|
||||||
|
manywallets.append(w)
|
||||||
|
else:
|
||||||
|
print("NOT WANTED",year, w.year())
|
||||||
|
continue
|
||||||
|
|
||||||
|
wp = w.people()
|
||||||
|
if not wp: # an -empty list
|
||||||
|
populatewallet(w)
|
||||||
|
else:
|
||||||
|
if len(wp) == 1:
|
||||||
|
nobody = wp[0].lower()
|
||||||
|
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ':
|
||||||
|
populatewallet(w)
|
||||||
|
|
||||||
|
if not w.date():
|
||||||
|
datewallet(w, earliest)
|
||||||
|
|
||||||
|
c = w.cave()
|
||||||
|
if not c:
|
||||||
|
caveifywallet(w)
|
||||||
|
|
||||||
|
return render(request, 'yearwallets.html', { 'manywallets':manywallets, 'settings': settings, 'year': year})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def cavewallets(request, caveid):
|
def cavewallets(request, caveid):
|
||||||
@ -98,7 +132,6 @@ def cavewallets(request, caveid):
|
|||||||
datewallet(w, earliest)
|
datewallet(w, earliest)
|
||||||
|
|
||||||
c = w.cave()
|
c = w.cave()
|
||||||
|
|
||||||
if not c:
|
if not c:
|
||||||
caveifywallet(w)
|
caveifywallet(w)
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
<a href="{% url "dwgallfiles" %}">Drawings</a> |
|
<a href="{% url "dwgallfiles" %}">Drawings</a> |
|
||||||
<a href="{% url "dwgupload" %}">Upload Drawings</a> |
|
<a href="{% url "dwgupload" %}">Upload Drawings</a> |
|
||||||
<a href="{% url "photoupload" %}">Upload Photos</a> |
|
<a href="{% url "photoupload" %}">Upload Photos</a> |
|
||||||
<a href="/1623/290/290.html">290 (FGH)</a> |
|
<a href="/1623/290/290">290 (FGH)</a> |
|
||||||
<a href="/1626/359/359.html">359 (Homecoming)</a> |
|
<a href="/1626/359/359">359 (Homecoming)</a> |
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a href="{% url "dataissues" %}">Data Issues</a> |
|
<a href="{% url "dataissues" %}">Data Issues</a> |
|
||||||
@ -48,8 +48,8 @@
|
|||||||
<a id="folklink" href="/folk">expoers</a> |
|
<a id="folklink" href="/folk">expoers</a> |
|
||||||
<a id="caversLink" href="{% url "notablepersons" %}">survey lengths</a> |
|
<a id="caversLink" href="{% url "notablepersons" %}">survey lengths</a> |
|
||||||
<a href="{% url "stats" %}">statistics</a> |
|
<a href="{% url "stats" %}">statistics</a> |
|
||||||
<a href="{% url "expedition" 2018 %}">Expo2018</a> |
|
<a href="/wallets/year/2019">Wallets(2019)</a> |
|
||||||
<a href="{% url "expedition" 2019 %}">Expo2019</a> |
|
<a href="{% url "expedition" 2019 %}">Expo(2019)</a> |
|
||||||
<a href="{% url "controlpanel" %}">import/export</a> |
|
<a href="{% url "controlpanel" %}">import/export</a> |
|
||||||
<a href="/admin/">Django admin</a>
|
<a href="/admin/">Django admin</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,9 +10,13 @@ plans and elevations. It also contains scans of centre-line survex output on whi
|
|||||||
hand-drawn passage sections are drawn. These hand-drawn passages will eventually be
|
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.
|
traced to produce Tunnel or Therion drawings and eventually the final complete cave survey.
|
||||||
<p>This lists all the files in a wallet, some of which may not be for this specific cave.
|
<p>This lists all the files in a wallet, some of which may not be for this specific cave.
|
||||||
|
<p>See also wallets
|
||||||
|
<ul>
|
||||||
|
<li>per year, e.g. <a href="/wallets/year/2019">2019</a>
|
||||||
|
|
||||||
|
</ul>
|
||||||
<table width=95%>
|
<table width=95%>
|
||||||
<tr><th>Wallet</th><th>Wallet Date</th><th>Wallet Name</th><th>People</th><th>Cave</th><th>Scans</th><th>Survex blocks</th><th>Drawings using these scans</th></tr>
|
<tr><th>Wallet</th><th>Wallet Date</th><th>Wallet Name</th><th>People</th><th>Scans</th><th>Survex blocks</th><th>Drawings using these scans</th></tr>
|
||||||
{% for wallet in manywallets|dictsort:"walletname" %}
|
{% for wallet in manywallets|dictsort:"walletname" %}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.walletname}}</a></td>
|
<td style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.walletname}}</a></td>
|
||||||
@ -20,9 +24,8 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
|||||||
<td style="padding:2px">{{wallet.date}}</td>
|
<td style="padding:2px">{{wallet.date}}</td>
|
||||||
<td style="padding:2px">{{wallet.name}}</td>
|
<td style="padding:2px">{{wallet.name}}</td>
|
||||||
<td style="padding:2px">{{wallet.people}}</td>
|
<td style="padding:2px">{{wallet.people}}</td>
|
||||||
<td style="padding:2px">{{wallet.cave}}</td>
|
|
||||||
|
|
||||||
<td align="right" style="padding:2px">{{wallet.singlescan_set.all|length}}</td>
|
<td align="center" style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.singlescan_set.all|length}}</a></td>
|
||||||
<td style="padding:2px">
|
<td style="padding:2px">
|
||||||
{% for survexblock in wallet.survexblock_set.all %}
|
{% for survexblock in wallet.survexblock_set.all %}
|
||||||
<a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a>
|
<a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a>
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
plans and elevations. It also contains scans of centre-line survex output on which
|
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
|
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.
|
traced to produce Tunnel or Therion drawings and eventually the final complete cave survey.
|
||||||
|
<p>See also wallets
|
||||||
|
<ul>
|
||||||
|
<li>per year, e.g. <a href="/wallets/year/2019">2019</a>
|
||||||
|
<li>per cave, e.g. <a href="/cave/scans/1623-204">1623/204</a>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<!-- This should all be restructured to use .prefetch_related() and .select_related()
|
<!-- This should all be restructured to use .prefetch_related() and .select_related()
|
||||||
see https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related
|
see https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
All the processing to extract the survex subdriectories and survex files is done in this template -->
|
All the processing to extract the survex subdriectories and survex files is done in this template -->
|
||||||
|
|
||||||
<p>Cave description: <a href="/{{cave.url}}">{{cave.url}}</a>
|
<p>Cave description: <a href="/{{cave.url}}">{{cave.url}}</a>
|
||||||
|
<p>Wallets: <a href="/cave/scans/{{cave|safe}}">{{cave|safe}}</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{% for survexdirectory in cave.survexdirectory_set.all %}
|
{% for survexdirectory in cave.survexdirectory_set.all %}
|
||||||
|
45
templates/yearwallets.html
Normal file
45
templates/yearwallets.html
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}One Year Survey scans folders (wallets){% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h3>Wallets for {{year}} </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.
|
||||||
|
<p>This lists all the files in a wallet, some of which may not be for this specific cave.
|
||||||
|
<p>See also wallets
|
||||||
|
<ul>
|
||||||
|
<li>per cave, e.g. <a href="/cave/scans/1623-204">1623/204</a>
|
||||||
|
</ul>
|
||||||
|
<table width=95%>
|
||||||
|
<tr><th>Wallet</th><th>Wallet Date</th><th>Wallet Name</th><th>People</th><th>Cave</th><th>Scans</th><th>Survex blocks</th><th>Drawings using these scans</th></tr>
|
||||||
|
{% for wallet in manywallets|dictsort:"walletname" %}
|
||||||
|
<tr>
|
||||||
|
<td style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.walletname}}</a></td>
|
||||||
|
|
||||||
|
<td style="padding:2px">{{wallet.date}}</td>
|
||||||
|
<td style="padding:2px">{{wallet.name}}</td>
|
||||||
|
<td style="padding:2px">{{wallet.people}}</td>
|
||||||
|
<td style="padding:2px">{{wallet.cave}}</td>
|
||||||
|
|
||||||
|
<td align="center" style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.singlescan_set.all|length}}</a></td>
|
||||||
|
<td style="padding:2px">
|
||||||
|
{% for survexblock in wallet.survexblock_set.all %}
|
||||||
|
<a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td style="padding:2px">
|
||||||
|
{% for drawing in wallet.drawingfile_set.all %}
|
||||||
|
<a href="{% url "dwgfilesingle" drawing.dwgpath %}">{{drawing.dwgpath}}</a><br>
|
||||||
|
{% empty %}
|
||||||
|
(no Tunnel drawings found: but there might be Therion drawings)
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user