Badges : corrections de lint (E501) et couverture du smoke test
Lignes trop longues détectées par ruff (badges.py, tests) ; ajout de /badges au smoke test frontend (rendu SSR de chaque écran protégé). Vérifié dans ce commit : pytest (248 passés), ruff check, alembic check, tsc --noEmit, eslint, vite build, smoke — tous verts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
579ea5d9db
commit
bc165757ca
@@ -226,14 +226,18 @@ AssignmentRow = tuple[Position, Shift, Volunteer | None] # (poste, créneau, r
|
|||||||
|
|
||||||
|
|
||||||
def _role_label(volunteer_id: uuid.UUID, lead_volunteer_ids: set[uuid.UUID]) -> str:
|
def _role_label(volunteer_id: uuid.UUID, lead_volunteer_ids: set[uuid.UUID]) -> str:
|
||||||
return t("badge.role.referent") if volunteer_id in lead_volunteer_ids else t("badge.role.volunteer")
|
if volunteer_id in lead_volunteer_ids:
|
||||||
|
return t("badge.role.referent")
|
||||||
|
return t("badge.role.volunteer")
|
||||||
|
|
||||||
|
|
||||||
def _category_label(category) -> str:
|
def _category_label(category) -> str:
|
||||||
return t(f"position.category.{category.value.lower()}")
|
return t(f"position.category.{category.value.lower()}")
|
||||||
|
|
||||||
|
|
||||||
def _position_line(position: Position, shift: Shift, referent: Volunteer | None, volunteer_id: uuid.UUID) -> str:
|
def _position_line(
|
||||||
|
position: Position, shift: Shift, referent: Volunteer | None, volunteer_id: uuid.UUID
|
||||||
|
) -> str:
|
||||||
"""Une ligne par créneau affecté : poste + horaire, et le référent du
|
"""Une ligne par créneau affecté : poste + horaire, et le référent du
|
||||||
poste s'il y en a un — sauf si le bénévole badgé est lui-même ce
|
poste s'il y en a un — sauf si le bénévole badgé est lui-même ce
|
||||||
référent (pas besoin de se l'indiquer à soi-même)."""
|
référent (pas besoin de se l'indiquer à soi-même)."""
|
||||||
@@ -258,7 +262,9 @@ def _field_text(
|
|||||||
for position, shift, referent in assignments
|
for position, shift, referent in assignments
|
||||||
)
|
)
|
||||||
if field.field_type == BadgeFieldType.CATEGORY:
|
if field.field_type == BadgeFieldType.CATEGORY:
|
||||||
categories = sorted({_category_label(position.category) for position, _shift, _r in assignments})
|
categories = sorted(
|
||||||
|
{_category_label(position.category) for position, _shift, _r in assignments}
|
||||||
|
)
|
||||||
return ", ".join(categories)
|
return ", ".join(categories)
|
||||||
if field.field_type == BadgeFieldType.ROLE:
|
if field.field_type == BadgeFieldType.ROLE:
|
||||||
return _role_label(volunteer.id, lead_volunteer_ids)
|
return _role_label(volunteer.id, lead_volunteer_ids)
|
||||||
@@ -315,7 +321,9 @@ def generate_badges(
|
|||||||
BadgeSpec(
|
BadgeSpec(
|
||||||
fields=tuple(
|
fields=tuple(
|
||||||
BadgeFieldSpec(
|
BadgeFieldSpec(
|
||||||
text=_field_text(field, volunteer, assignments_by_volunteer, lead_volunteer_ids),
|
text=_field_text(
|
||||||
|
field, volunteer, assignments_by_volunteer, lead_volunteer_ids
|
||||||
|
),
|
||||||
x_mm=field.x_mm,
|
x_mm=field.x_mm,
|
||||||
y_mm=field.y_mm,
|
y_mm=field.y_mm,
|
||||||
width_mm=field.width_mm,
|
width_mm=field.width_mm,
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ def _position(**kw) -> Position:
|
|||||||
|
|
||||||
|
|
||||||
def _shift(start: dt.datetime, end: dt.datetime) -> Shift:
|
def _shift(start: dt.datetime, end: dt.datetime) -> Shift:
|
||||||
return Shift(id=uuid.uuid4(), edition_id=uuid.uuid4(), position_id=uuid.uuid4(), starts_at=start, ends_at=end)
|
return Shift(
|
||||||
|
id=uuid.uuid4(), edition_id=uuid.uuid4(), position_id=uuid.uuid4(),
|
||||||
|
starts_at=start, ends_at=end,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_position_line_shows_the_schedule():
|
def test_position_line_shows_the_schedule():
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ def test_day_part_before_the_day_boundary_rolls_to_the_next_calendar_day(client,
|
|||||||
shifts = client.get(
|
shifts = client.get(
|
||||||
f"/editions/{edition.id}/shifts", params={"position_id": position["id"]}
|
f"/editions/{edition.id}/shifts", params={"position_id": position["id"]}
|
||||||
).json()
|
).json()
|
||||||
nuit_shifts = [s for s in shifts if dt.time.fromisoformat(s["starts_at"][11:19]) == dt.time(2, 0)]
|
nuit_shifts = [
|
||||||
|
s for s in shifts if dt.time.fromisoformat(s["starts_at"][11:19]) == dt.time(2, 0)
|
||||||
|
]
|
||||||
assert len(nuit_shifts) == 4
|
assert len(nuit_shifts) == 4
|
||||||
|
|
||||||
nuit_dates = sorted(dt.date.fromisoformat(s["starts_at"][:10]) for s in nuit_shifts)
|
nuit_dates = sorted(dt.date.fromisoformat(s["starts_at"][:10]) for s in nuit_shifts)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import type { AccountRead } from '@/api/schema';
|
|||||||
import { queryKeys } from '@/api/hooks';
|
import { queryKeys } from '@/api/hooks';
|
||||||
import { AuthContext, AuthProvider, type AuthContextValue } from '@/auth/auth-context';
|
import { AuthContext, AuthProvider, type AuthContextValue } from '@/auth/auth-context';
|
||||||
import { routes } from '@/app/router';
|
import { routes } from '@/app/router';
|
||||||
|
import { BadgesPage } from '@/pages/BadgesPage';
|
||||||
import { ConfigPage } from '@/pages/ConfigPage';
|
import { ConfigPage } from '@/pages/ConfigPage';
|
||||||
import { GrillePage } from '@/pages/GrillePage';
|
import { GrillePage } from '@/pages/GrillePage';
|
||||||
import { MobileLeadPage } from '@/pages/MobileLeadPage';
|
import { MobileLeadPage } from '@/pages/MobileLeadPage';
|
||||||
@@ -156,6 +157,7 @@ if (coordinator) {
|
|||||||
await renderProtected('/grille', coordinator, createElement(GrillePage));
|
await renderProtected('/grille', coordinator, createElement(GrillePage));
|
||||||
await renderProtected('/benevoles', coordinator, createElement(VolunteerViewPage));
|
await renderProtected('/benevoles', coordinator, createElement(VolunteerViewPage));
|
||||||
await renderProtected('/configuration', coordinator, createElement(ConfigPage));
|
await renderProtected('/configuration', coordinator, createElement(ConfigPage));
|
||||||
|
await renderProtected('/badges', coordinator, createElement(BadgesPage));
|
||||||
}
|
}
|
||||||
if (volunteerAccount) {
|
if (volunteerAccount) {
|
||||||
const vid = volunteerAccount.volunteer_id as string;
|
const vid = volunteerAccount.volunteer_id as string;
|
||||||
|
|||||||
Reference in New Issue
Block a user