campingmontagut/deploy/setup_location.sql
jordi fita mas ff6e9497b5 Replace contact page with location
Customer does not want a contact page, but a page where they can write
the direction on how to reach the campground, with a Google map embed
instead of using Leaflet, because Google Maps shows the reviews right
in the map.

That means i had to replace the GPS locations with XML fields for the
customer to write.  In all four languages.

This time i tried a translation approach inspired by PrestaShop: instead
of opening a new page for each language, i have all languages in the
same page and use AlpineJS to show just a single language.  It is far
easier to write the translations, even though you do not have the source
text visible, specially in this section that there is no place for me
to put the language links.
2023-12-21 21:17:04 +01:00

27 lines
811 B
PL/PgSQL

-- Deploy camper:setup_location to pg
-- requires: roles
-- requires: schema_camper
-- requires: location
begin;
set search_path to camper, public;
create or replace function setup_location(company integer, directions text, map_embed text, opening_dates text) returns void as
$$
insert into location (company_id, directions, map_embed, opening_dates)
values (company, xmlparse(content directions), xmlparse(content map_embed), xmlparse(content opening_dates))
on conflict (company_id) do update
set directions = excluded.directions
, map_embed = excluded.map_embed
, opening_dates = excluded.opening_dates
;
$$
language sql
;
revoke execute on function setup_location(integer, text, text, text) from public;
grant execute on function setup_location(integer, text, text, text) to admin;
commit;