mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +00:00
fix more twiddly variations of QMs
This commit is contained in:
parent
d64948749e
commit
5a90e7b727
@ -150,8 +150,8 @@ class QM(TroggleModel):
|
||||
blockname = models.TextField(blank=True, null=True) # NB truncated copy of survexblock name with last char added
|
||||
expoyear = models.CharField(max_length=4, blank=True, null=True)
|
||||
ticked = models.BooleanField(default=False)
|
||||
location_description = models.TextField(blank=True)
|
||||
completion_description = models.TextField(blank=True)
|
||||
location_description = models.TextField(blank=True, null=True)
|
||||
completion_description = models.TextField(blank=True, null=True)
|
||||
completion_date = models.DateField(blank=True, null=True)
|
||||
nearest_station_name = models.CharField(max_length=200, blank=True, null=True)
|
||||
resolution_station_name = models.CharField(max_length=200, blank=True, null=True)
|
||||
@ -177,17 +177,17 @@ class QM(TroggleModel):
|
||||
blocknamestr = ""
|
||||
return f"{cavestr}-{expoyearstr}-{self.number}{self.grade}{blocknamestr}"
|
||||
|
||||
def get_completion_url(self):
|
||||
"""assumes html file named is in same folder as cave description file
|
||||
WRONG - needs rewriting!"""
|
||||
cd = None
|
||||
if self.completion_description:
|
||||
try:
|
||||
dir = Path(self.cave.url).parent
|
||||
cd = dir / self.completion_description
|
||||
except:
|
||||
cd = None
|
||||
return cd
|
||||
# def get_completion_url(self):
|
||||
# """assumes html file named is in same folder as cave description file
|
||||
# WRONG - needs rewriting!"""
|
||||
# cd = None
|
||||
# if self.completion_description:
|
||||
# try:
|
||||
# dir = Path(self.cave.url).parent
|
||||
# cd = dir / self.completion_description
|
||||
# except:
|
||||
# cd = None
|
||||
# return cd
|
||||
|
||||
def newslug(self):
|
||||
qmslug = f"{str(self.cave)}-{self.expoyear}-{self.blockname}{self.number}{self.grade}"
|
||||
|
@ -550,7 +550,7 @@ def qm(request, cave_id, qm_id, year, grade=None, blockname=None):
|
||||
try:
|
||||
c = getCave(cave_id)
|
||||
manyqms = c.get_open_QMs() | c.get_ticked_QMs() # set union operation
|
||||
qm = manyqms.get(number=qm_id, expoyear=year)
|
||||
qm = manyqms.get(number=qm_id, expoyear=year, grade=grade)
|
||||
return render(request, "qm.html", {"qm": qm})
|
||||
except QM.DoesNotExist:
|
||||
# raise
|
||||
@ -561,6 +561,16 @@ def qm(request, cave_id, qm_id, year, grade=None, blockname=None):
|
||||
"badslug": f"QM.DoesNotExist blockname is empty string: {cave_id=} {year=} {qm_id=} {grade=} {blockname=}"
|
||||
},
|
||||
)
|
||||
except QM.MultipleObjectsReturned:
|
||||
# raise
|
||||
qms = manyqms.filter(number=qm_id, expoyear=year)
|
||||
return render(
|
||||
request,
|
||||
"errors/badslug.html",
|
||||
{
|
||||
"badslug": f"QM.MultipleObjectsReturned {cave_id=} {year=} {qm_id=} {grade=} {blockname=} {qms=}"
|
||||
},
|
||||
)
|
||||
|
||||
else:
|
||||
try:
|
||||
|
@ -147,20 +147,32 @@ def parse_KH_QMs(kh, inputFile, ticked):
|
||||
# <dt><a href="sibria.htm#qC1997-161-27" name="C1997-161-27">C1997-161-27</a> A<dd>Sib: pitch at end of Fuzzy Logic [Paradox Rift - continues] [sep.fuzzy.13]
|
||||
line += 1
|
||||
res = re.search(
|
||||
r"name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a>\s*(?P<grade>[ABCDX?V])<dd>(?P<location_description>.*)(\[(?P<station_name>.*)\])?",
|
||||
r"name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a>\s*(?P<grade>[ABCDX?V])<dd>(?P<location_description>[^[]*)(\[\s*(?P<completion>[^]]*)\s*\])?\s*(\[\s*(?P<station_name>[^]]*)\s*\])?",
|
||||
dataline,
|
||||
)
|
||||
if res:
|
||||
res = res.groupdict()
|
||||
year = int(res["year"])
|
||||
|
||||
completion = res["completion"]
|
||||
station_name = res["station_name"]
|
||||
if not completion and station_name:
|
||||
if station_name.startswith("<a href"):
|
||||
completion = station_name
|
||||
station_name = ""
|
||||
if completion and not station_name:
|
||||
if not ticked:
|
||||
station_name = completion
|
||||
|
||||
if completion:
|
||||
completion = completion.replace("<a href=\"","<a href=\"/1623/161/")
|
||||
nearest_station_name = ""
|
||||
resolution_station_name = ""
|
||||
if res["station_name"]:
|
||||
if station_name:
|
||||
if ticked:
|
||||
resolution_station_name = res["station_name"].replace("<a href=\"","<a href=\"/1623/161/")
|
||||
resolution_station_name = station_name.replace("<a href=\"","<a href=\"/1623/161/")
|
||||
else:
|
||||
nearest_station_name = res["station_name"]
|
||||
nearest_station_name = station_name.replace("<a href=\"","<a href=\"/1623/161/")
|
||||
lookupAttribs = {
|
||||
#'found_by':placeholder,
|
||||
"blockname": "",
|
||||
@ -172,7 +184,7 @@ def parse_KH_QMs(kh, inputFile, ticked):
|
||||
nonLookupAttribs = {
|
||||
"ticked": ticked,
|
||||
"page_ref": "",
|
||||
"completion_description": "",
|
||||
"completion_description": completion,
|
||||
"nearest_station_name": nearest_station_name,
|
||||
"resolution_station_name": resolution_station_name,
|
||||
"location_description": res["location_description"].replace("<a href=\"","<a href=\"/1623/161/"),
|
||||
|
@ -28,8 +28,10 @@
|
||||
<ul>{% for QM in cave.get_open_QMs %}
|
||||
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a>
|
||||
{% if QM.nearest_station_name %}§<em>{{QM.nearest_station_name|safe}}</em>§{% endif %}
|
||||
{{QM.location_description}} <b>{{QM.grade}}</b>
|
||||
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date}} {% endif %}</li>
|
||||
{{QM.location_description|safe}} <b>{{QM.grade}}</b>
|
||||
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date|date:'Y-m-d'}} {% endif %}
|
||||
{% if QM.comment %}
|
||||
<span style="color:red;">{{QM.comment}}</span>{% endif %}
|
||||
{% empty %}
|
||||
<li>No open leads.
|
||||
{% endfor %}
|
||||
@ -43,14 +45,15 @@
|
||||
{% if QM.nearest_station_name %}§<em>{{QM.nearest_station_name|safe}}</em>§{% endif %}
|
||||
{% if QM.resolution_station_name %}<b>☆<em>{{QM.resolution_station_name|safe}}</em>☆</b>{% endif %}
|
||||
{{QM.location_description|safe}} <b>{{QM.grade}}</b>
|
||||
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date}} {% endif %}
|
||||
|
||||
|
||||
|
||||
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date|date:'Y-m-d'}} {% endif %}
|
||||
{% if QM.completion_description %}
|
||||
Completion page: <a href="/{{QM.get_completion_url}}">{{QM.completion_description}}</a>
|
||||
⋮<em>{{QM.completion_description|safe}}</em>⋮
|
||||
{% endif %}
|
||||
{% if QM.page_ref %}☉<em><a href="/{{QM.cave.url_parent}}/{{QM.page_ref}}">{{QM.page_ref}}</a></em>☉{% endif %}
|
||||
{% if QM.comment %}
|
||||
Comment: <a href="/{{QM.get_completion_url}}">{{QM.comment}}</a>
|
||||
{% endif %}
|
||||
<span style="color:red;">{{QM.comment}}</span>{% endif %}
|
||||
{% empty %}
|
||||
<li>No ticked leads.
|
||||
{% endfor %}
|
||||
@ -58,4 +61,7 @@
|
||||
</p>
|
||||
§ QM.nearest_station_name<br />
|
||||
☆ QM.resolution_station_name - when ticked.<br />
|
||||
☉ QM.page_ref<br />
|
||||
⋮ QM.completion_description<br />
|
||||
<span style="color:red;">QM.comment</span><br />
|
||||
{% endblock %}
|
@ -26,12 +26,11 @@
|
||||
{% if qm.resolution_station_name %}
|
||||
The survey station which record the continuation of the cave past this QM is <b>{{qm.resolution_station_name}}</b>.<br />
|
||||
{%endif %}
|
||||
Tick off comment: '{{qm.comment}}'</a> <br />
|
||||
Tick off completion description: '{{qm.completion_description}}' </a> <br />
|
||||
Tick off url: <a href="/{{qm.get_completion_url}}">{{qm.get_completion_url}}</a> WRONG <br />
|
||||
Tick off date: '{{qm.completion_date}}' [For survex file ticks. not implemented yet]</a> <br />
|
||||
Tick off comment: '{{qm.comment|safe}}'</a> <br />
|
||||
Tick off completion description: '{{qm.completion_description|safe}}' </a> <br />
|
||||
Tick off date: '{{qm.completion_date|date:'Y-m-d'}}' [For survex file ticks. not implemented yet]</a> <br />
|
||||
{% endif %}
|
||||
QM page_ref: '{{qm.page_ref}}'<br>
|
||||
QM page_ref: '{{qm.page_ref|safe}}'<br>
|
||||
|
||||
{% if qm.cave %}
|
||||
<h3>Cave: {{qm.cave|safe }}</h3>
|
||||
@ -50,7 +49,7 @@ Comment: '{{qm.comment}}'</a> <br />
|
||||
|
||||
{% if qm.block %}
|
||||
<h3>Survexfile</h3>
|
||||
{{qm.block.date}} <a href="/survexfile/{{qm.block.survexfile.path}}.svx">{{qm.block}}.svx</a>
|
||||
{{qm.block.date|date:'Y-m-d'}} <a href="/survexfile/{{qm.block.survexfile.path}}.svx">{{qm.block}}.svx</a>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user