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.
28 lines
918 B
PL/PgSQL
28 lines
918 B
PL/PgSQL
-- Deploy camper:translate_amenity to pg
|
|
-- requires: roles
|
|
-- requires: schema_camper
|
|
-- requires: amenity_i18n
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
create or replace function translate_amenity(amenity_id integer, lang_tag text, name text, info1 text, info2 text) returns void as
|
|
$$
|
|
insert into amenity_i18n (amenity_id, lang_tag, name, info1, info2)
|
|
values (amenity_id, lang_tag, case trim(name) when '' then null else name end, case trim(info1) when '' then null else xmlparse(content info1) end, case trim(info2) when '' then null else xmlparse(content info2) end)
|
|
on conflict (amenity_id, lang_tag)
|
|
do update
|
|
set name = excluded.name
|
|
, info1 = excluded.info1
|
|
, info2 = excluded.info2
|
|
;
|
|
$$
|
|
language sql
|
|
;
|
|
|
|
revoke execute on function translate_amenity(integer, text, text, text, text) from public;
|
|
grant execute on function translate_amenity(integer, text, text, text, text) to admin;
|
|
|
|
commit;
|