Merge main into places-ship-2

This commit is contained in:
swaits committed 2026-11-20 11:07:24 -07:00
commit 1fbcfd5021
126 files changed
+2076 -9

No files matched your search

+24
View File
@@ -185,6 +185,30 @@ def season_text(rec):
return words.join_names(MONTHS[m - 1] for m in ms)
SEASON_BASIS_TEXT = {
"primary": "The season comes from the page of the body that manages the trail or the trail's own association or, for a route, its author.",
"sources": "Two or more pages from different publishers agree on the season.",
"source": "One page states the season. It is not the trail's own page.",
}
def season_basis(rec):
"""Where the season came from: primary, sources, source or estimate; "" when it has none."""
h = hike.table(rec)
if not h.get("season") and not h.get("months"):
return ""
return h.get("season_basis") or ""
def season_basis_line(rec):
"""One sentence for "About this data"; "" when the season has no recorded basis."""
basis = season_basis(rec)
if basis == "estimate":
method = (hike.table(rec).get("season_method") or "").strip()
return (method + " No page states a season.").strip()
return SEASON_BASIS_TEXT.get(basis, "")
# Terrain, Walking, Shape ----------------------------------------------------
TERRAIN_VALUES = words.TERRAIN
+3 -1
View File
@@ -1577,7 +1577,9 @@ def hike_sources_block(rec):
body = f'<ul class="linklist">{items}</ul>' if items else \
'<p class="record-text">The record names no page for these facts.</p>'
checked = f'<p class="note">Checked {esc(h["checked"])}.</p>' if h.get("checked") else ""
return block("hike-title", "Where the hiking facts come from", Markup(body + checked))
basis = facets.season_basis_line(rec)
basis = f'<p class="note">{esc(basis)}</p>' if basis else ""
return block("hike-title", "Where the hiking facts come from", Markup(body + checked + basis))
def about_data(rec, site, author_links=None):
+12
View File
@@ -125,6 +125,18 @@ class TrailPageTest(unittest.TestCase):
self.assertTrue(trail.description(rec).startswith(
"A trail of 62 miles (100 km) in Arizona, usually 5 to 7 months. A long walk along the crest"))
def test_about_this_data_says_where_the_season_came_from(self):
from olt import facets
rec = sample_record("X Trail")
rec["hike"] = dict(FULL_HIKE, season_basis="primary")
block = trail.hike_sources_block(rec)
self.assertIn("The season comes from the page of the body that manages the trail or the trail's own association or, for a route, its author.",
html.unescape(block))
self.assertEqual(facets.season_basis(rec), "primary")
rec["hike"] = {k: v for k, v in FULL_HIKE.items() if k not in ("season", "months")}
self.assertNotIn("The season comes from", trail.hike_sources_block(rec))
self.assertEqual(facets.season_basis(rec), "")
def test_partial_hike_table(self):
rec = sample_record("X Trail")
rec["hike"] = {"shape": "loop", "start": "Lake Camp", "days": [4, 6], "checked": "2026-11-13"}