add colonne
build / build (push) Failing after 36s

This commit is contained in:
hcornet committed 2026-09-22 15:09:24 +02:00
1 parent 3b641ff555
commit cc3a134675
4 files changed
+30 -2

No files matched your search

+14
View File
@@ -6,6 +6,7 @@ from sqlalchemy import func, select
from sqlalchemy.orm import Session
from app.database import get_db
from app.hierarchy import DIMENSION_LEVEL, level
from app.models import Character, Episode, Location
from app.routers import characters, episodes, locations
from app.routers.common import parse_page
@@ -43,6 +44,9 @@ def _page(request: Request, fetch, page: str | None, **filters):
VIEWS = ("images", "liste")
# Sous-colonne « Planète » de la liste des épisodes (lieux liés directement à l'épisode)
PLANET_TYPES = ("planet", "dwarf planet (celestial dwarf)")
# Sections de la fiche épisode : (clé de characters_by_role, titre affiché)
SECTIONS = (
("major", "Major characters"),
@@ -186,6 +190,16 @@ def episodes_page(
db: Session = Depends(get_db),
):
context = _page(request, episodes.list_episodes, page, name=name, episode=episode, db=db)
urls = sorted({u for e in context["results"] for u in e.locations})
types = {loc.url: loc.type for loc in _by_ids(locations.get_locations, db, urls)}
context["place_counts"] = {
e.id: {
"total": len(e.locations),
"dimension": sum(level(types.get(u, "")) == DIMENSION_LEVEL for u in e.locations),
"planet": sum(types.get(u, "").strip().lower() in PLANET_TYPES for u in e.locations),
}
for e in context["results"]
}
return render(request, "episodes.html", context)
+10
View File
@@ -104,3 +104,13 @@ def test_episode_page_tree(seeded):
assert html.count('class="ghost"') == 3
page = seeded.get(f"/locations/{house}").text
assert "Contenu dans (2)" in page and "Contient (0)" in page
def test_episodes_list_counts_locations(seeded):
dim = create(seeded, "Dimension C-137", "Dimension")
house = create(seeded, "Smith Residence", "Residence", parents=[loc(1)])
for i in (dim, 1, house, 3): # 1 = Planet, 3 = Space station
seeded.put(f"/api/episode/1/locations/{i}")
html = seeded.get("/episodes").text
assert "Planète" in html
row = html[html.index('href="/episodes/1"') :].split("</tr>")[0]
assert [c.split(">")[-1] for c in row.split("</td>")[-4:-1]] == ["4", "1", "1"]
+3
View File
@@ -58,6 +58,9 @@ ul.tree.d2{background:var(--lvl2);border-color:var(--lvl2b)}
ul.tree.d3{background:var(--lvl3);border-color:var(--lvl3b)}
ul.tree.d4{background:var(--lvl4);border-color:var(--lvl4b)}
.small{font-size:.85rem}
th.group{text-align:center;border-left:1px solid var(--line)}
th.num,td.num{text-align:center}
th.sub,td.sub{border-left:1px solid var(--line)}
@media (max-width:600px){table.list .wide{display:none}}
</style>
</head>
+3 -2
View File
@@ -10,8 +10,9 @@
</form>
{% if results %}
<table>
<tr><th>Code</th><th>Titre</th><th>Diffusion</th><th>Characters</th></tr>
{% for e in results %}<tr><td>{{ e.episode }}</td><td><a href="/episodes/{{ e.id }}">{{ e.name }}</a></td><td>{{ e.air_date }}</td><td>{{ e.characters | length }}</td></tr>{% endfor %}
<tr><th rowspan="2">Code</th><th rowspan="2">Titre</th><th rowspan="2">Diffusion</th><th rowspan="2" class="num">Characters</th><th colspan="3" class="group">Locations</th></tr>
<tr><th class="num sub">Total</th><th class="num sub">Dimension</th><th class="num sub">Planète</th></tr>
{% for e in results %}{% set n = place_counts[e.id] %}<tr><td>{{ e.episode }}</td><td><a href="/episodes/{{ e.id }}">{{ e.name }}</a></td><td>{{ e.air_date }}</td><td class="num">{{ e.characters | length }}</td><td class="num sub">{{ n.total }}</td><td class="num">{{ n.dimension }}</td><td class="num">{{ n.planet }}</td></tr>{% endfor %}
</table>
{{ pager(page, pages, prev_url, next_url) }}
{% else %}<p class="muted">Aucun résultat.</p>{% endif %}