Fit the guide change to the catalogue: Siskiyou Peaks guide, Circle of Solitude sources, and honest no-GPX wording
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
1601f7c755
commit
978514a43e
7 files changed
+67
-13
No files matched your search
@@ -292,6 +292,11 @@ def gpx_status_text(rec):
|
||||
status = gpx(rec)
|
||||
if status == "sold" and not common.sells_gpx(rec):
|
||||
return "Not here, sold as a guide"
|
||||
if status == "elsewhere":
|
||||
# What the page really offers is read from the same link the page's button uses.
|
||||
from . import trail
|
||||
return {"guide": "Not here, see the guide", "": "Not here"}.get(trail.see_kind(rec),
|
||||
GPX_STATUS[status])
|
||||
return GPX_STATUS[status]
|
||||
|
||||
|
||||
|
||||
@@ -196,6 +196,15 @@ def sold_guide_page(rec, url):
|
||||
GUIDE_LABELS = set(LINK_IS_TEXT.values()) | {"The guide's page", "The route's guide"}
|
||||
|
||||
|
||||
def see_kind(rec):
|
||||
"""What a page with no GPX here sends the reader to: "guide" when its link is a guide's,
|
||||
"" when it has no link at all, else "official"."""
|
||||
link = official_link(rec)
|
||||
if not link:
|
||||
return ""
|
||||
return "guide" if link[1] in GUIDE_LABELS else "official"
|
||||
|
||||
|
||||
def _see_clause(rec):
|
||||
"""", so see the official site", or ", so see the guide" when the page on offer is a guide's."""
|
||||
link = official_link(rec)
|
||||
|
||||
@@ -83,6 +83,21 @@ class ExactGuideTest(unittest.TestCase):
|
||||
rec["guide"] = [dict(BOOK, access="free", url="https://author.example/route", link_is="author")]
|
||||
self.assertEqual(trail.official_link(rec)[1], "Official site")
|
||||
|
||||
def test_the_no_gpx_wording_follows_what_the_page_offers(self):
|
||||
from olt import facets
|
||||
unclear = {"creator": "A", "line_policy": "unclear"}
|
||||
rec = route(hike={"official_url": "https://author.example/route"}, route=unclear)
|
||||
self.assertEqual(facets.gpx(rec), "elsewhere")
|
||||
self.assertEqual(facets.gpx_status_text(rec), "Not here, see the official site")
|
||||
rec = route(hike={"official_url": "https://shop.example/sierra-south"}, route=unclear)
|
||||
self.assertEqual(facets.gpx_status_text(rec), "Not here, see the guide")
|
||||
rec = route(route=unclear)
|
||||
self.assertEqual(facets.gpx_status_text(rec), "Not here, see the guide")
|
||||
rec = route(route=unclear, guide=None)
|
||||
rec["guide"] = []
|
||||
self.assertEqual(facets.gpx_status_text(rec), "Not here")
|
||||
self.assertNotIn("official site", facets.gpx_status_text(route(route=unclear)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -154,7 +154,7 @@ class TrailPageTest(unittest.TestCase):
|
||||
self.assertNotIn("Where the hiking facts come from", body)
|
||||
# no track: the page says so plainly and points at the source
|
||||
self.assertIn("No GPX here", t)
|
||||
self.assertIn("GPX Not here, see the official site", t)
|
||||
self.assertIn("GPX Not here", t)
|
||||
self.assertIn('href="#track"', top)
|
||||
self.assertIn('id="track"', top)
|
||||
|
||||
|
||||
Reference in new issue
Block a user