fix(app): grant expiry ends the chosen day in Paris; species order 0..9999 (V1-2.5 L2)
Owner checkpoint 2026-11-02: expiry 23:59:59.999 Europe/Paris (picker, validation, display), tests under non-Paris zones and DST days; M7 redefines create_species and update_inactive_species with the range check; pgTAP 015 and 022; « Relecteur ou relectrice »; object_conflict EN; setup key selectable, no Copy.
This commit is contained in:
1 parent
4111efa1d1
commit
51225cacf6
17 files changed
+437
-61
No files matched your search
@@ -13,8 +13,10 @@
|
||||
-- rounds, with the names of the people who acted.
|
||||
-- Capability holders at aal2 only (`caller_is_catalog_staff`, the predicate
|
||||
-- of the draft reads); an unknown or forbidden sheet gets one answer. No
|
||||
-- write, no grant, no policy and no rule changes here. Also: `get_sheet_version`
|
||||
-- returns the fingerprint of a deprecated version (§10, BDR-098).
|
||||
-- table, grant, policy or rule changes here. Also: `get_sheet_version`
|
||||
-- returns the fingerprint of a deprecated version (§10, BDR-098); and
|
||||
-- `create_species` / `update_inactive_species` refuse a sort order outside
|
||||
-- 0..9 999 (owner 2026-11-02), their privileges restated.
|
||||
|
||||
-- ===========================================================================
|
||||
-- 1. Helpers
|
||||
@@ -247,3 +249,68 @@ grant execute on function public.get_official_sheet_admin(uuid) to authenticated
|
||||
-- Kept by `create or replace`, stated again so this file stands alone.
|
||||
revoke all on function public.get_sheet_version(uuid) from public, anon, service_role;
|
||||
grant execute on function public.get_sheet_version(uuid) to authenticated;
|
||||
|
||||
-- ===========================================================================
|
||||
-- 5. Species order range (owner 2026-11-02)
|
||||
-- ===========================================================================
|
||||
-- The M5 bodies, with the sort order bounded 0..9 999 (null keeps today's
|
||||
-- meaning: the default 100 on creation, the stored value on update).
|
||||
create or replace function public.create_species(id text, name_fr text, name_en text, sort_order integer default 100)
|
||||
returns text
|
||||
language plpgsql
|
||||
volatile
|
||||
security definer
|
||||
set search_path = ''
|
||||
as $$
|
||||
#variable_conflict use_column
|
||||
declare
|
||||
v_actor uuid := private.require_capability('sheet_editor');
|
||||
begin
|
||||
if create_species.id is null or create_species.id !~ '^[a-z0-9][a-z0-9_-]{0,63}$' or create_species.id = 'other'
|
||||
or char_length(name_fr) not between 1 and 80 or char_length(name_en) not between 1 and 80
|
||||
or (create_species.sort_order is not null and create_species.sort_order not between 0 and 9999) then
|
||||
raise exception 'invalid_input' using errcode = 'P0001';
|
||||
end if;
|
||||
if exists (select 1 from public.species s where s.id = create_species.id) then
|
||||
raise exception 'species.exists' using errcode = 'P0001';
|
||||
end if;
|
||||
perform private.consume_catalog_write_budget(v_actor);
|
||||
insert into public.species (id, name_fr, name_en, sort_order, active)
|
||||
values (create_species.id, name_fr, name_en, coalesce(sort_order, 100), false);
|
||||
perform private.log_event(v_actor, 'species.created', 'species', null, null, null,
|
||||
jsonb_build_object('id', create_species.id));
|
||||
return create_species.id;
|
||||
end;
|
||||
$$;
|
||||
|
||||
create or replace function public.update_inactive_species(id text, name_fr text, name_en text, sort_order integer)
|
||||
returns text
|
||||
language plpgsql
|
||||
volatile
|
||||
security definer
|
||||
set search_path = ''
|
||||
as $$
|
||||
#variable_conflict use_column
|
||||
declare
|
||||
v_actor uuid := private.require_capability('sheet_editor');
|
||||
begin
|
||||
if char_length(name_fr) not between 1 and 80 or char_length(name_en) not between 1 and 80
|
||||
or (update_inactive_species.sort_order is not null and update_inactive_species.sort_order not between 0 and 9999) then
|
||||
raise exception 'invalid_input' using errcode = 'P0001';
|
||||
end if;
|
||||
perform 1 from public.species s where s.id = update_inactive_species.id and not s.active for update;
|
||||
if not found then
|
||||
raise exception 'species.not_inactive' using errcode = 'P0001';
|
||||
end if;
|
||||
perform private.consume_catalog_write_budget(v_actor);
|
||||
update public.species s set name_fr = update_inactive_species.name_fr, name_en = update_inactive_species.name_en,
|
||||
sort_order = coalesce(update_inactive_species.sort_order, s.sort_order) where s.id = update_inactive_species.id;
|
||||
perform private.log_event(v_actor, 'species.updated', 'species', null, null, null, jsonb_build_object('id', update_inactive_species.id));
|
||||
return update_inactive_species.id;
|
||||
end;
|
||||
$$;
|
||||
|
||||
revoke all on function public.create_species(text, text, text, integer) from public, anon, service_role;
|
||||
revoke all on function public.update_inactive_species(text, text, text, integer) from public, anon, service_role;
|
||||
grant execute on function public.create_species(text, text, text, integer) to authenticated;
|
||||
grant execute on function public.update_inactive_species(text, text, text, integer) to authenticated;
|
||||
Reference in new issue
Block a user