Say that permits are not on file when a trail's record has none
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f58103a45
commit
92ee879399
2 files changed
+24
-5
No files matched your search
+9
-3
@@ -606,6 +606,11 @@ def time_note(rec, records):
|
|||||||
return Markup(f"{note} {list_anchor(records, key, text)}" if note else str(list_anchor(records, key, text)))
|
return Markup(f"{note} {list_anchor(records, key, text)}" if note else str(list_anchor(records, key, text)))
|
||||||
|
|
||||||
|
|
||||||
|
# A trail with no permit sentence in its record has no row for it, as with season, terrain and walking:
|
||||||
|
# the panel's note says the fact is not on file, so a missing row is not read as "no permit needed".
|
||||||
|
PERMITS = "Permits"
|
||||||
|
|
||||||
|
|
||||||
def glance(rec, records=None):
|
def glance(rec, records=None):
|
||||||
"""The hiker's facts at a glance, under the attribute names every page uses.
|
"""The hiker's facts at a glance, under the attribute names every page uses.
|
||||||
|
|
||||||
@@ -664,7 +669,7 @@ def glance(rec, records=None):
|
|||||||
for t in terrain))
|
for t in terrain))
|
||||||
rows.append(glance_row(facets.TERRAIN, names, wide=True))
|
rows.append(glance_row(facets.TERRAIN, names, wide=True))
|
||||||
if h.get("permit"):
|
if h.get("permit"):
|
||||||
rows.append(glance_row("Permits", common.sentence(h["permit"]), wide=True))
|
rows.append(glance_row(PERMITS, common.sentence(h["permit"]), wide=True))
|
||||||
country = " and ".join(words.COUNTRIES.get(c, c) for c in common.countries(rec))
|
country = " and ".join(words.COUNTRIES.get(c, c) for c in common.countries(rec))
|
||||||
rows.append(glance_row(facets.WHERE, Markup(f'{region_names(rec)}, {esc(country)}'), wide=True))
|
rows.append(glance_row(facets.WHERE, Markup(f'{region_names(rec)}, {esc(country)}'), wide=True))
|
||||||
status = facets.gpx(rec)
|
status = facets.gpx(rec)
|
||||||
@@ -688,11 +693,12 @@ def glance(rec, records=None):
|
|||||||
if h.get("unfinished"):
|
if h.get("unfinished"):
|
||||||
unfinished = f'<p class="glance__warn"><strong>Not finished.</strong> {common.rich(common.sentence(h["unfinished"]))}</p>'
|
unfinished = f'<p class="glance__warn"><strong>Not finished.</strong> {common.rich(common.sentence(h["unfinished"]))}</p>'
|
||||||
missing = [name for name, have in ((facets.SEASON, season), (facets.TERRAIN, terrain),
|
missing = [name for name, have in ((facets.SEASON, season), (facets.TERRAIN, terrain),
|
||||||
(facets.WALKING, facets.walking(rec))) if not have]
|
(facets.WALKING, facets.walking(rec)),
|
||||||
|
(PERMITS, h.get("permit"))) if not have]
|
||||||
pending = ""
|
pending = ""
|
||||||
if missing:
|
if missing:
|
||||||
names = words.join_names([missing[0]] + [m.lower() for m in missing[1:]])
|
names = words.join_names([missing[0]] + [m.lower() for m in missing[1:]])
|
||||||
verb = "is" if len(missing) == 1 else "are"
|
verb = "is" if len(missing) == 1 and missing[0] != PERMITS else "are"
|
||||||
pending = f'<p class="note">{esc(names)} {verb} not on file for this trail yet.</p>'
|
pending = f'<p class="note">{esc(names)} {verb} not on file for this trail yet.</p>'
|
||||||
elev_caveat = elevation.coverage_caveat(elev) if elev else ""
|
elev_caveat = elevation.coverage_caveat(elev) if elev else ""
|
||||||
elev_note = f'<p class="note">{esc(elev_caveat)}</p>' if elev_caveat else ""
|
elev_note = f'<p class="note">{esc(elev_caveat)}</p>' if elev_caveat else ""
|
||||||
|
|||||||
+15
-2
@@ -132,7 +132,7 @@ class TrailPageTest(unittest.TestCase):
|
|||||||
t = text(top)
|
t = text(top)
|
||||||
self.assertIn("Shape Loop. Starts and ends at Lake Camp", t)
|
self.assertIn("Shape Loop. Starts and ends at Lake Camp", t)
|
||||||
self.assertIn("Time 4 to 6 days", t)
|
self.assertIn("Time 4 to 6 days", t)
|
||||||
self.assertIn("Season, terrain and walking are not on file for this trail yet.", t)
|
self.assertIn("Season, terrain, walking and permits are not on file for this trail yet.", t)
|
||||||
for absent in ("Season March", "High point", "Terrain Alpine", "Permits", "Not finished", "Official site"):
|
for absent in ("Season March", "High point", "Terrain Alpine", "Permits", "Not finished", "Official site"):
|
||||||
self.assertNotIn(absent, t, absent)
|
self.assertNotIn(absent, t, absent)
|
||||||
# no summary: the lede is built from the record
|
# no summary: the lede is built from the record
|
||||||
@@ -140,6 +140,19 @@ class TrailPageTest(unittest.TestCase):
|
|||||||
about = render(rec)[render(rec).index('<details class="about-data"'):]
|
about = render(rec)[render(rec).index('<details class="about-data"'):]
|
||||||
self.assertIn("The record names no page for these facts.", about)
|
self.assertIn("The record names no page for these facts.", about)
|
||||||
|
|
||||||
|
def test_a_missing_permit_is_said_to_be_not_on_file(self):
|
||||||
|
rec = sample_record("X Trail")
|
||||||
|
rec["hike"] = {"shape": "loop", "start": "Lake Camp", "days": [4, 6], "terrain": ["alpine"],
|
||||||
|
"travel": "trail", "months": [6, 7], "checked": "2026-11-13"}
|
||||||
|
t = text(top_part(render(rec)))
|
||||||
|
self.assertIn("Permits are not on file for this trail yet.", t)
|
||||||
|
self.assertNotIn("Permits A permit", t) # no row that could be read as "none needed"
|
||||||
|
rec["hike"]["permit"] = "No permit is needed."
|
||||||
|
t = text(top_part(render(rec)))
|
||||||
|
self.assertIn("Permits No permit is needed.", t)
|
||||||
|
self.assertNotIn("Permits are not on file", t)
|
||||||
|
self.assertNotIn("permits are not on file", t)
|
||||||
|
|
||||||
def test_no_hike_table(self):
|
def test_no_hike_table(self):
|
||||||
rec = sample_record("X Trail")
|
rec = sample_record("X Trail")
|
||||||
body = render(rec)
|
body = render(rec)
|
||||||
@@ -150,7 +163,7 @@ class TrailPageTest(unittest.TestCase):
|
|||||||
self.assertIn("Where Arizona , United States", t)
|
self.assertIn("Where Arizona , United States", t)
|
||||||
# every trail has a time: here estimated from its 100 km, and labelled so
|
# every trail has a time: here estimated from its 100 km, and labelled so
|
||||||
self.assertIn("Time About 4 to 5 days Estimated from the length, at 12 to 19 mi 20 to 30 km a day.", t)
|
self.assertIn("Time About 4 to 5 days Estimated from the length, at 12 to 19 mi 20 to 30 km a day.", t)
|
||||||
self.assertIn("Season, terrain and walking are not on file for this trail yet.", t)
|
self.assertIn("Season, terrain, walking and permits are not on file for this trail yet.", t)
|
||||||
self.assertNotIn("Where the hiking facts come from", body)
|
self.assertNotIn("Where the hiking facts come from", body)
|
||||||
# no track: the page says so plainly and points at the source
|
# no track: the page says so plainly and points at the source
|
||||||
self.assertIn("No GPX here", t)
|
self.assertIn("No GPX here", t)
|
||||||
|
|||||||
Reference in new issue
Block a user