mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
enhancing list of wallets on cave description page
This commit is contained in:
parent
ebfab4da45
commit
96b034d026
@ -62,6 +62,20 @@ class CaveAndEntrance(models.Model):
|
|||||||
# class CaveSlug(models.Model):
|
# class CaveSlug(models.Model):
|
||||||
# moved to models/logbooks.py to avoid cyclic import problem. No I don't know why either.
|
# moved to models/logbooks.py to avoid cyclic import problem. No I don't know why either.
|
||||||
|
|
||||||
|
def get_cave_leniently(caveid):
|
||||||
|
try:
|
||||||
|
c = getCave(caveid)
|
||||||
|
if c:
|
||||||
|
return c
|
||||||
|
except:
|
||||||
|
# print(f"get_cave_leniently FAIL {caveid}")
|
||||||
|
try:
|
||||||
|
c = getCave("1623-"+caveid)
|
||||||
|
if c:
|
||||||
|
return c
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
class Cave(TroggleModel):
|
class Cave(TroggleModel):
|
||||||
# (far) too much here perhaps,
|
# (far) too much here perhaps,
|
||||||
areacode = models.CharField(max_length=4, blank=True, null=True) # could use models.IntegerChoices
|
areacode = models.CharField(max_length=4, blank=True, null=True) # could use models.IntegerChoices
|
||||||
|
@ -11,7 +11,7 @@ from django.db import models
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from troggle.core.models.troggle import DataIssue
|
from troggle.core.models.troggle import DataIssue
|
||||||
from troggle.core.views.caves import get_cave_leniently
|
from troggle.core.models.caves import get_cave_leniently
|
||||||
|
|
||||||
# from troggle.core.models.survex import SurvexBlock
|
# from troggle.core.models.survex import SurvexBlock
|
||||||
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
|
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
|
||||||
@ -133,6 +133,9 @@ class Wallet(models.Model):
|
|||||||
# we do not use URL_ROOT any more.
|
# we do not use URL_ROOT any more.
|
||||||
return reverse("singlewallet", kwargs={"path": re.sub("#", "%23", self.walletname)})
|
return reverse("singlewallet", kwargs={"path": re.sub("#", "%23", self.walletname)})
|
||||||
|
|
||||||
|
def get_url(self):
|
||||||
|
return f"/walletedit/{self.walletname}".replace('#', ':')
|
||||||
|
|
||||||
def get_json(self):
|
def get_json(self):
|
||||||
"""Read the JSON file for the wallet and do stuff
|
"""Read the JSON file for the wallet and do stuff
|
||||||
Do it every time it is queried, to be sure the result is fresh.. well, no.
|
Do it every time it is queried, to be sure the result is fresh.. well, no.
|
||||||
@ -150,7 +153,7 @@ class Wallet(models.Model):
|
|||||||
fp = Path(self.fpath)
|
fp = Path(self.fpath)
|
||||||
wname = fp.name
|
wname = fp.name
|
||||||
wyear = fp.parent.name
|
wyear = fp.parent.name
|
||||||
wurl = f"/walletedit/{self.walletname}".replace('#', ':')
|
wurl = self.get_url()
|
||||||
|
|
||||||
if len(wyear) != 4 or len(wname) !=6:
|
if len(wyear) != 4 or len(wname) !=6:
|
||||||
# no contents.json for old-style wallets
|
# no contents.json for old-style wallets
|
||||||
|
@ -15,8 +15,9 @@ from django.urls import NoReverseMatch, reverse
|
|||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm
|
from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm
|
||||||
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup
|
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently
|
||||||
from troggle.core.models.logbooks import CaveSlug, QM
|
from troggle.core.models.logbooks import CaveSlug, QM
|
||||||
|
from troggle.core.models.wallets import Wallet
|
||||||
from troggle.core.utils import write_and_commit
|
from troggle.core.utils import write_and_commit
|
||||||
from troggle.core.views import expo
|
from troggle.core.views import expo
|
||||||
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
|
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
|
||||||
@ -40,19 +41,7 @@ todo = """
|
|||||||
https://zerotobyte.com/how-to-use-django-select-related-and-prefetch-related/
|
https://zerotobyte.com/how-to-use-django-select-related-and-prefetch-related/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_cave_leniently(caveid):
|
|
||||||
try:
|
|
||||||
c = getCave(caveid)
|
|
||||||
if c:
|
|
||||||
return c
|
|
||||||
except:
|
|
||||||
# print(f"get_cave_leniently FAIL {caveid}")
|
|
||||||
try:
|
|
||||||
c = getCave("1623-"+caveid)
|
|
||||||
if c:
|
|
||||||
return c
|
|
||||||
except:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def getCaves(cave_id):
|
def getCaves(cave_id):
|
||||||
@ -294,6 +283,8 @@ def rendercave(request, cave, slug, cave_id=""):
|
|||||||
# see design docum in troggle/templates/cave.html
|
# see design docum in troggle/templates/cave.html
|
||||||
# see rendercave() in troggle/core/views/caves.py
|
# see rendercave() in troggle/core/views/caves.py
|
||||||
templatefile = "cave.html"
|
templatefile = "cave.html"
|
||||||
|
|
||||||
|
wallets = Wallet.objects.filter(caves=cave)
|
||||||
|
|
||||||
if not cave_id:
|
if not cave_id:
|
||||||
cave_id = slug # cave.unofficial_number
|
cave_id = slug # cave.unofficial_number
|
||||||
@ -305,6 +296,7 @@ def rendercave(request, cave, slug, cave_id=""):
|
|||||||
"cave_id": cave_id,
|
"cave_id": cave_id,
|
||||||
"svxstem": str(svxstem),
|
"svxstem": str(svxstem),
|
||||||
"svx3d": svx3d,
|
"svx3d": svx3d,
|
||||||
|
"wallets": wallets,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do not catch any exceptions here: propagate up to caller
|
# Do not catch any exceptions here: propagate up to caller
|
||||||
|
@ -121,8 +121,15 @@ Nope, it is not useful, removing it... Philip S.
|
|||||||
<a href="{% url 'caveQMs' cave_id|safe %}">QM page for {{ cave_id|safe }}</a>
|
<a href="{% url 'caveQMs' cave_id|safe %}">QM page for {{ cave_id|safe }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>Scanned survey notes</h2>
|
{% if wallets %}
|
||||||
<a href="{% url "cavewallets" cave_id %}">{{ cave_id|safe }}</a> (if any)
|
<h2>Wallets: scanned survey notes</h2>
|
||||||
|
|
||||||
|
There are <a href="{% url "cavewallets" cave_id %}">{{wallets|length}} wallets</a> with data for this cave:<br />
|
||||||
|
{% for w in wallets %}
|
||||||
|
|
||||||
|
<a href="{{w.get_url}}">{{w.walletname}}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if cave.notes %}
|
{% if cave.notes %}
|
||||||
|
@ -20,11 +20,16 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
|||||||
{% for otherexpedition in expeditions %}
|
{% for otherexpedition in expeditions %}
|
||||||
| <a <a href="/wallets/year/{{ otherexpedition.year }}">{{otherexpedition.year}}</a>
|
| <a <a href="/wallets/year/{{ otherexpedition.year }}">{{otherexpedition.year}}</a>
|
||||||
{% endfor %}</ul></ul>
|
{% endfor %}</ul></ul>
|
||||||
|
|
||||||
{% include 'wallet_table.html' %}
|
{% include 'wallet_table.html' %}
|
||||||
|
|
||||||
<p>Note that names in italics are copied from the related survex file block name.
|
<p>Note that names in italics are copied from the related survex file block name.
|
||||||
<br />
|
<br />
|
||||||
<p>Total underground survey length: {{length_ug|floatformat:"1g"}} m<br />
|
<p>Total underground survey length: {{length_ug|floatformat:"1g"}} m<br />
|
||||||
Note that this is for <em>all the wallets</em> listed above, which includes those which may not be directly relevant to what you are looking for.
|
Note that this is for <em>all the wallets</em> listed above, which includes those which are surveys of different caves not just {{cave}}.
|
||||||
|
<br />
|
||||||
|
If you want accurate cave lengths for {{cave}}, go to the <a href="/survexfile/{{cave.survex_file}}">primary survex file</a> for this cave
|
||||||
|
and click on the "Run 'cavern' on this SVX file" button at the bottom of the page.
|
||||||
<br />
|
<br />
|
||||||
<table width=95%>
|
<table width=95%>
|
||||||
<tr><th>Wallet</th><th width=13%>Wallet Date</th><th>Wallet Name</th><th width=25%>People</th><th>Scans</th><th>Survex blocks</th><th>Drawings using these scans</th></tr>
|
<tr><th>Wallet</th><th width=13%>Wallet Date</th><th>Wallet Name</th><th width=25%>People</th><th>Scans</th><th>Survex blocks</th><th>Drawings using these scans</th></tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user