Skip to content

Hide empty values on the species page - #185

Open
eastagiletracker wants to merge 1 commit into
jazkarta:masterfrom
eastagiletracker:agile-board/hide-empty-conservation-status
Open

Hide empty values on the species page#185
eastagiletracker wants to merge 1 commit into
jazkarta:masterfrom
eastagiletracker:agile-board/hide-empty-conservation-status

Conversation

@eastagiletracker

Copy link
Copy Markdown

This PR proposes hiding the empty "N/A" rows on the species page so that only conservation statuses that actually have a value are displayed (Fixes #111). We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/276. You can sign in with your GitHub ID to claim ownership of the project.

What was wrong

Every species page rendered a fixed set of conservation status rows, filling in N/A wherever the taxon had no value — the default_if_none:"N/A" filters on the global rank, US status, Canadian status, regional rank, regional status and wetland status cells in goorchids/site/templates/gobotany/species.html. The "Facts About" section did the same for taxa with no factoid. This is visible on the site right now — the Ghost Orchid page renders five of them:

$ curl -s https://goorchids.northamericanorchidcenter.org/species/dendrophylax/lindenii/ | grep -c '<td>N/A</td>'
5

A related detail: the region switcher was built from every RegionalConservationStatus row, so a region whose record carries no rank, status or wetland value still appeared in the drop-down and selected an all-N/A table.

The change

species_view now builds the conservation status tables it hands to the template (_conservation_status_tables), in the same spirit as the character-group structures it already assembles. A row is included only when it has a value, a table is included only when it has rows, and the region drop-down is built from the tables that survive, so a region with nothing to show is no longer offered. The template renders that structure instead of a fixed grid of cells. When a taxon has no conservation status at all, the section says so in one line rather than showing a table of N/A. Rows that do have values keep their existing labels, order and markup — including the data-region attributes and the hidden class that orchid_site/species.js toggles — so the region switcher behaves exactly as before. The "Facts About" section is now omitted when the factoid is empty instead of printing N/A.

Verifying it

Reproduced on master at f882c27 with the new tests in place and the fix reverted:

$ docker compose exec -e PYTHONDONTWRITEBYTECODE=1 goorchids python manage.py test goorchids.site
FAIL: test_ranks_without_a_value_are_left_out
AssertionError: 'US Status' unexpectedly found in ... <th>US Status</th>\n<td>N/A</td>
FAILED (failures=6)

Six of the seven new tests fail on the unmodified tree; the seventh is the control that asserts a populated "Facts About" section still renders, and stays green either way. With the change applied they all pass, and the project suite goes from 3 tests to 10 with no new failures:

$ docker compose exec -e PYTHONDONTWRITEBYTECODE=1 goorchids python manage.py test
Ran 10 tests in 0.290s
OK

The tests live in goorchids/site/tests/, following the package layout adopted for goorchids/core/tests/ in #183. They drive the real species URL through the test client and cover: ranks with no value dropped, regional statuses with no value dropped, a species with no status at all, a region that has nothing to show being left out of the switcher, every populated status still rendering (with the <option value="fl">Florida</option> markup intact), and the "Facts About" section in both states.

How this was managed

This work was tracked as a story on a board imported from this repository's own issues and pull requests — 181 stories and 6 labels: Hide N/A values on the Species page, on the Go Orchids board.

board

If you'd rather not receive contributions like this, reply no-more-prs on this pull request and we won't open any further ones on your repositories.


Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com

Conservation status rows, and the Facts About section, were rendered as
N/A when the taxon had no value for them. Build the conservation status
tables in the view instead, leaving out rows without a value, tables
that would have no rows, and regions that have nothing to show.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hide N/A values on the Species page

1 participant