diff options
-rw-r--r-- | core/models/survex.py | 10 | ||||
-rw-r--r-- | core/views/scans.py | 45 | ||||
-rw-r--r-- | templates/base.html | 8 | ||||
-rw-r--r-- | templates/cavewallets.html | 9 | ||||
-rw-r--r-- | templates/manywallets.html | 5 | ||||
-rw-r--r-- | templates/svxcavesingle.html | 1 | ||||
-rw-r--r-- | templates/yearwallets.html | 45 |
7 files changed, 110 insertions, 13 deletions
diff --git a/core/models/survex.py b/core/models/survex.py index 79a645e..a84a37e 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -190,6 +190,16 @@ class Wallet(models.Model): raise 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 def date(self): diff --git a/core/views/scans.py b/core/views/scans.py index fda3d6d..6ecae2b 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -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 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): @@ -42,13 +45,13 @@ def populatewallet(w): def datewallet(w, earliest): blocks = SurvexBlock.objects.filter(scanswallet = w) - for b in blocks: - if b.date < earliest: - earliest = b.date + for b in blocks: + if b.date: + if b.date < earliest: + earliest = b.date w.date = earliest def caveifywallet(w): - print('*') blocks = SurvexBlock.objects.filter(scanswallet = w) for b in blocks: # 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'}) else: 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): @@ -98,7 +132,6 @@ def cavewallets(request, caveid): datewallet(w, earliest) c = w.cave() - if not c: caveifywallet(w) diff --git a/templates/base.html b/templates/base.html index 8f3f562..6d43e63 100644 --- a/templates/base.html +++ b/templates/base.html @@ -36,8 +36,8 @@ <a href="{% url "dwgallfiles" %}">Drawings</a> | <a href="{% url "dwgupload" %}">Upload Drawings</a> | <a href="{% url "photoupload" %}">Upload Photos</a> | - <a href="/1623/290/290.html">290 (FGH)</a> | - <a href="/1626/359/359.html">359 (Homecoming)</a> | + <a href="/1623/290/290">290 (FGH)</a> | + <a href="/1626/359/359">359 (Homecoming)</a> | <br> <a href="{% url "dataissues" %}">Data Issues</a> | @@ -48,8 +48,8 @@ <a id="folklink" href="/folk">expoers</a> | <a id="caversLink" href="{% url "notablepersons" %}">survey lengths</a> | <a href="{% url "stats" %}">statistics</a> | - <a href="{% url "expedition" 2018 %}">Expo2018</a> | - <a href="{% url "expedition" 2019 %}">Expo2019</a> | + <a href="/wallets/year/2019">Wallets(2019)</a> | + <a href="{% url "expedition" 2019 %}">Expo(2019)</a> | <a href="{% url "controlpanel" %}">import/export</a> | <a href="/admin/">Django admin</a> </div> diff --git a/templates/cavewallets.html b/templates/cavewallets.html index 51e5d76..3208927 100644 --- a/templates/cavewallets.html +++ b/templates/cavewallets.html @@ -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 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 year, e.g. <a href="/wallets/year/2019">2019</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> +<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" %} <tr> <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.name}}</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"> {% for survexblock in wallet.survexblock_set.all %} <a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a> diff --git a/templates/manywallets.html b/templates/manywallets.html index 7fc04cb..44d097f 100644 --- a/templates/manywallets.html +++ b/templates/manywallets.html @@ -9,6 +9,11 @@ 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>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() see https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related diff --git a/templates/svxcavesingle.html b/templates/svxcavesingle.html index ad8af8c..6b90b22 100644 --- a/templates/svxcavesingle.html +++ b/templates/svxcavesingle.html @@ -10,6 +10,7 @@ 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>Wallets: <a href="/cave/scans/{{cave|safe}}">{{cave|safe}}</a> </p> <p> {% for survexdirectory in cave.survexdirectory_set.all %} diff --git a/templates/yearwallets.html b/templates/yearwallets.html new file mode 100644 index 0000000..87843d2 --- /dev/null +++ b/templates/yearwallets.html @@ -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 %}
\ No newline at end of file |