campingmontagut/deploy/edit_amenity.sql
jordi fita mas eeaa3b415e Add amenities section and public page
This is more or less the same as the campsites, as public information
goes, but for buildings and other amenities that the camping provides
that are not campsites.
2024-01-27 22:51:41 +01:00

28 lines
767 B
PL/PgSQL

-- Deploy camper:edit_amenity to pg
-- requires: roles
-- requires: schema_camper
-- requires: amenity
begin;
set search_path to camper, public;
create or replace function edit_amenity(amenity_id integer, new_label text, new_name text, new_info1 text, new_info2 text, active boolean) returns integer as
$$
update amenity
set label = new_label
, name = new_name
, info1 = xmlparse(content new_info1)
, info2 = xmlparse(content new_info2)
, active = edit_amenity.active
where amenity_id = edit_amenity.amenity_id
returning amenity_id;
$$
language sql
;
revoke execute on function edit_amenity(integer, text, text, text, text, boolean) from public;
grant execute on function edit_amenity(integer, text, text, text, text, boolean) to admin;
commit;