diff --git a/demo/demo.sql b/demo/demo.sql index c6a8412..a401164 100644 --- a/demo/demo.sql +++ b/demo/demo.sql @@ -127,11 +127,11 @@ select translate_services_carousel_slide(63, 'en', 'Safari Tents'); select translate_services_carousel_slide(63, 'es', 'Tiendas Safari'); alter table campsite_type alter column campsite_type_id restart with 72; -select add_campsite_type(52, 62, 'Parceŀles', '

Acampa enmig de la natura

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Parcel·les amples amb serveis a prop d’on ets per fer allò que vols.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 6, true, true, true); -select add_campsite_type(52, 63, 'Safari Tents', '

Glàmping a la teva disposició

Un luxe de tendes per viure aventures.

Dues tendes amb terra de fusta, llits, cuina i tot de comoditats per gaudir de les teves vacances.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '16 h a 21 h', '10 h', 6, false, false, false); -select add_campsite_type(52, 64, 'Bungalous', '

Allotjaments de luxe

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 5, false, false, false); -select add_campsite_type(52, 65, 'Bungalous prèmium', '

Allotjaments de luxe

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 5, false, false, false); -select add_campsite_type(52, 66, 'Cabanes de fusta', '

Allotjaments de luxe

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 5, false, false, false); +select add_campsite_type(52, 62, 'Parceŀles', '

Acampa enmig de la natura

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Parcel·les amples amb serveis a prop d’on ets per fer allò que vols.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 6, '[1, 7]', true, true, true); +select add_campsite_type(52, 63, 'Safari Tents', '

Glàmping a la teva disposició

Un luxe de tendes per viure aventures.

Dues tendes amb terra de fusta, llits, cuina i tot de comoditats per gaudir de les teves vacances.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '16 h a 21 h', '10 h', 6, '[2, 7]', false, false, false); +select add_campsite_type(52, 64, 'Bungalous', '

Allotjaments de luxe

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 5, '[2, 7]', false, false, false); +select add_campsite_type(52, 65, 'Bungalous prèmium', '

Allotjaments de luxe

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 5, '[2, 7]', false, false, false); +select add_campsite_type(52, 66, 'Cabanes de fusta', '

Allotjaments de luxe

Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.

Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.

', '

Proxo/terrassa (13 m²)

Planta baixa (32 m²)

Planta altell (16 m²)

', '

El preu inclou

* Tovalloles: preu extra

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '15 h a 21 h', '12 h', 5, '[2, 7]', false, false, false); insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, info, facilities, description, additional_info, check_in, check_out) values (72, 'en', 'Plots', '

Camp in the middle of nature

Located on the campground’s mountain-side and overlooking the nature that surrounds us.

Large plots with serivces close to where you are to do what you want.

', '

Porch/terrace (13 m²)

First floor (32 m²)

Loft floor (16 m²)

', '

Price includes

* Towels: extra cost

', '

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

', '', '3 p.m. to 9 p.m.', '12 a.m.') @@ -1231,23 +1231,21 @@ select set_season_range(94, '[2023-09-24, 2023-09-28]'); select set_season_range(93, '[2023-09-29, 2023-09-30]'); select set_season_range(94, '[2023-10-01, 2023-10-12]'); -insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) -values (72, 92, 20000, 1) - , (72, 93, 16500, 1) - , (72, 94, 12500, 1) - , (73, 92, 20000, 2) - , (73, 93, 16500, 2) - , (73, 94, 12500, 2) - , (74, 92, 20000, 2) - , (74, 93, 16500, 2) - , (74, 94, 12500, 2) - , (75, 92, 20000, 2) - , (75, 93, 16500, 2) - , (75, 94, 12500, 2) - , (76, 92, 20000, 2) - , (76, 93, 16500, 2) - , (76, 94, 12500, 2) -; +select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 72; +select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 72; +select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 72; +select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 73; +select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 73; +select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 73; +select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 74; +select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 74; +select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 74; +select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 75; +select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 75; +select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 75; +select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 76; +select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 76; +select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 76; alter table campsite_type_option alter column campsite_type_option_id restart with 102; insert into campsite_type_option (campsite_type_id, name, range) diff --git a/deploy/add_campsite_type.sql b/deploy/add_campsite_type.sql index 5130991..b7bf62a 100644 --- a/deploy/add_campsite_type.sql +++ b/deploy/add_campsite_type.sql @@ -11,18 +11,18 @@ begin; set search_path to camper, public; -drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean); +drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean); -create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean) returns uuid as +create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, bookable_nights int4range, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean) returns uuid as $$ - insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences) - values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences) + insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, bookable_nights, dogs_allowed, overflow_allowed, ask_zone_preferences) + values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, bookable_nights, dogs_allowed, overflow_allowed, ask_zone_preferences) returning slug; $$ language sql ; -revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) from public; -grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) to admin; +revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean) from public; +grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean) to admin; commit; diff --git a/deploy/add_campsite_type@v3.sql b/deploy/add_campsite_type@v3.sql new file mode 100644 index 0000000..5130991 --- /dev/null +++ b/deploy/add_campsite_type@v3.sql @@ -0,0 +1,28 @@ +-- Deploy camper:add_campsite_type to pg +-- requires: roles +-- requires: schema_camper +-- requires: campsite_type +-- requires: company +-- requires: campsite_type__check_in_out +-- requires: campsite_type__overflow_allowed +-- requires: campsite_type__ask_zone_preferences + +begin; + +set search_path to camper, public; + +drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean); + +create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean) returns uuid as +$$ + insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences) + values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences) + returning slug; +$$ + language sql +; + +revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) from public; +grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) to admin; + +commit; diff --git a/deploy/campsite_type__bookable_nights.sql b/deploy/campsite_type__bookable_nights.sql new file mode 100644 index 0000000..33c1e0c --- /dev/null +++ b/deploy/campsite_type__bookable_nights.sql @@ -0,0 +1,27 @@ +-- Deploy camper:campsite_type__bookable_nights to pg +-- requires: campsite_type +-- requires: campsite_type_cost + +begin; + +set search_path to camper, public; + +alter table campsite_type +add column bookable_nights int4range not null default '[1, 8)' constraint at_least_one_night check (not isempty(bookable_nights) and lower(bookable_nights) > 0) +; + +update campsite_type +set bookable_nights = int4range(min_nights, 8) +from campsite_type_cost +where campsite_type_cost.campsite_type_id = campsite_type.campsite_type_id +; + +--alter table campsite_type_cost +--drop column if exists min_nights +--; + +alter table campsite_type +alter column bookable_nights drop default +; + +commit; diff --git a/deploy/campsite_type_cost__-min_nights.sql b/deploy/campsite_type_cost__-min_nights.sql new file mode 100644 index 0000000..b51a9d6 --- /dev/null +++ b/deploy/campsite_type_cost__-min_nights.sql @@ -0,0 +1,11 @@ +-- Deploy camper:campsite_type_cost__-min_nights to pg +-- requires: campsite_type__bookable_nights +-- requires: set_campsite_type_cost@HEAD + +begin; + +alter table camper.campsite_type_cost +drop column if exists min_nights +; + +commit; diff --git a/deploy/edit_campsite_type.sql b/deploy/edit_campsite_type.sql index 81efa25..ceb28d7 100644 --- a/deploy/edit_campsite_type.sql +++ b/deploy/edit_campsite_type.sql @@ -11,9 +11,9 @@ begin; set search_path to camper, public; -drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean); +drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean); -create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean, active boolean) returns uuid as +create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, bookable_nights int4range, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean, active boolean) returns uuid as $$ update campsite_type set name = edit_campsite_type.name @@ -26,6 +26,7 @@ $$ , facilities = xmlparse(content edit_campsite_type.facilities) , media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id) , max_campers = edit_campsite_type.max_campers + , bookable_nights = edit_campsite_type.bookable_nights , dogs_allowed = edit_campsite_type.dogs_allowed , overflow_allowed = edit_campsite_type.overflow_allowed , ask_zone_preferences = edit_campsite_type.ask_zone_preferences @@ -36,7 +37,7 @@ $$ language sql ; -revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean) from public; -grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean) to admin; +revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean, boolean) from public; +grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean, boolean) to admin; commit; diff --git a/deploy/edit_campsite_type@v3.sql b/deploy/edit_campsite_type@v3.sql new file mode 100644 index 0000000..81efa25 --- /dev/null +++ b/deploy/edit_campsite_type@v3.sql @@ -0,0 +1,42 @@ +-- Deploy camper:edit_campsite_type to pg +-- requires: roles +-- requires: schema_camper +-- requires: campsite_type +-- requires: company +-- requires: campsite_type__check_in_out +-- requires: campsite_type__overflow_allowed +-- requires: campsite_type__ask_zone_preferences + +begin; + +set search_path to camper, public; + +drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean); + +create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean, active boolean) returns uuid as +$$ + update campsite_type + set name = edit_campsite_type.name + , spiel = xmlparse(content edit_campsite_type.spiel) + , description = xmlparse(content edit_campsite_type.description) + , info = xmlparse(content edit_campsite_type.info) + , additional_info = xmlparse(content edit_campsite_type.additional_info) + , check_in = edit_campsite_type.check_in + , check_out = edit_campsite_type.check_out + , facilities = xmlparse(content edit_campsite_type.facilities) + , media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id) + , max_campers = edit_campsite_type.max_campers + , dogs_allowed = edit_campsite_type.dogs_allowed + , overflow_allowed = edit_campsite_type.overflow_allowed + , ask_zone_preferences = edit_campsite_type.ask_zone_preferences + , active = edit_campsite_type.active + where slug = edit_campsite_type.slug + returning slug; +$$ +language sql +; + +revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean) from public; +grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean) to admin; + +commit; diff --git a/deploy/set_campsite_type_cost.sql b/deploy/set_campsite_type_cost.sql index 8322f0f..5a53c7b 100644 --- a/deploy/set_campsite_type_cost.sql +++ b/deploy/set_campsite_type_cost.sql @@ -8,21 +8,22 @@ begin; set search_path to camper, public; -create or replace function set_campsite_type_cost(slug uuid, season_id integer, min_nights integer, cost_per_night text, decimal_places integer default 2) returns void as +drop function if exists set_campsite_type_cost(uuid, integer, integer, text, integer); + +create or replace function set_campsite_type_cost(slug uuid, season_id integer, cost_per_night text, decimal_places integer default 2) returns void as $$ - insert into campsite_type_cost (campsite_type_id, season_id, min_nights, cost_per_night) - select campsite_type_id, season_id, min_nights, parse_price(cost_per_night, decimal_places) + insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) + select campsite_type_id, season_id, parse_price(cost_per_night, decimal_places) from campsite_type where campsite_type.slug = set_campsite_type_cost.slug on conflict (campsite_type_id, season_id) do update - set min_nights = excluded.min_nights - , cost_per_night = excluded.cost_per_night + set cost_per_night = excluded.cost_per_night ; $$ language sql ; -revoke execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) from public; -grant execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) to admin; +revoke execute on function set_campsite_type_cost(uuid, integer, text, integer) from public; +grant execute on function set_campsite_type_cost(uuid, integer, text, integer) to admin; commit; diff --git a/deploy/set_campsite_type_cost@v3.sql b/deploy/set_campsite_type_cost@v3.sql new file mode 100644 index 0000000..8322f0f --- /dev/null +++ b/deploy/set_campsite_type_cost@v3.sql @@ -0,0 +1,28 @@ +-- Deploy camper:set_campsite_type_cost to pg +-- requires: roles +-- requires: schema_camper +-- requires: campsite_type_cost +-- requires: parse_price + +begin; + +set search_path to camper, public; + +create or replace function set_campsite_type_cost(slug uuid, season_id integer, min_nights integer, cost_per_night text, decimal_places integer default 2) returns void as +$$ + insert into campsite_type_cost (campsite_type_id, season_id, min_nights, cost_per_night) + select campsite_type_id, season_id, min_nights, parse_price(cost_per_night, decimal_places) + from campsite_type + where campsite_type.slug = set_campsite_type_cost.slug + on conflict (campsite_type_id, season_id) do update + set min_nights = excluded.min_nights + , cost_per_night = excluded.cost_per_night + ; +$$ + language sql +; + +revoke execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) from public; +grant execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) to admin; + +commit; diff --git a/pkg/build/version.go b/pkg/build/version.go index d132957..71687b3 100644 --- a/pkg/build/version.go +++ b/pkg/build/version.go @@ -1,3 +1,3 @@ package build -const Version = "1.2~git" +const Version = "1.3~git" diff --git a/pkg/campsite/types/admin.go b/pkg/campsite/types/admin.go index 2ded84a..1baf919 100644 --- a/pkg/campsite/types/admin.go +++ b/pkg/campsite/types/admin.go @@ -167,7 +167,7 @@ func addType(w http.ResponseWriter, r *http.Request, user *auth.User, company *a } processTypeForm(w, r, user, company, conn, f, func(ctx context.Context, tx *database.Tx) error { var err error - f.Slug, err = tx.AddCampsiteType(ctx, company.ID, f.Media.Int(), f.Name[f.DefaultLang].Val, f.Spiel[f.DefaultLang].Val, f.Info[f.DefaultLang].Val, f.Facilities[f.DefaultLang].Val, f.Description[f.DefaultLang].Val, f.AdditionalInfo[f.DefaultLang].Val, f.CheckIn[f.DefaultLang].Val, f.CheckOut[f.DefaultLang].Val, f.MaxCampers.Int(), f.DogsAllowed.Checked, f.OverflowAllowed.Checked, f.AskZonePreferences.Checked) + f.Slug, err = tx.AddCampsiteType(ctx, company.ID, f.Media.Int(), f.Name[f.DefaultLang].Val, f.Spiel[f.DefaultLang].Val, f.Info[f.DefaultLang].Val, f.Facilities[f.DefaultLang].Val, f.Description[f.DefaultLang].Val, f.AdditionalInfo[f.DefaultLang].Val, f.CheckIn[f.DefaultLang].Val, f.CheckOut[f.DefaultLang].Val, f.MaxCampers.Int(), f.MinNights.Int(), f.MaxNights.Int(), f.DogsAllowed.Checked, f.OverflowAllowed.Checked, f.AskZonePreferences.Checked) if err != nil { return err } @@ -193,7 +193,7 @@ func translateTypes(ctx context.Context, tx *database.Tx, company *auth.Company, func setTypePrices(ctx context.Context, tx *database.Tx, slug string, prices map[int]*typePriceForm) error { for seasonID, p := range prices { - if err := tx.SetCampsiteTypeCost(ctx, slug, seasonID, p.MinNights.Int(), p.PricePerNight.Val); err != nil { + if err := tx.SetCampsiteTypeCost(ctx, slug, seasonID, p.PricePerNight.Val); err != nil { return err } } @@ -202,7 +202,7 @@ func setTypePrices(ctx context.Context, tx *database.Tx, slug string, prices map func editType(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, f *typeForm) { processTypeForm(w, r, user, company, conn, f, func(ctx context.Context, tx *database.Tx) error { - if _, err := tx.EditCampsiteType(ctx, f.Slug, f.Media.Int(), f.Name[f.DefaultLang].Val, f.Spiel[f.DefaultLang].Val, f.Info[f.DefaultLang].Val, f.Facilities[f.DefaultLang].Val, f.Description[f.DefaultLang].Val, f.AdditionalInfo[f.DefaultLang].Val, f.CheckIn[f.DefaultLang].Val, f.CheckOut[f.DefaultLang].Val, f.MaxCampers.Int(), f.DogsAllowed.Checked, f.OverflowAllowed.Checked, f.AskZonePreferences.Checked, f.Active.Checked); err != nil { + if _, err := tx.EditCampsiteType(ctx, f.Slug, f.Media.Int(), f.Name[f.DefaultLang].Val, f.Spiel[f.DefaultLang].Val, f.Info[f.DefaultLang].Val, f.Facilities[f.DefaultLang].Val, f.Description[f.DefaultLang].Val, f.AdditionalInfo[f.DefaultLang].Val, f.CheckIn[f.DefaultLang].Val, f.CheckOut[f.DefaultLang].Val, f.MaxCampers.Int(), f.MinNights.Int(), f.MaxNights.Int(), f.DogsAllowed.Checked, f.OverflowAllowed.Checked, f.AskZonePreferences.Checked, f.Active.Checked); err != nil { return err } if err := translateTypes(ctx, tx, company, f); err != nil { @@ -276,6 +276,8 @@ type typeForm struct { Media *form.Media Name form.I18nInput MaxCampers *form.Input + MinNights *form.Input + MaxNights *form.Input DogsAllowed *form.Checkbox OverflowAllowed *form.Checkbox AskZonePreferences *form.Checkbox @@ -292,7 +294,6 @@ type typeForm struct { type typePriceForm struct { SeasonName string PricePerNight *form.Input - MinNights *form.Input } func newTypeForm(ctx context.Context, company *auth.Company, conn *database.Conn) (*typeForm, error) { @@ -313,6 +314,14 @@ func newTypeForm(ctx context.Context, company *auth.Company, conn *database.Conn MaxCampers: &form.Input{ Name: "max_campers", }, + MinNights: &form.Input{ + Name: "min_nights", + Val: "1", + }, + MaxNights: &form.Input{ + Name: "max_nights", + Val: "7", + }, DogsAllowed: &form.Checkbox{ Name: "dogs_allowed", }, @@ -350,10 +359,6 @@ func newTypeForm(ctx context.Context, company *auth.Company, conn *database.Conn Name: fmt.Sprintf("season.%d.price_per_night", id), Val: "0", }, - MinNights: &form.Input{ - Name: fmt.Sprintf("season.%d.min_nights", id), - Val: "1", - }, } } @@ -381,6 +386,8 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl , campsite_type.check_out::text , media_id::text , max_campers::text + , lower(bookable_nights)::text + , (upper(bookable_nights) - 1)::text , dogs_allowed , overflow_allowed , ask_zone_preferences @@ -406,12 +413,38 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl , campsite_type.check_out , media_id::text , max_campers::text + , bookable_nights , dogs_allowed , overflow_allowed , ask_zone_preferences , active `, pgx.QueryResultFormats{pgx.BinaryFormatCode}, slug) - if err := row.Scan(&f.Name[f.DefaultLang].Val, &f.Spiel[f.DefaultLang].Val, &f.Info[f.DefaultLang].Val, &f.Facilities[f.DefaultLang].Val, &f.Description[f.DefaultLang].Val, &f.AdditionalInfo[f.DefaultLang].Val, &f.CheckIn[f.DefaultLang].Val, &f.CheckOut[f.DefaultLang].Val, &f.Media.Val, &f.MaxCampers.Val, &f.DogsAllowed.Checked, &f.OverflowAllowed.Checked, &f.AskZonePreferences.Checked, &f.Active.Checked, &name, &spiel, &info, &facilities, &description, &additionalInfo, &checkIn, &checkOut); err != nil { + if err := row.Scan( + &f.Name[f.DefaultLang].Val, + &f.Spiel[f.DefaultLang].Val, + &f.Info[f.DefaultLang].Val, + &f.Facilities[f.DefaultLang].Val, + &f.Description[f.DefaultLang].Val, + &f.AdditionalInfo[f.DefaultLang].Val, + &f.CheckIn[f.DefaultLang].Val, + &f.CheckOut[f.DefaultLang].Val, + &f.Media.Val, + &f.MaxCampers.Val, + &f.MinNights.Val, + &f.MaxNights.Val, + &f.DogsAllowed.Checked, + &f.OverflowAllowed.Checked, + &f.AskZonePreferences.Checked, + &f.Active.Checked, + &name, + &spiel, + &info, + &facilities, + &description, + &additionalInfo, + &checkIn, + &checkOut, + ); err != nil { return err } if err := f.Name.FillArray(name); err != nil { @@ -441,7 +474,6 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl rows, err := conn.Query(ctx, ` select season_id - , min_nights::text , to_price(cost_per_night) from campsite_type join campsite_type_cost using (campsite_type_id) @@ -454,13 +486,11 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl for rows.Next() { var seasonID int - var minNights string var pricePerNight string - if err := rows.Scan(&seasonID, &minNights, &pricePerNight); err != nil { + if err = rows.Scan(&seasonID, &pricePerNight); err != nil { return err } if p, ok := f.Prices[seasonID]; ok { - p.MinNights.Val = minNights p.PricePerNight.Val = pricePerNight } } @@ -474,6 +504,8 @@ func (f *typeForm) Parse(r *http.Request) error { f.Active.FillValue(r) f.Name.FillValue(r) f.MaxCampers.FillValue(r) + f.MinNights.FillValue(r) + f.MaxNights.FillValue(r) f.DogsAllowed.FillValue(r) f.OverflowAllowed.FillValue(r) f.AskZonePreferences.FillValue(r) @@ -487,7 +519,6 @@ func (f *typeForm) Parse(r *http.Request) error { f.Media.FillValue(r) for _, p := range f.Prices { p.PricePerNight.FillValue(r) - p.MinNights.FillValue(r) } return nil } @@ -509,17 +540,22 @@ func (f *typeForm) Valid(ctx context.Context, conn *database.Conn, l *locale.Loc v.CheckMinInteger(f.MaxCampers, 1, l.GettextNoop("Maximum number of campers must be one or greater.")) } } + if v.CheckRequired(f.MinNights, l.GettextNoop("Minimum number of nights can not be empty.")) { + if v.CheckValidInteger(f.MinNights, l.GettextNoop("Minimum number of nights must be an integer.")) { + v.CheckMinInteger(f.MinNights, 1, l.GettextNoop("Minimum number of nights must be one or greater.")) + } + } + if v.CheckRequired(f.MaxNights, l.GettextNoop("Maximum number of nights can not be empty.")) { + if v.CheckValidInteger(f.MaxNights, l.GettextNoop("Maximum number of nights must be an integer.")) && f.MinNights.Error == nil { + v.CheckMinInteger(f.MaxNights, f.MinNights.Int(), l.GettextNoop("Maximum number of nights must be equal or greater than the minimum.")) + } + } for _, p := range f.Prices { if v.CheckRequired(p.PricePerNight, l.GettextNoop("Price per night can not be empty.")) { if v.CheckValidDecimal(p.PricePerNight, l.GettextNoop("Price per night must be a decimal number.")) { v.CheckMinDecimal(p.PricePerNight, 0.0, l.GettextNoop("Price per night must be zero or greater.")) } } - if v.CheckRequired(p.MinNights, l.GettextNoop("Minimum number of nights can not be empty.")) { - if v.CheckValidInteger(p.MinNights, l.GettextNoop("Minimum number of nights must be an integer.")) { - v.CheckMinInteger(p.MinNights, 0, l.GettextNoop("Minimum number of nights must be one or greater.")) - } - } } return v.AllOK, nil } diff --git a/pkg/campsite/types/public.go b/pkg/campsite/types/public.go index 96e0b92..78b122b 100644 --- a/pkg/campsite/types/public.go +++ b/pkg/campsite/types/public.go @@ -78,12 +78,13 @@ type publicPage struct { AdditionalInfo gotemplate.HTML CheckIn string CheckOut string + MinNights int + MaxNights int } type typePrice struct { SeasonName string SeasonColor string - MinNights int PricePerNight string Options []*optionPrice } @@ -129,6 +130,8 @@ func newPublicPage(ctx context.Context, company *auth.Company, conn *database.Co , coalesce(i18n.additional_info, campsite_type.additional_info)::text as l10n_description , coalesce(i18n.check_in, campsite_type.check_in)::text as l10n_check_in , coalesce(i18n.check_out, campsite_type.check_out)::text as l10n_check_out + , lower(bookable_nights) + , upper(bookable_nights) - 1 , dogs_allowed , '3.50' as dogs_prices from campsite_type @@ -136,7 +139,20 @@ func newPublicPage(ctx context.Context, company *auth.Company, conn *database.Co where slug = $2 and active `, loc.Language, slug) - if err := row.Scan(&page.Name, &page.Spiel, &page.Info, &page.Facilities, &page.Description, &page.AdditionalInfo, &page.CheckIn, &page.CheckOut, &page.DogsAllowed, &page.DogsPrice); err != nil { + if err = row.Scan( + &page.Name, + &page.Spiel, + &page.Info, + &page.Facilities, + &page.Description, + &page.AdditionalInfo, + &page.CheckIn, + &page.CheckOut, + &page.MinNights, + &page.MaxNights, + &page.DogsAllowed, + &page.DogsPrice, + ); err != nil { return nil, err } if err := conn.QueryRow(ctx, "select to_price(tourist_tax, $1) from company where company_id = $2", company.DecimalDigits, company.ID).Scan(&page.TouristTax); err != nil { @@ -150,7 +166,6 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T rows, err := conn.Query(ctx, ` select coalesce(i18n.name, season.name) as l10n_name , to_color(season.color)::text - , coalesce(cost.min_nights, 1) , to_price(coalesce(cost.cost_per_night, 0)) , array_agg((coalesce(option_i18n.name, option.name), to_price(coalesce(option_cost.cost_per_night, 0))) order by option.position) filter (where option.campsite_type_option_id is not null) from season @@ -169,7 +184,6 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T group by i18n.name , season.name , season.color - , cost.min_nights , cost.cost_per_night , season.position order by season.position, l10n_name @@ -182,7 +196,12 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T for rows.Next() { price := &typePrice{} var options database.RecordArray - if err := rows.Scan(&price.SeasonName, &price.SeasonColor, &price.MinNights, &price.PricePerNight, &options); err != nil { + if err = rows.Scan( + &price.SeasonName, + &price.SeasonColor, + &price.PricePerNight, + &options, + ); err != nil { return nil, err } for _, el := range options.Elements { diff --git a/pkg/database/funcs.go b/pkg/database/funcs.go index 512cad3..913a253 100644 --- a/pkg/database/funcs.go +++ b/pkg/database/funcs.go @@ -130,12 +130,12 @@ func (c *Conn) RemoveCampsiteFeature(ctx context.Context, id int) error { return err } -func (tx *Tx) AddCampsiteType(ctx context.Context, companyID int, mediaID int, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut string, maxCampers int, dogsAllowed bool, overflowAllowed bool, askZonePreferences bool) (string, error) { - return tx.GetText(ctx, "select add_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)", companyID, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, dogsAllowed, overflowAllowed, askZonePreferences) +func (tx *Tx) AddCampsiteType(ctx context.Context, companyID int, mediaID int, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut string, maxCampers int, minNights int, maxNights int, dogsAllowed bool, overflowAllowed bool, askZonePreferences bool) (string, error) { + return tx.GetText(ctx, "select add_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, int4range($12, $13), $14, $15, $16)", companyID, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, minNights, maxNights+1, dogsAllowed, overflowAllowed, askZonePreferences) } -func (tx *Tx) EditCampsiteType(ctx context.Context, slug string, mediaID int, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut string, maxCampers int, dogsAllowed bool, overflowAllowed bool, askZonePreferences bool, active bool) (string, error) { - return tx.GetText(ctx, "select edit_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)", slug, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, dogsAllowed, overflowAllowed, askZonePreferences, active) +func (tx *Tx) EditCampsiteType(ctx context.Context, slug string, mediaID int, name string, spiel string, info string, facilities string, description string, additionalInfo string, checkIn string, checkOut string, maxCampers int, minNights int, maxNights int, dogsAllowed bool, overflowAllowed bool, askZonePreferences bool, active bool) (string, error) { + return tx.GetText(ctx, "select edit_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, int4range($12, $13), $14, $15, $16, $17)", slug, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, minNights, maxNights+1, dogsAllowed, overflowAllowed, askZonePreferences, active) } func (c *Conn) OrderCampsiteTypes(ctx context.Context, slugs []string) error { @@ -147,8 +147,8 @@ func (tx *Tx) TranslateCampsiteType(ctx context.Context, slug string, langTag la _, err := tx.Exec(ctx, "select translate_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", slug, langTag, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut) return err } -func (tx *Tx) SetCampsiteTypeCost(ctx context.Context, slug string, seasonID int, minNights int, costPerNight string) error { - _, err := tx.Exec(ctx, "select set_campsite_type_cost($1, $2, $3, $4)", slug, seasonID, minNights, costPerNight) +func (tx *Tx) SetCampsiteTypeCost(ctx context.Context, slug string, seasonID int, costPerNight string) error { + _, err := tx.Exec(ctx, "select set_campsite_type_cost($1, $2, $3)", slug, seasonID, costPerNight) return err } diff --git a/po/ca.po b/po/ca.po index 3894727..70922be 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2024-01-31 15:05+0100\n" +"POT-Creation-Date: 2024-01-31 22:40+0100\n" "PO-Revision-Date: 2023-07-22 23:45+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Catalan \n" @@ -94,7 +94,7 @@ msgid "The campsite offers many different services." msgstr "El càmping disposa de diversos serveis." #: web/templates/public/amenity.gohtml:39 -#: web/templates/public/campsite/type.gohtml:112 +#: web/templates/public/campsite/type.gohtml:114 #: web/templates/public/campsite/page.gohtml:39 msgctxt "title" msgid "Features" @@ -163,80 +163,80 @@ msgctxt "input" msgid "Check-out Date" msgstr "Data de sortida" -#: web/templates/public/campsite/type.gohtml:54 -#: web/templates/public/booking.gohtml:169 +#: web/templates/public/campsite/type.gohtml:56 +#: web/templates/public/booking.gohtml:171 msgctxt "action" msgid "Book" msgstr "Reserva" -#: web/templates/public/campsite/type.gohtml:62 +#: web/templates/public/campsite/type.gohtml:64 #: web/templates/admin/season/index.gohtml:54 msgctxt "title" msgid "Calendar" msgstr "Calendari" -#: web/templates/public/campsite/type.gohtml:73 -#: web/templates/admin/campsite/type/form.gohtml:127 +#: web/templates/public/campsite/type.gohtml:75 +#: web/templates/admin/campsite/type/form.gohtml:143 #: web/templates/admin/campsite/type/option/form.gohtml:70 msgctxt "title" msgid "Prices" msgstr "Preus" -#: web/templates/public/campsite/type.gohtml:85 -#: web/templates/public/campsite/type.gohtml:91 +#: web/templates/public/campsite/type.gohtml:87 +#: web/templates/public/campsite/type.gohtml:93 msgid "%s: %s €/night" msgstr "%s: %s €/nit" -#: web/templates/public/campsite/type.gohtml:87 +#: web/templates/public/campsite/type.gohtml:89 msgid "%s €/night" msgstr "%s €/nit" -#: web/templates/public/campsite/type.gohtml:94 +#: web/templates/public/campsite/type.gohtml:96 msgid "*Minimum %d nights per stay" msgstr "*Mínim %d nits per estada" -#: web/templates/public/campsite/type.gohtml:99 +#: web/templates/public/campsite/type.gohtml:101 msgid "10 % VAT included." msgstr "IVA del 10 % inclòs." -#: web/templates/public/campsite/type.gohtml:100 +#: web/templates/public/campsite/type.gohtml:102 msgid "Tourist tax: %s/night per person aged 17 or older." msgstr "Impost turístic: %s/nit per persona major de 16 anys." -#: web/templates/public/campsite/type.gohtml:102 +#: web/templates/public/campsite/type.gohtml:104 msgid "Dogs: %s/night, tied, accompanied, and minimal barking." msgstr "Gossos: %s/night, lligats, acompanyats i el mínim de lladrucs." -#: web/templates/public/campsite/type.gohtml:104 +#: web/templates/public/campsite/type.gohtml:106 msgid "No dogs allowed." msgstr "No es permeten gossos." -#: web/templates/public/campsite/type.gohtml:123 +#: web/templates/public/campsite/type.gohtml:125 msgctxt "title" msgid "Info" msgstr "Informació" -#: web/templates/public/campsite/type.gohtml:127 +#: web/templates/public/campsite/type.gohtml:129 msgctxt "title" msgid "Facilities" msgstr "Equipaments" -#: web/templates/public/campsite/type.gohtml:131 +#: web/templates/public/campsite/type.gohtml:133 msgctxt "title" msgid "Description" msgstr "Descripció" -#: web/templates/public/campsite/type.gohtml:135 +#: web/templates/public/campsite/type.gohtml:137 msgctxt "title" msgid "Additional Information" msgstr "Informació addicional" -#: web/templates/public/campsite/type.gohtml:138 +#: web/templates/public/campsite/type.gohtml:140 msgctxt "time" msgid "Check-in" msgstr "Entrada" -#: web/templates/public/campsite/type.gohtml:142 +#: web/templates/public/campsite/type.gohtml:144 msgctxt "time" msgid "Check-out" msgstr "Sortida" @@ -560,17 +560,17 @@ msgctxt "input" msgid "Arrival date" msgstr "Data d’arribada" -#: web/templates/public/booking.gohtml:138 +#: web/templates/public/booking.gohtml:139 msgctxt "input" msgid "Departure date" msgstr "Data de sortida" -#: web/templates/public/booking.gohtml:149 +#: web/templates/public/booking.gohtml:151 msgctxt "input" msgid "ACSI card? (optional)" msgstr "Targeta ACSI? (opcional)" -#: web/templates/public/booking.gohtml:156 +#: web/templates/public/booking.gohtml:158 msgctxt "input" msgid "I have read and I accept %[1]sthe reservation conditions%[2]s" msgstr "He llegit i accepto %[1]sles condicions de reserves%[2]s" @@ -675,7 +675,7 @@ msgstr "Contingut" #: web/templates/admin/campsite/form.gohtml:92 #: web/templates/admin/campsite/type/feature/form.gohtml:74 #: web/templates/admin/campsite/type/carousel/form.gohtml:59 -#: web/templates/admin/campsite/type/form.gohtml:220 +#: web/templates/admin/campsite/type/form.gohtml:228 #: web/templates/admin/campsite/type/option/form.gohtml:90 #: web/templates/admin/season/form.gohtml:73 #: web/templates/admin/services/form.gohtml:81 @@ -697,7 +697,7 @@ msgstr "Actualitza" #: web/templates/admin/campsite/form.gohtml:94 #: web/templates/admin/campsite/type/feature/form.gohtml:76 #: web/templates/admin/campsite/type/carousel/form.gohtml:61 -#: web/templates/admin/campsite/type/form.gohtml:222 +#: web/templates/admin/campsite/type/form.gohtml:230 #: web/templates/admin/campsite/type/option/form.gohtml:92 #: web/templates/admin/season/form.gohtml:75 #: web/templates/admin/services/form.gohtml:83 @@ -1110,60 +1110,65 @@ msgctxt "input" msgid "Check-out" msgstr "Sortida" -#: web/templates/admin/campsite/type/form.gohtml:94 +#: web/templates/admin/campsite/type/form.gohtml:93 +msgctxt "input" +msgid "Minimum number of nights" +msgstr "Número mínim de nits" + +#: web/templates/admin/campsite/type/form.gohtml:101 +msgctxt "input" +msgid "Maximum number of nights" +msgstr "Número màxim de nits" + +#: web/templates/admin/campsite/type/form.gohtml:110 msgctxt "input" msgid "Maximum number of campers" msgstr "Número màxim de persones" -#: web/templates/admin/campsite/type/form.gohtml:104 +#: web/templates/admin/campsite/type/form.gohtml:120 msgctxt "input" msgid "Allow overflowing guests to neighbouring campsites" msgstr "Permet reservar allotjaments veïns si es supera el màxim de persones" -#: web/templates/admin/campsite/type/form.gohtml:113 +#: web/templates/admin/campsite/type/form.gohtml:129 msgctxt "input" msgid "Ask for zone preferences when booking" msgstr "Demana la preferència de zona durant la reserva" -#: web/templates/admin/campsite/type/form.gohtml:121 +#: web/templates/admin/campsite/type/form.gohtml:137 msgctxt "input" msgid "Dogs allowed" msgstr "Es permeten gossos" -#: web/templates/admin/campsite/type/form.gohtml:133 +#: web/templates/admin/campsite/type/form.gohtml:149 #: web/templates/admin/campsite/type/option/form.gohtml:76 msgctxt "input" msgid "Price per night" msgstr "Preu per nit" -#: web/templates/admin/campsite/type/form.gohtml:141 -msgctxt "input" -msgid "Minimum number of nights" -msgstr "Número mínim de nits" - -#: web/templates/admin/campsite/type/form.gohtml:153 +#: web/templates/admin/campsite/type/form.gohtml:161 msgctxt "input" msgid "Spiel" msgstr "Introducció" -#: web/templates/admin/campsite/type/form.gohtml:166 +#: web/templates/admin/campsite/type/form.gohtml:174 msgctxt "input" msgid "Info" msgstr "Informació" -#: web/templates/admin/campsite/type/form.gohtml:179 +#: web/templates/admin/campsite/type/form.gohtml:187 msgctxt "input" msgid "Facilities" msgstr "Equipaments" -#: web/templates/admin/campsite/type/form.gohtml:192 +#: web/templates/admin/campsite/type/form.gohtml:200 #: web/templates/admin/services/form.gohtml:66 #: web/templates/admin/surroundings/form.gohtml:54 msgctxt "input" msgid "Description" msgstr "Descripció" -#: web/templates/admin/campsite/type/form.gohtml:205 +#: web/templates/admin/campsite/type/form.gohtml:213 msgctxt "input" msgid "Additional Information" msgstr "Informació addicional" @@ -1860,7 +1865,7 @@ msgid "No booking found." msgstr "No s’ha trobat cap reserva." #: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357 -#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:497 +#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:528 #: pkg/campsite/feature.go:269 pkg/season/admin.go:412 #: pkg/services/admin.go:316 pkg/surroundings/admin.go:340 #: pkg/amenity/feature.go:269 pkg/amenity/admin.go:283 @@ -1868,7 +1873,7 @@ msgid "Name can not be empty." msgstr "No podeu deixar el nom en blanc." #: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358 -#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:498 +#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:529 #: pkg/campsite/feature.go:270 pkg/amenity/feature.go:270 msgid "Name must have at least one letter." msgstr "El nom ha de tenir com a mínim una lletra." @@ -1960,15 +1965,15 @@ msgstr "El valor del màxim ha de ser un número enter." msgid "Maximum must be equal or greater than minimum." msgstr "El valor del màxim ha de ser igual o superir al del mínim." -#: pkg/campsite/types/option.go:374 pkg/campsite/types/admin.go:513 +#: pkg/campsite/types/option.go:374 pkg/campsite/types/admin.go:554 msgid "Price per night can not be empty." msgstr "No podeu deixar el preu per nit en blanc." -#: pkg/campsite/types/option.go:375 pkg/campsite/types/admin.go:514 +#: pkg/campsite/types/option.go:375 pkg/campsite/types/admin.go:555 msgid "Price per night must be a decimal number." msgstr "El preu per nit ha de ser un número decimal." -#: pkg/campsite/types/option.go:376 pkg/campsite/types/admin.go:515 +#: pkg/campsite/types/option.go:376 pkg/campsite/types/admin.go:556 msgid "Price per night must be zero or greater." msgstr "El preu per nit ha de ser com a mínim zero." @@ -1977,56 +1982,68 @@ msgstr "El preu per nit ha de ser com a mínim zero." msgid "Selected icon is not valid." msgstr "La icona escollida no és vàlida." -#: pkg/campsite/types/admin.go:309 +#: pkg/campsite/types/admin.go:310 msgctxt "input" msgid "Cover image" msgstr "Imatge de portada" -#: pkg/campsite/types/admin.go:310 +#: pkg/campsite/types/admin.go:311 msgctxt "action" msgid "Set campsite type cover" msgstr "Estableix la portada del tipus d’allotjament" -#: pkg/campsite/types/admin.go:500 +#: pkg/campsite/types/admin.go:531 msgid "Check-in can not be empty." msgstr "No podeu deixar l’entrada en blanc." -#: pkg/campsite/types/admin.go:501 +#: pkg/campsite/types/admin.go:532 msgid "Check-out can not be empty." msgstr "No podeu deixar la sortida en blanc." -#: pkg/campsite/types/admin.go:502 +#: pkg/campsite/types/admin.go:533 msgid "Cover image can not be empty." msgstr "No podeu deixar la imatge de portada en blanc." -#: pkg/campsite/types/admin.go:503 +#: pkg/campsite/types/admin.go:534 msgid "Cover image must be an image media type." msgstr "La imatge de portada ha de ser un mèdia de tipus imatge." -#: pkg/campsite/types/admin.go:507 +#: pkg/campsite/types/admin.go:538 msgid "Maximum number of campers can not be empty." msgstr "No podeu deixar el número màxim de persones en blanc." -#: pkg/campsite/types/admin.go:508 +#: pkg/campsite/types/admin.go:539 msgid "Maximum number of campers must be an integer number." msgstr "El número màxim de persones ha de ser enter." -#: pkg/campsite/types/admin.go:509 +#: pkg/campsite/types/admin.go:540 msgid "Maximum number of campers must be one or greater." msgstr "El número màxim de persones no pot ser zero." -#: pkg/campsite/types/admin.go:518 +#: pkg/campsite/types/admin.go:543 msgid "Minimum number of nights can not be empty." msgstr "No podeu deixar el número mínim de nits en blanc." -#: pkg/campsite/types/admin.go:519 +#: pkg/campsite/types/admin.go:544 msgid "Minimum number of nights must be an integer." msgstr "El número mínim de nits ha de ser enter." -#: pkg/campsite/types/admin.go:520 +#: pkg/campsite/types/admin.go:545 msgid "Minimum number of nights must be one or greater." msgstr "El número mínim de nits no pot ser zero." +#: pkg/campsite/types/admin.go:548 +msgid "Maximum number of nights can not be empty." +msgstr "No podeu deixar el número màxim de nits en blanc." + +#: pkg/campsite/types/admin.go:549 +msgid "Maximum number of nights must be an integer." +msgstr "El número màxim de nits ha de ser enter." + +#: pkg/campsite/types/admin.go:550 +msgid "Maximum number of nights must be equal or greater than the minimum." +msgstr "El valor del número màxim de nits ha de ser igual o superir al del mínim." + #: pkg/campsite/admin.go:275 pkg/booking/public.go:321 msgid "Selected campsite type is not valid." msgstr "El tipus d’allotjament escollit no és vàlid." diff --git a/po/es.po b/po/es.po index b55072d..19506b5 100644 --- a/po/es.po +++ b/po/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2024-01-31 15:06+0100\n" +"POT-Creation-Date: 2024-01-31 22:40+0100\n" "PO-Revision-Date: 2023-07-22 23:46+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Spanish \n" @@ -94,7 +94,7 @@ msgid "The campsite offers many different services." msgstr "El camping dispone de varios servicios." #: web/templates/public/amenity.gohtml:39 -#: web/templates/public/campsite/type.gohtml:112 +#: web/templates/public/campsite/type.gohtml:114 #: web/templates/public/campsite/page.gohtml:39 msgctxt "title" msgid "Features" @@ -163,80 +163,80 @@ msgctxt "input" msgid "Check-out Date" msgstr "Fecha de salida" -#: web/templates/public/campsite/type.gohtml:54 -#: web/templates/public/booking.gohtml:169 +#: web/templates/public/campsite/type.gohtml:56 +#: web/templates/public/booking.gohtml:171 msgctxt "action" msgid "Book" msgstr "Reservar" -#: web/templates/public/campsite/type.gohtml:62 +#: web/templates/public/campsite/type.gohtml:64 #: web/templates/admin/season/index.gohtml:54 msgctxt "title" msgid "Calendar" msgstr "Calendario" -#: web/templates/public/campsite/type.gohtml:73 -#: web/templates/admin/campsite/type/form.gohtml:127 +#: web/templates/public/campsite/type.gohtml:75 +#: web/templates/admin/campsite/type/form.gohtml:143 #: web/templates/admin/campsite/type/option/form.gohtml:70 msgctxt "title" msgid "Prices" msgstr "Precios" -#: web/templates/public/campsite/type.gohtml:85 -#: web/templates/public/campsite/type.gohtml:91 +#: web/templates/public/campsite/type.gohtml:87 +#: web/templates/public/campsite/type.gohtml:93 msgid "%s: %s €/night" msgstr "%s: %s €/noche" -#: web/templates/public/campsite/type.gohtml:87 +#: web/templates/public/campsite/type.gohtml:89 msgid "%s €/night" msgstr "%s €/noche" -#: web/templates/public/campsite/type.gohtml:94 +#: web/templates/public/campsite/type.gohtml:96 msgid "*Minimum %d nights per stay" msgstr "*Mínimo %d noches por estancia" -#: web/templates/public/campsite/type.gohtml:99 +#: web/templates/public/campsite/type.gohtml:101 msgid "10 % VAT included." msgstr "IVA del 10 % incluido." -#: web/templates/public/campsite/type.gohtml:100 +#: web/templates/public/campsite/type.gohtml:102 msgid "Tourist tax: %s/night per person aged 17 or older." msgstr "Impuesto turístico: %s/noche por persona mayor de de 16 años." -#: web/templates/public/campsite/type.gohtml:102 +#: web/templates/public/campsite/type.gohtml:104 msgid "Dogs: %s/night, tied, accompanied, and minimal barking." msgstr "Perros: %s/noche, atados, acompañados y con mínimo de ladrido." -#: web/templates/public/campsite/type.gohtml:104 +#: web/templates/public/campsite/type.gohtml:106 msgid "No dogs allowed." msgstr "No se permiten perros" -#: web/templates/public/campsite/type.gohtml:123 +#: web/templates/public/campsite/type.gohtml:125 msgctxt "title" msgid "Info" msgstr "Información" -#: web/templates/public/campsite/type.gohtml:127 +#: web/templates/public/campsite/type.gohtml:129 msgctxt "title" msgid "Facilities" msgstr "Equipamiento" -#: web/templates/public/campsite/type.gohtml:131 +#: web/templates/public/campsite/type.gohtml:133 msgctxt "title" msgid "Description" msgstr "Descripción" -#: web/templates/public/campsite/type.gohtml:135 +#: web/templates/public/campsite/type.gohtml:137 msgctxt "title" msgid "Additional Information" msgstr "Información adicional" -#: web/templates/public/campsite/type.gohtml:138 +#: web/templates/public/campsite/type.gohtml:140 msgctxt "time" msgid "Check-in" msgstr "Entrada" -#: web/templates/public/campsite/type.gohtml:142 +#: web/templates/public/campsite/type.gohtml:144 msgctxt "time" msgid "Check-out" msgstr "Salida" @@ -560,17 +560,17 @@ msgctxt "input" msgid "Arrival date" msgstr "Fecha de llegada" -#: web/templates/public/booking.gohtml:138 +#: web/templates/public/booking.gohtml:139 msgctxt "input" msgid "Departure date" msgstr "Fecha de salida" -#: web/templates/public/booking.gohtml:149 +#: web/templates/public/booking.gohtml:151 msgctxt "input" msgid "ACSI card? (optional)" msgstr "¿Tarjeta ACSI? (opcional)" -#: web/templates/public/booking.gohtml:156 +#: web/templates/public/booking.gohtml:158 msgctxt "input" msgid "I have read and I accept %[1]sthe reservation conditions%[2]s" msgstr "He leído y acepto %[1]slas condiciones de reserva%[2]s" @@ -675,7 +675,7 @@ msgstr "Contenido" #: web/templates/admin/campsite/form.gohtml:92 #: web/templates/admin/campsite/type/feature/form.gohtml:74 #: web/templates/admin/campsite/type/carousel/form.gohtml:59 -#: web/templates/admin/campsite/type/form.gohtml:220 +#: web/templates/admin/campsite/type/form.gohtml:228 #: web/templates/admin/campsite/type/option/form.gohtml:90 #: web/templates/admin/season/form.gohtml:73 #: web/templates/admin/services/form.gohtml:81 @@ -697,7 +697,7 @@ msgstr "Actualizar" #: web/templates/admin/campsite/form.gohtml:94 #: web/templates/admin/campsite/type/feature/form.gohtml:76 #: web/templates/admin/campsite/type/carousel/form.gohtml:61 -#: web/templates/admin/campsite/type/form.gohtml:222 +#: web/templates/admin/campsite/type/form.gohtml:230 #: web/templates/admin/campsite/type/option/form.gohtml:92 #: web/templates/admin/season/form.gohtml:75 #: web/templates/admin/services/form.gohtml:83 @@ -1110,60 +1110,65 @@ msgctxt "input" msgid "Check-out" msgstr "Salida" -#: web/templates/admin/campsite/type/form.gohtml:94 +#: web/templates/admin/campsite/type/form.gohtml:93 +msgctxt "input" +msgid "Minimum number of nights" +msgstr "Número mínimos de noches" + +#: web/templates/admin/campsite/type/form.gohtml:101 +msgctxt "input" +msgid "Maximum number of nights" +msgstr "Número máximo de noches" + +#: web/templates/admin/campsite/type/form.gohtml:110 msgctxt "input" msgid "Maximum number of campers" msgstr "Número máximo de personas" -#: web/templates/admin/campsite/type/form.gohtml:104 +#: web/templates/admin/campsite/type/form.gohtml:120 msgctxt "input" msgid "Allow overflowing guests to neighbouring campsites" msgstr "Permitir reservar alojamientos vecinos si se supera el máximo de personas" -#: web/templates/admin/campsite/type/form.gohtml:113 +#: web/templates/admin/campsite/type/form.gohtml:129 msgctxt "input" msgid "Ask for zone preferences when booking" msgstr "Pedir la preferencia de zona durante la reserva" -#: web/templates/admin/campsite/type/form.gohtml:121 +#: web/templates/admin/campsite/type/form.gohtml:137 msgctxt "input" msgid "Dogs allowed" msgstr "Se permiten perros" -#: web/templates/admin/campsite/type/form.gohtml:133 +#: web/templates/admin/campsite/type/form.gohtml:149 #: web/templates/admin/campsite/type/option/form.gohtml:76 msgctxt "input" msgid "Price per night" msgstr "Precio por noche" -#: web/templates/admin/campsite/type/form.gohtml:141 -msgctxt "input" -msgid "Minimum number of nights" -msgstr "Número mínimos de noches" - -#: web/templates/admin/campsite/type/form.gohtml:153 +#: web/templates/admin/campsite/type/form.gohtml:161 msgctxt "input" msgid "Spiel" msgstr "Introducción" -#: web/templates/admin/campsite/type/form.gohtml:166 +#: web/templates/admin/campsite/type/form.gohtml:174 msgctxt "input" msgid "Info" msgstr "Información" -#: web/templates/admin/campsite/type/form.gohtml:179 +#: web/templates/admin/campsite/type/form.gohtml:187 msgctxt "input" msgid "Facilities" msgstr "Equipamento" -#: web/templates/admin/campsite/type/form.gohtml:192 +#: web/templates/admin/campsite/type/form.gohtml:200 #: web/templates/admin/services/form.gohtml:66 #: web/templates/admin/surroundings/form.gohtml:54 msgctxt "input" msgid "Description" msgstr "Descripción" -#: web/templates/admin/campsite/type/form.gohtml:205 +#: web/templates/admin/campsite/type/form.gohtml:213 msgctxt "input" msgid "Additional Information" msgstr "Información adicional" @@ -1860,7 +1865,7 @@ msgid "No booking found." msgstr "No se ha encontrado ninguna reserva." #: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357 -#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:497 +#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:528 #: pkg/campsite/feature.go:269 pkg/season/admin.go:412 #: pkg/services/admin.go:316 pkg/surroundings/admin.go:340 #: pkg/amenity/feature.go:269 pkg/amenity/admin.go:283 @@ -1868,7 +1873,7 @@ msgid "Name can not be empty." msgstr "No podéis dejar el nombre en blanco." #: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358 -#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:498 +#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:529 #: pkg/campsite/feature.go:270 pkg/amenity/feature.go:270 msgid "Name must have at least one letter." msgstr "El nombre tiene que tener como mínimo una letra." @@ -1960,15 +1965,15 @@ msgstr "El valor del máximo tiene que ser un número entero." msgid "Maximum must be equal or greater than minimum." msgstr "El valor del máximo tiene que ser igual o mayor al del mínimo." -#: pkg/campsite/types/option.go:374 pkg/campsite/types/admin.go:513 +#: pkg/campsite/types/option.go:374 pkg/campsite/types/admin.go:554 msgid "Price per night can not be empty." msgstr "No podéis dejar el precio por noche en blanco." -#: pkg/campsite/types/option.go:375 pkg/campsite/types/admin.go:514 +#: pkg/campsite/types/option.go:375 pkg/campsite/types/admin.go:555 msgid "Price per night must be a decimal number." msgstr "El precio por noche tiene que ser un número decimal." -#: pkg/campsite/types/option.go:376 pkg/campsite/types/admin.go:515 +#: pkg/campsite/types/option.go:376 pkg/campsite/types/admin.go:556 msgid "Price per night must be zero or greater." msgstr "El precio por noche tiene que ser como mínimo cero." @@ -1977,56 +1982,68 @@ msgstr "El precio por noche tiene que ser como mínimo cero." msgid "Selected icon is not valid." msgstr "El icono escogido no es válido." -#: pkg/campsite/types/admin.go:309 +#: pkg/campsite/types/admin.go:310 msgctxt "input" msgid "Cover image" msgstr "Imagen de portada" -#: pkg/campsite/types/admin.go:310 +#: pkg/campsite/types/admin.go:311 msgctxt "action" msgid "Set campsite type cover" msgstr "Establecer la portada del tipo de alojamiento" -#: pkg/campsite/types/admin.go:500 +#: pkg/campsite/types/admin.go:531 msgid "Check-in can not be empty." msgstr "No podéis dejar la entrada en blanco." -#: pkg/campsite/types/admin.go:501 +#: pkg/campsite/types/admin.go:532 msgid "Check-out can not be empty." msgstr "No podéis dejar la salida en blanco." -#: pkg/campsite/types/admin.go:502 +#: pkg/campsite/types/admin.go:533 msgid "Cover image can not be empty." msgstr "No podéis dejar la imagen de portada en blanco." -#: pkg/campsite/types/admin.go:503 +#: pkg/campsite/types/admin.go:534 msgid "Cover image must be an image media type." msgstr "La imagen de portada tiene que ser un medio de tipo imagen." -#: pkg/campsite/types/admin.go:507 +#: pkg/campsite/types/admin.go:538 msgid "Maximum number of campers can not be empty." msgstr "No podéis dejar el número máximo de personas en blanco." -#: pkg/campsite/types/admin.go:508 +#: pkg/campsite/types/admin.go:539 msgid "Maximum number of campers must be an integer number." msgstr "El número máximo de personas tiene que ser entero." -#: pkg/campsite/types/admin.go:509 +#: pkg/campsite/types/admin.go:540 msgid "Maximum number of campers must be one or greater." msgstr "El número máximo de personas no puede ser cero." -#: pkg/campsite/types/admin.go:518 +#: pkg/campsite/types/admin.go:543 msgid "Minimum number of nights can not be empty." msgstr "No podéis dejar el número mínimo de noches en blanco." -#: pkg/campsite/types/admin.go:519 +#: pkg/campsite/types/admin.go:544 msgid "Minimum number of nights must be an integer." msgstr "El número mínimo de noches tiene que ser entero." -#: pkg/campsite/types/admin.go:520 +#: pkg/campsite/types/admin.go:545 msgid "Minimum number of nights must be one or greater." msgstr "El número mínimo de noches no puede ser cero." +#: pkg/campsite/types/admin.go:548 +msgid "Maximum number of nights can not be empty." +msgstr "No podéis dejar el número máximo de noches en blanco." + +#: pkg/campsite/types/admin.go:549 +msgid "Maximum number of nights must be an integer." +msgstr "El número máximo de noches tiene que ser entero." + +#: pkg/campsite/types/admin.go:550 +msgid "Maximum number of nights must be equal or greater than the minimum." +msgstr "El valor del número máximo de noches tiene que ser igual o mayor al del mínimo." + #: pkg/campsite/admin.go:275 pkg/booking/public.go:321 msgid "Selected campsite type is not valid." msgstr "El tipo de alojamiento escogido no es válido." diff --git a/po/fr.po b/po/fr.po index 77612e4..773bff4 100644 --- a/po/fr.po +++ b/po/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2024-01-31 15:06+0100\n" +"POT-Creation-Date: 2024-01-31 22:40+0100\n" "PO-Revision-Date: 2023-12-20 10:13+0100\n" "Last-Translator: Oriol Carbonell \n" "Language-Team: French \n" @@ -95,7 +95,7 @@ msgid "The campsite offers many different services." msgstr "Le camping propose de nombreux services différents." #: web/templates/public/amenity.gohtml:39 -#: web/templates/public/campsite/type.gohtml:112 +#: web/templates/public/campsite/type.gohtml:114 #: web/templates/public/campsite/page.gohtml:39 msgctxt "title" msgid "Features" @@ -164,80 +164,80 @@ msgctxt "input" msgid "Check-out Date" msgstr "Date de départ" -#: web/templates/public/campsite/type.gohtml:54 -#: web/templates/public/booking.gohtml:169 +#: web/templates/public/campsite/type.gohtml:56 +#: web/templates/public/booking.gohtml:171 msgctxt "action" msgid "Book" msgstr "Réserver" -#: web/templates/public/campsite/type.gohtml:62 +#: web/templates/public/campsite/type.gohtml:64 #: web/templates/admin/season/index.gohtml:54 msgctxt "title" msgid "Calendar" msgstr "Calendrier" -#: web/templates/public/campsite/type.gohtml:73 -#: web/templates/admin/campsite/type/form.gohtml:127 +#: web/templates/public/campsite/type.gohtml:75 +#: web/templates/admin/campsite/type/form.gohtml:143 #: web/templates/admin/campsite/type/option/form.gohtml:70 msgctxt "title" msgid "Prices" msgstr "Prix" -#: web/templates/public/campsite/type.gohtml:85 -#: web/templates/public/campsite/type.gohtml:91 +#: web/templates/public/campsite/type.gohtml:87 +#: web/templates/public/campsite/type.gohtml:93 msgid "%s: %s €/night" msgstr "%s : %s €/nuit" -#: web/templates/public/campsite/type.gohtml:87 +#: web/templates/public/campsite/type.gohtml:89 msgid "%s €/night" msgstr "%s €/nuit" -#: web/templates/public/campsite/type.gohtml:94 +#: web/templates/public/campsite/type.gohtml:96 msgid "*Minimum %d nights per stay" msgstr "*Minimum %d nuits par séjour" -#: web/templates/public/campsite/type.gohtml:99 +#: web/templates/public/campsite/type.gohtml:101 msgid "10 % VAT included." msgstr "10 % TVA incluse." -#: web/templates/public/campsite/type.gohtml:100 +#: web/templates/public/campsite/type.gohtml:102 msgid "Tourist tax: %s/night per person aged 17 or older." msgstr "Taxe touristique: %s/nuit par personne de plus de 16 ans." -#: web/templates/public/campsite/type.gohtml:102 +#: web/templates/public/campsite/type.gohtml:104 msgid "Dogs: %s/night, tied, accompanied, and minimal barking." msgstr "Chiens : %s/nuit, attachés, accompagnés et aboiements minimes." -#: web/templates/public/campsite/type.gohtml:104 +#: web/templates/public/campsite/type.gohtml:106 msgid "No dogs allowed." msgstr "Chiens interdits." -#: web/templates/public/campsite/type.gohtml:123 +#: web/templates/public/campsite/type.gohtml:125 msgctxt "title" msgid "Info" msgstr "Info" -#: web/templates/public/campsite/type.gohtml:127 +#: web/templates/public/campsite/type.gohtml:129 msgctxt "title" msgid "Facilities" msgstr "Installations" -#: web/templates/public/campsite/type.gohtml:131 +#: web/templates/public/campsite/type.gohtml:133 msgctxt "title" msgid "Description" msgstr "Description" -#: web/templates/public/campsite/type.gohtml:135 +#: web/templates/public/campsite/type.gohtml:137 msgctxt "title" msgid "Additional Information" msgstr "Informations Complémentaires" -#: web/templates/public/campsite/type.gohtml:138 +#: web/templates/public/campsite/type.gohtml:140 msgctxt "time" msgid "Check-in" msgstr "Arrivée" -#: web/templates/public/campsite/type.gohtml:142 +#: web/templates/public/campsite/type.gohtml:144 msgctxt "time" msgid "Check-out" msgstr "Départ" @@ -561,17 +561,17 @@ msgctxt "input" msgid "Arrival date" msgstr "Date d’arrivée" -#: web/templates/public/booking.gohtml:138 +#: web/templates/public/booking.gohtml:139 msgctxt "input" msgid "Departure date" msgstr "Date de depart" -#: web/templates/public/booking.gohtml:149 +#: web/templates/public/booking.gohtml:151 msgctxt "input" msgid "ACSI card? (optional)" msgstr "Carte ACSI ? (Facultatif)" -#: web/templates/public/booking.gohtml:156 +#: web/templates/public/booking.gohtml:158 msgctxt "input" msgid "I have read and I accept %[1]sthe reservation conditions%[2]s" msgstr "J’ai lu et j’accepte %[1]sles conditions de réservation%[2]s" @@ -676,7 +676,7 @@ msgstr "Contenu" #: web/templates/admin/campsite/form.gohtml:92 #: web/templates/admin/campsite/type/feature/form.gohtml:74 #: web/templates/admin/campsite/type/carousel/form.gohtml:59 -#: web/templates/admin/campsite/type/form.gohtml:220 +#: web/templates/admin/campsite/type/form.gohtml:228 #: web/templates/admin/campsite/type/option/form.gohtml:90 #: web/templates/admin/season/form.gohtml:73 #: web/templates/admin/services/form.gohtml:81 @@ -698,7 +698,7 @@ msgstr "Mettre à jour" #: web/templates/admin/campsite/form.gohtml:94 #: web/templates/admin/campsite/type/feature/form.gohtml:76 #: web/templates/admin/campsite/type/carousel/form.gohtml:61 -#: web/templates/admin/campsite/type/form.gohtml:222 +#: web/templates/admin/campsite/type/form.gohtml:230 #: web/templates/admin/campsite/type/option/form.gohtml:92 #: web/templates/admin/season/form.gohtml:75 #: web/templates/admin/services/form.gohtml:83 @@ -1111,60 +1111,65 @@ msgctxt "input" msgid "Check-out" msgstr "Départ" -#: web/templates/admin/campsite/type/form.gohtml:94 +#: web/templates/admin/campsite/type/form.gohtml:93 +msgctxt "input" +msgid "Minimum number of nights" +msgstr "Nombre minimum de nuits" + +#: web/templates/admin/campsite/type/form.gohtml:101 +msgctxt "input" +msgid "Maximum number of nights" +msgstr "Nombre maximale de nuits" + +#: web/templates/admin/campsite/type/form.gohtml:110 msgctxt "input" msgid "Maximum number of campers" msgstr "Nombre maximum de personnes" -#: web/templates/admin/campsite/type/form.gohtml:104 +#: web/templates/admin/campsite/type/form.gohtml:120 msgctxt "input" msgid "Allow overflowing guests to neighbouring campsites" msgstr "Autoriser la réservation d’un hébergement voisin si le nombre maximum de personnes est dépassé" -#: web/templates/admin/campsite/type/form.gohtml:113 +#: web/templates/admin/campsite/type/form.gohtml:129 msgctxt "input" msgid "Ask for zone preferences when booking" msgstr "Demandez la préférence de zone lors de la réservation" -#: web/templates/admin/campsite/type/form.gohtml:121 +#: web/templates/admin/campsite/type/form.gohtml:137 msgctxt "input" msgid "Dogs allowed" msgstr "Chiens acceptés" -#: web/templates/admin/campsite/type/form.gohtml:133 +#: web/templates/admin/campsite/type/form.gohtml:149 #: web/templates/admin/campsite/type/option/form.gohtml:76 msgctxt "input" msgid "Price per night" msgstr "Prix par nuit" -#: web/templates/admin/campsite/type/form.gohtml:141 -msgctxt "input" -msgid "Minimum number of nights" -msgstr "Nombre minimum de nuits" - -#: web/templates/admin/campsite/type/form.gohtml:153 +#: web/templates/admin/campsite/type/form.gohtml:161 msgctxt "input" msgid "Spiel" msgstr "Boniment" -#: web/templates/admin/campsite/type/form.gohtml:166 +#: web/templates/admin/campsite/type/form.gohtml:174 msgctxt "input" msgid "Info" msgstr "Info" -#: web/templates/admin/campsite/type/form.gohtml:179 +#: web/templates/admin/campsite/type/form.gohtml:187 msgctxt "input" msgid "Facilities" msgstr "Installations" -#: web/templates/admin/campsite/type/form.gohtml:192 +#: web/templates/admin/campsite/type/form.gohtml:200 #: web/templates/admin/services/form.gohtml:66 #: web/templates/admin/surroundings/form.gohtml:54 msgctxt "input" msgid "Description" msgstr "Description" -#: web/templates/admin/campsite/type/form.gohtml:205 +#: web/templates/admin/campsite/type/form.gohtml:213 msgctxt "input" msgid "Additional Information" msgstr "Informations Complémentaires" @@ -1861,7 +1866,7 @@ msgid "No booking found." msgstr "Aucune réservation trouvée." #: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357 -#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:497 +#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:528 #: pkg/campsite/feature.go:269 pkg/season/admin.go:412 #: pkg/services/admin.go:316 pkg/surroundings/admin.go:340 #: pkg/amenity/feature.go:269 pkg/amenity/admin.go:283 @@ -1869,7 +1874,7 @@ msgid "Name can not be empty." msgstr "Le nom ne peut pas être laissé vide." #: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358 -#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:498 +#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:529 #: pkg/campsite/feature.go:270 pkg/amenity/feature.go:270 msgid "Name must have at least one letter." msgstr "Le nom doit comporter au moins une lettre." @@ -1961,15 +1966,15 @@ msgstr "Le maximum doit être un nombre entier." msgid "Maximum must be equal or greater than minimum." msgstr "Le maximum doit être égal ou supérieur au minimum." -#: pkg/campsite/types/option.go:374 pkg/campsite/types/admin.go:513 +#: pkg/campsite/types/option.go:374 pkg/campsite/types/admin.go:554 msgid "Price per night can not be empty." msgstr "Le prix par nuit ne peut pas être vide." -#: pkg/campsite/types/option.go:375 pkg/campsite/types/admin.go:514 +#: pkg/campsite/types/option.go:375 pkg/campsite/types/admin.go:555 msgid "Price per night must be a decimal number." msgstr "Le prix par nuit doit être un nombre décimal." -#: pkg/campsite/types/option.go:376 pkg/campsite/types/admin.go:515 +#: pkg/campsite/types/option.go:376 pkg/campsite/types/admin.go:556 msgid "Price per night must be zero or greater." msgstr "Le prix par nuit doit être égal ou supérieur." @@ -1978,56 +1983,68 @@ msgstr "Le prix par nuit doit être égal ou supérieur." msgid "Selected icon is not valid." msgstr "L’icône sélectionnée n’est pas valide." -#: pkg/campsite/types/admin.go:309 +#: pkg/campsite/types/admin.go:310 msgctxt "input" msgid "Cover image" msgstr "Image de couverture" -#: pkg/campsite/types/admin.go:310 +#: pkg/campsite/types/admin.go:311 msgctxt "action" msgid "Set campsite type cover" msgstr "Définir une couverture type camping" -#: pkg/campsite/types/admin.go:500 +#: pkg/campsite/types/admin.go:531 msgid "Check-in can not be empty." msgstr "L’arrivée ne peut pas être vide." -#: pkg/campsite/types/admin.go:501 +#: pkg/campsite/types/admin.go:532 msgid "Check-out can not be empty." msgstr "Le départ ne peut pas être vide." -#: pkg/campsite/types/admin.go:502 +#: pkg/campsite/types/admin.go:533 msgid "Cover image can not be empty." msgstr "L’image de couverture ne peut pas être vide." -#: pkg/campsite/types/admin.go:503 +#: pkg/campsite/types/admin.go:534 msgid "Cover image must be an image media type." msgstr "L’image de couverture doit être de type média d’image." -#: pkg/campsite/types/admin.go:507 +#: pkg/campsite/types/admin.go:538 msgid "Maximum number of campers can not be empty." msgstr "Le nombre maximum de campeurs ne peut pas être vide." -#: pkg/campsite/types/admin.go:508 +#: pkg/campsite/types/admin.go:539 msgid "Maximum number of campers must be an integer number." msgstr "Le nombre maximum de campeurs doit être un nombre entier." -#: pkg/campsite/types/admin.go:509 +#: pkg/campsite/types/admin.go:540 msgid "Maximum number of campers must be one or greater." msgstr "Le nombre maximum de campeurs doit être égal ou supérieur à un campeur." -#: pkg/campsite/types/admin.go:518 +#: pkg/campsite/types/admin.go:543 msgid "Minimum number of nights can not be empty." msgstr "Le nombre minimum de nuits ne peut pas être vide." -#: pkg/campsite/types/admin.go:519 +#: pkg/campsite/types/admin.go:544 msgid "Minimum number of nights must be an integer." msgstr "Le nombre minimum de nuits doit être un entier." -#: pkg/campsite/types/admin.go:520 +#: pkg/campsite/types/admin.go:545 msgid "Minimum number of nights must be one or greater." msgstr "Le nombre minimum de nuits doit être supérieur ou égal à une nuit." +#: pkg/campsite/types/admin.go:548 +msgid "Maximum number of nights can not be empty." +msgstr "Le nombre maximale de nuits ne peut pas être vide." + +#: pkg/campsite/types/admin.go:549 +msgid "Maximum number of nights must be an integer." +msgstr "Le nombre maximale de nuits doit être un entier." + +#: pkg/campsite/types/admin.go:550 +msgid "Maximum number of nights must be equal or greater than the minimum." +msgstr "Le nombre maximale de nuits doit être égal ou supérieur au minimum." + #: pkg/campsite/admin.go:275 pkg/booking/public.go:321 msgid "Selected campsite type is not valid." msgstr "Le type d’emplacement sélectionné n’est pas valide." diff --git a/revert/add_campsite_type.sql b/revert/add_campsite_type.sql index e0d414c..cddab29 100644 --- a/revert/add_campsite_type.sql +++ b/revert/add_campsite_type.sql @@ -4,23 +4,25 @@ -- requires: campsite_type -- requires: company -- requires: campsite_type__check_in_out +-- requires: campsite_type__overflow_allowed +-- requires: campsite_type__ask_zone_preferences begin; set search_path to camper, public; -drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean); +drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean); -create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean) returns uuid as +create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean) returns uuid as $$ - insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, dogs_allowed) - values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, dogs_allowed) + insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences) + values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences) returning slug; $$ language sql ; -revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean) from public; -grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean) to admin; +revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) from public; +grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) to admin; commit; diff --git a/revert/add_campsite_type@v3.sql b/revert/add_campsite_type@v3.sql new file mode 100644 index 0000000..e0d414c --- /dev/null +++ b/revert/add_campsite_type@v3.sql @@ -0,0 +1,26 @@ +-- Deploy camper:add_campsite_type to pg +-- requires: roles +-- requires: schema_camper +-- requires: campsite_type +-- requires: company +-- requires: campsite_type__check_in_out + +begin; + +set search_path to camper, public; + +drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean); + +create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean) returns uuid as +$$ + insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, dogs_allowed) + values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, dogs_allowed) + returning slug; +$$ + language sql +; + +revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean) from public; +grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean) to admin; + +commit; diff --git a/revert/campsite_type__bookable_nights.sql b/revert/campsite_type__bookable_nights.sql new file mode 100644 index 0000000..03b9bb9 --- /dev/null +++ b/revert/campsite_type__bookable_nights.sql @@ -0,0 +1,10 @@ +-- Revert camper:campsite_type__bookable_nights from pg + +begin; + + +alter table camper.campsite_type +drop column if exists bookable_nights +; + +commit; diff --git a/revert/campsite_type_cost__-min_nights.sql b/revert/campsite_type_cost__-min_nights.sql new file mode 100644 index 0000000..8155836 --- /dev/null +++ b/revert/campsite_type_cost__-min_nights.sql @@ -0,0 +1,21 @@ +-- Revert camper:campsite_type_cost__-min_nights from pg + +begin; + +set search_path to camper, public; + +alter table campsite_type_cost +add column if not exists min_nights integer not null default 1 constraint at_least_one_night check(min_nights > 0) +; + +update campsite_type_cost +set min_nights = lower(bookable_nights) +from campsite_type +where campsite_type.campsite_type_id = campsite_type_cost.campsite_type_id +; + +alter table campsite_type_cost +alter column min_nights drop default +; + +commit; diff --git a/revert/edit_campsite_type.sql b/revert/edit_campsite_type.sql index 5e3c235..35ee58f 100644 --- a/revert/edit_campsite_type.sql +++ b/revert/edit_campsite_type.sql @@ -4,14 +4,16 @@ -- requires: campsite_type -- requires: company -- requires: campsite_type__check_in_out +-- requires: campsite_type__overflow_allowed +-- requires: campsite_type__ask_zone_preferences begin; set search_path to camper, public; -drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean); +drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean, boolean); -create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, active boolean) returns uuid as +create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, overflow_allowed boolean, ask_zone_preferences boolean, active boolean) returns uuid as $$ update campsite_type set name = edit_campsite_type.name @@ -25,6 +27,8 @@ $$ , media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id) , max_campers = edit_campsite_type.max_campers , dogs_allowed = edit_campsite_type.dogs_allowed + , overflow_allowed = edit_campsite_type.overflow_allowed + , ask_zone_preferences = edit_campsite_type.ask_zone_preferences , active = edit_campsite_type.active where slug = edit_campsite_type.slug returning slug; @@ -32,7 +36,7 @@ $$ language sql ; -revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean) from public; -grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean) to admin; +revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean) from public; +grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean) to admin; commit; diff --git a/revert/edit_campsite_type@v3.sql b/revert/edit_campsite_type@v3.sql new file mode 100644 index 0000000..5e3c235 --- /dev/null +++ b/revert/edit_campsite_type@v3.sql @@ -0,0 +1,38 @@ +-- Deploy camper:edit_campsite_type to pg +-- requires: roles +-- requires: schema_camper +-- requires: campsite_type +-- requires: company +-- requires: campsite_type__check_in_out + +begin; + +set search_path to camper, public; + +drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean); + +create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, dogs_allowed boolean, active boolean) returns uuid as +$$ + update campsite_type + set name = edit_campsite_type.name + , spiel = xmlparse(content edit_campsite_type.spiel) + , description = xmlparse(content edit_campsite_type.description) + , info = xmlparse(content edit_campsite_type.info) + , additional_info = xmlparse(content edit_campsite_type.additional_info) + , check_in = edit_campsite_type.check_in + , check_out = edit_campsite_type.check_out + , facilities = xmlparse(content edit_campsite_type.facilities) + , media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id) + , max_campers = edit_campsite_type.max_campers + , dogs_allowed = edit_campsite_type.dogs_allowed + , active = edit_campsite_type.active + where slug = edit_campsite_type.slug + returning slug; +$$ +language sql +; + +revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean) from public; +grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean) to admin; + +commit; diff --git a/revert/set_campsite_type_cost.sql b/revert/set_campsite_type_cost.sql index a27a107..feb16b2 100644 --- a/revert/set_campsite_type_cost.sql +++ b/revert/set_campsite_type_cost.sql @@ -1,7 +1,30 @@ --- Revert camper:set_campsite_type_cost from pg +-- Deploy camper:set_campsite_type_cost to pg +-- requires: roles +-- requires: schema_camper +-- requires: campsite_type_cost +-- requires: parse_price begin; -drop function if exists camper.set_campsite_type_cost(uuid, integer, integer, text, integer); +set search_path to camper, public; + +drop function if exists set_campsite_type_cost(uuid, integer, text, integer); + +create or replace function set_campsite_type_cost(slug uuid, season_id integer, min_nights integer, cost_per_night text, decimal_places integer default 2) returns void as +$$ + insert into campsite_type_cost (campsite_type_id, season_id, min_nights, cost_per_night) + select campsite_type_id, season_id, min_nights, parse_price(cost_per_night, decimal_places) + from campsite_type + where campsite_type.slug = set_campsite_type_cost.slug + on conflict (campsite_type_id, season_id) do update + set min_nights = excluded.min_nights + , cost_per_night = excluded.cost_per_night + ; +$$ + language sql +; + +revoke execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) from public; +grant execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) to admin; commit; diff --git a/revert/set_campsite_type_cost@v3.sql b/revert/set_campsite_type_cost@v3.sql new file mode 100644 index 0000000..a27a107 --- /dev/null +++ b/revert/set_campsite_type_cost@v3.sql @@ -0,0 +1,7 @@ +-- Revert camper:set_campsite_type_cost from pg + +begin; + +drop function if exists camper.set_campsite_type_cost(uuid, integer, integer, text, integer); + +commit; diff --git a/sqitch.plan b/sqitch.plan index 46593d0..ee8a8f0 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -222,3 +222,10 @@ campsite_type__overflow_allowed [campsite_type] 2024-01-29T01:05:11Z jordi fita campsite_type__ask_zone_preferences [campsite_type] 2024-01-29T01:08:14Z jordi fita mas # Add ask_zone_preferences column to campsite_type add_campsite_type [add_campsite_type@v2 campsite_type__overflow_allowed campsite_type__ask_zone_preferences] 2024-01-29T01:13:55Z jordi fita mas # Add overflow_allowed and ask_zone_preferences parameters to add_campsite_type edit_campsite_type [edit_campsite_type@v2 campsite_type__overflow_allowed campsite_type__ask_zone_preferences] 2024-01-29T01:18:03Z jordi fita mas # Add overflow_allowed and ask_zone_preferences parameters to edit_campsite_type +@v3 2024-01-31T20:40:16Z jordi fita mas # Tag v3 + +campsite_type__bookable_nights [campsite_type campsite_type_cost] 2024-01-31T19:45:46Z jordi fita mas # Add bookable_nights to campsite_type +add_campsite_type [add_campsite_type@v3 campsite_type__bookable_nights] 2024-01-31T20:46:47Z jordi fita mas # Add bookable_nights param to add_campsite_type +edit_campsite_type [edit_campsite_type@v3 campsite_type__bookable_nights] 2024-01-31T20:51:40Z jordi fita mas # Add bookable_nights param to edit_campsite_type +set_campsite_type_cost [set_campsite_type_cost@v3 campsite_type__bookable_nights] 2024-01-31T21:02:06Z jordi fita mas # Remove min_nights parameter from set_campsite_type_cost +campsite_type_cost__-min_nights [campsite_type__bookable_nights set_campsite_type_cost] 2024-01-31T21:46:33Z jordi fita mas # Remove min_nights field from campsite_type_cost relation diff --git a/test/add_campsite.sql b/test/add_campsite.sql index a33a831..20a8783 100644 --- a/test/add_campsite.sql +++ b/test/add_campsite.sql @@ -43,10 +43,10 @@ values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (4, 2, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers) -values (11, 1, 3, 'A', false, 5) - , (12, 1, 3, 'B', false, 5) - , (21, 2, 4, 'C', false, 5) +insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers, bookable_nights) +values (11, 1, 3, 'A', false, 5, '[1, 7]') + , (12, 1, 3, 'B', false, 5, '[2, 6]') + , (21, 2, 4, 'C', false, 5, '[3, 5]') ; select lives_ok( diff --git a/test/add_campsite_carousel_slide.sql b/test/add_campsite_carousel_slide.sql index 8d26156..3383471 100644 --- a/test/add_campsite_carousel_slide.sql +++ b/test/add_campsite_carousel_slide.sql @@ -51,9 +51,9 @@ values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (7, 1, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, 3, 'Type A', '

A

', 5, false, true) - , (11, 2, 4, 'Type A', '

A

', 5, false, true) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, 3, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 2, 4, 'Type A', '

A

', 5, '[2, 5]', false, true) ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/add_campsite_feature.sql b/test/add_campsite_feature.sql index f057db2..1d63ef0 100644 --- a/test/add_campsite_feature.sql +++ b/test/add_campsite_feature.sql @@ -43,9 +43,9 @@ insert into media (media_id, company_id, original_filename, content_hash) values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) -values (4, 1, 3, 'Type A', '

A

', true, false, 4) - , (5, 1, 3, 'Type B', '

B

', true, false, 5) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (4, 1, 3, 'Type A', '

A

', true, false, 4, '[1, 7]') + , (5, 1, 3, 'Type B', '

B

', true, false, 5, '[2, 5]') ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/add_campsite_type.sql b/test/add_campsite_type.sql index 9d2e798..1304273 100644 --- a/test/add_campsite_type.sql +++ b/test/add_campsite_type.sql @@ -9,15 +9,15 @@ set search_path to camper, public; select plan(13); -select has_function('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean']); -select function_lang_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'sql'); -select function_returns('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'uuid'); -select isnt_definer('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean']); -select volatility_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'volatile'); -select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'guest', array[]::text[]); -select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'employee', array[]::text[]); -select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'admin', array['EXECUTE']); -select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean'], 'authenticator', array[]::text[]); +select has_function('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean']); +select function_lang_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'sql'); +select function_returns('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'uuid'); +select isnt_definer('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean']); +select volatility_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'volatile'); +select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'guest', array[]::text[]); +select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'employee', array[]::text[]); +select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean'], 'authenticator', array[]::text[]); set client_min_messages to warning; @@ -44,19 +44,19 @@ values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a ; select lives_ok( - $$ select add_campsite_type(1, 3, 'Type A', '', '

Features

', '', '

This is what, exactly?

Dunno

', '', 'After 4 p.m.', '12 a.m.', 5, true, false, true) $$, + $$ select add_campsite_type(1, 3, 'Type A', '', '

Features

', '', '

This is what, exactly?

Dunno

', '', 'After 4 p.m.', '12 a.m.', 5, '[1, 7]', true, false, true) $$, 'Should be able to add a campsite type to the first company' ); select lives_ok( - $$ select add_campsite_type(2, 4, 'Type B', '

One

Two

', '', '

Pricing

', '', '

More

', 'After 9 p.m.', '9 a.m.', 2, false, true, false) $$, + $$ select add_campsite_type(2, 4, 'Type B', '

One

Two

', '', '

Pricing

', '', '

More

', 'After 9 p.m.', '9 a.m.', 2, '(1, 7)', false, true, false) $$, 'Should be able to add a campsite type to the second company' ); select bag_eq( - $$ select company_id, media_id, name, spiel::text, info::text, facilities::text, description::text, additional_info::text, check_in, check_out, active, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences from campsite_type $$, - $$ values (1, 3, 'Type A', '', '

Features

', '', '

This is what, exactly?

Dunno

', '', 'After 4 p.m.', '12 a.m.', true, 5, true, false, true) - , (2, 4, 'Type B', '

One

Two

', '', '

Pricing

', '', '

More

', 'After 9 p.m.', '9 a.m.', true, 2, false, true, false) + $$ select company_id, media_id, name, spiel::text, info::text, facilities::text, description::text, additional_info::text, check_in, check_out, active, max_campers, bookable_nights, dogs_allowed, overflow_allowed, ask_zone_preferences from campsite_type $$, + $$ values (1, 3, 'Type A', '', '

Features

', '', '

This is what, exactly?

Dunno

', '', 'After 4 p.m.', '12 a.m.', true, 5, int4range(1, 8), true, false, true) + , (2, 4, 'Type B', '

One

Two

', '', '

Pricing

', '', '

More

', 'After 9 p.m.', '9 a.m.', true, 2, int4range(2, 7), false, true, false) $$, 'Should have added all two campsite type' ); diff --git a/test/add_campsite_type_carousel_slide.sql b/test/add_campsite_type_carousel_slide.sql index 86633ac..8cf3d94 100644 --- a/test/add_campsite_type_carousel_slide.sql +++ b/test/add_campsite_type_carousel_slide.sql @@ -50,9 +50,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (6, 1, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) - , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite_type_carousel (campsite_type_id, media_id, caption) diff --git a/test/add_campsite_type_feature.sql b/test/add_campsite_type_feature.sql index 4efffe0..754c947 100644 --- a/test/add_campsite_type_feature.sql +++ b/test/add_campsite_type_feature.sql @@ -42,9 +42,9 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4) - , (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '

B

', true, false, 5) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4, '[1, 7]') + , (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '

B

', true, false, 5, '[2, 6]') ; select lives_ok( diff --git a/test/add_campsite_type_option.sql b/test/add_campsite_type_option.sql index 93829f3..592e765 100644 --- a/test/add_campsite_type_option.sql +++ b/test/add_campsite_type_option.sql @@ -42,9 +42,9 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4) - , (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '

B

', true, false, 5) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4, '[1, 7]') + , (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '

B

', true, false, 5, '[1, 6]') ; select lives_ok( diff --git a/test/booking.sql b/test/booking.sql index 9ebcb31..6330d0e 100644 --- a/test/booking.sql +++ b/test/booking.sql @@ -125,9 +125,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (10, 2, 'Wooden lodge', 6, false, 7) - , (12, 4, 'Bungalow', 8, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (10, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (12, 4, 'Bungalow', 8, false, 6, '[2, 6]') ; insert into booking (company_id, campsite_type_id, holder_name, arrival_date, departure_date, number_dogs, acsi_card) diff --git a/test/campsite.sql b/test/campsite.sql index 59b52d2..850efb1 100644 --- a/test/campsite.sql +++ b/test/campsite.sql @@ -102,9 +102,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers) -values (22, 2, 6, 'Wooden lodge', true, 5) - , (44, 4, 8, 'Bungalow', false, 4) +insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers, bookable_nights) +values (22, 2, 6, 'Wooden lodge', true, 5, '[1, 7]') + , (44, 4, 8, 'Bungalow', false, 4, '[2, 6]') ; insert into campsite (company_id, campsite_type_id, label) diff --git a/test/campsite_carousel.sql b/test/campsite_carousel.sql index 5461461..54c3594 100644 --- a/test/campsite_carousel.sql +++ b/test/campsite_carousel.sql @@ -93,9 +93,9 @@ values ( 6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff"," , (11, 4, 'text5.txt', sha256('content5')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (21, 2, 'Wooden lodge', 6, false, 7) - , (22, 4, 'Bungalow', 9, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (21, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (22, 4, 'Bungalow', 9, false, 6, '[2, 6]') ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/campsite_feature.sql b/test/campsite_feature.sql index 0395330..6ad978c 100644 --- a/test/campsite_feature.sql +++ b/test/campsite_feature.sql @@ -89,9 +89,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) - , (18, 4, 'Bungalow', 8, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]') ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/campsite_type.sql b/test/campsite_type.sql index 11f6294..550fe0f 100644 --- a/test/campsite_type.sql +++ b/test/campsite_type.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(106); +select plan(112); set search_path to camper, public; @@ -112,6 +112,11 @@ select col_not_null('campsite_type', 'check_out'); select col_has_default('campsite_type', 'check_out'); select col_default_is('campsite_type', 'check_out', ''); +select has_column('campsite_type', 'bookable_nights'); +select col_type_is('campsite_type', 'bookable_nights', 'int4range'); +select col_not_null('campsite_type', 'bookable_nights'); +select col_hasnt_default('campsite_type', 'bookable_nights'); + select has_column('campsite_type', 'active'); select col_type_is('campsite_type', 'active', 'boolean'); select col_not_null('campsite_type', 'active'); @@ -164,9 +169,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers) -values (2, 'Wooden lodge', 6, false, 7) - , (4, 'Bungalow', 8, false, 6) +insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (4, 'Bungalow', 8, false, 6, '[2, 6]') ; prepare campsite_type_data as @@ -187,7 +192,7 @@ reset role; select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog', 'co2'); select lives_ok( - $$ insert into campsite_type(company_id, name, media_id, dogs_allowed, max_campers) values (2, 'Another type', 6, true, 7) $$, + $$ insert into campsite_type(company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) values (2, 'Another type', 6, true, 7, '[1, 7]') $$, 'Admin from company 2 should be able to insert a new campsite type to that company.' ); @@ -228,7 +233,7 @@ select bag_eq( ); select throws_ok( - $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers) values (4, 'Another type', 6, true, 6) $$, + $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) values (4, 'Another type', 6, true, 6, '[1, 7]') $$, '42501', 'new row violates row-level security policy for table "campsite_type"', 'Admin from company 2 should NOT be able to insert new campsite types to company 4.' ); @@ -266,17 +271,29 @@ select bag_eq( ); select throws_ok( - $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers) values (2, ' ', 6, false, 5) $$, + $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) values (2, ' ', 6, false, 5, '[1, 7]') $$, '23514', 'new row for relation "campsite_type" violates check constraint "name_not_empty"', 'Should not be able to insert campsite types with a blank name.' ); select throws_ok( - $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers) values (2, 'Name', 6, false, 0) $$, + $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) values (2, 'Name', 6, false, 0, '[1, 7]') $$, '23514', 'new row for relation "campsite_type" violates check constraint "at_least_one_camper"', 'Should not be able to insert campsite types with no campers allowed.' ); +select throws_ok( + $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) values (2, 'Name', 6, false, 1, '[0, 7]') $$, + '23514', 'new row for relation "campsite_type" violates check constraint "at_least_one_night"', + 'Should not be able to insert campsite types that allows to book zero nights.' +); + +select throws_ok( + $$ insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) values (2, 'Name', 6, false, 1, '[1, 1)') $$, + '23514', 'new row for relation "campsite_type" violates check constraint "at_least_one_night"', + 'Should not be able to insert campsite types with no bookable nights.' +); + reset role; diff --git a/test/campsite_type_carousel.sql b/test/campsite_type_carousel.sql index 787c649..82c6d2a 100644 --- a/test/campsite_type_carousel.sql +++ b/test/campsite_type_carousel.sql @@ -92,9 +92,9 @@ values ( 6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff"," , (11, 4, 'text5.txt', sha256('content5')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (21, 2, 'Wooden lodge', 6, false, 7) - , (22, 4, 'Bungalow', 9, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (21, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (22, 4, 'Bungalow', 9, false, 6, '[2, 6]') ; insert into campsite_type_carousel (campsite_type_id, media_id, caption) diff --git a/test/campsite_type_cost.sql b/test/campsite_type_cost.sql index bbe91d8..72a53ac 100644 --- a/test/campsite_type_cost.sql +++ b/test/campsite_type_cost.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(47); +select plan(42); set search_path to camper, public; @@ -36,11 +36,6 @@ select col_type_is('campsite_type_cost', 'cost_per_night', 'integer'); select col_not_null('campsite_type_cost', 'cost_per_night'); select col_hasnt_default('campsite_type_cost', 'cost_per_night'); -select has_column('campsite_type_cost', 'min_nights'); -select col_type_is('campsite_type_cost', 'min_nights', 'integer'); -select col_not_null('campsite_type_cost', 'min_nights'); -select col_hasnt_default('campsite_type_cost', 'min_nights'); - set client_min_messages to warning; truncate campsite_type_cost cascade; @@ -83,9 +78,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) - , (18, 4, 'Bungalow', 8, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]') ; insert into season (season_id, company_id, name) @@ -95,9 +90,9 @@ values (26, 2, 'Low') , (29, 4, 'Mid') ; -insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) -values (16, 26, 2, 2) - , (18, 28, 4, 4) +insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) +values (16, 26, 2) + , (18, 28, 4) ; prepare campsite_season_data as @@ -118,7 +113,7 @@ reset role; select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog', 'co2'); select lives_ok( - $$ insert into campsite_type_cost(campsite_type_id, season_id, cost_per_night, min_nights) values (16, 27, 3, 3) $$, + $$ insert into campsite_type_cost(campsite_type_id, season_id, cost_per_night) values (16, 27, 3) $$, 'Admin from company 2 should be able to insert a new campsite type season to that company.' ); @@ -159,19 +154,19 @@ select bag_eq( ); select throws_ok( - $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) values (18, 29, 5, 5) $$, + $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) values (18, 29, 5) $$, '42501', 'new row violates row-level security policy for table "campsite_type_cost"', 'Admin from company 2 should NOT be able to insert new campsite type costs to company 4.' ); select throws_ok( - $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) values (18, 27, 5, 5) $$, + $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) values (18, 27, 5) $$, '42501', 'new row violates row-level security policy for table "campsite_type_cost"', 'Admin from company 2 should NOT be able to insert new row with a campsite type from company 4.' ); select throws_ok( - $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) values (16, 29, 5, 5) $$, + $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) values (16, 29, 5) $$, '42501', 'new row violates row-level security policy for table "campsite_type_cost"', 'Admin from company 2 should NOT be able to insert new row with a season from company 4.' ); @@ -225,16 +220,11 @@ select bag_eq( ); select throws_ok( - $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) values (16, 27, -1, 1) $$, + $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) values (16, 27, -1) $$, '23514', 'new row for relation "campsite_type_cost" violates check constraint "cost_not_negative"', 'Should not be able to insert campsite type costs with negative cost per night.' ); -select throws_ok( - $$ insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) values (16, 27, 1, 0) $$, - '23514', 'new row for relation "campsite_type_cost" violates check constraint "at_least_one_night"', - 'Should not be able to insert campsite type costs with at a night stay.' -); reset role; diff --git a/test/campsite_type_feature.sql b/test/campsite_type_feature.sql index 10db86f..e11b38c 100644 --- a/test/campsite_type_feature.sql +++ b/test/campsite_type_feature.sql @@ -88,9 +88,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) - , (18, 4, 'Bungalow', 8, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]') ; insert into campsite_type_feature (campsite_type_id, icon_name, name) diff --git a/test/campsite_type_option.sql b/test/campsite_type_option.sql index 6ac2f9a..37840b8 100644 --- a/test/campsite_type_option.sql +++ b/test/campsite_type_option.sql @@ -86,9 +86,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) - , (18, 4, 'Bungalow', 8, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]') ; insert into campsite_type_option (campsite_type_id, name, range) diff --git a/test/campsite_type_option_cost.sql b/test/campsite_type_option_cost.sql index 6719ece..0c48e94 100644 --- a/test/campsite_type_option_cost.sql +++ b/test/campsite_type_option_cost.sql @@ -79,9 +79,9 @@ values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (8, 4, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) - , (18, 4, 'Bungalow', 8, false, 6) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') + , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]') ; insert into season (season_id, company_id, name) diff --git a/test/edit_campsite.sql b/test/edit_campsite.sql index e9d774b..d7d9f95 100644 --- a/test/edit_campsite.sql +++ b/test/edit_campsite.sql @@ -40,10 +40,10 @@ insert into media (media_id, company_id, original_filename, content_hash) values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers) -values (11, 1, 3, 'Type A', false, 5) - , (12, 1, 3, 'Type B', false, 5) - , (13, 1, 3, 'Type C', false, 5) +insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers, bookable_nights) +values (11, 1, 3, 'Type A', false, 5, '[1, 7]') + , (12, 1, 3, 'Type B', false, 5, '[2, 6]') + , (13, 1, 3, 'Type C', false, 5, '[3, 5]') ; insert into campsite (campsite_id, company_id, campsite_type_id, label, info1, info2, active) diff --git a/test/edit_campsite_feature.sql b/test/edit_campsite_feature.sql index 838bf5a..0be57bc 100644 --- a/test/edit_campsite_feature.sql +++ b/test/edit_campsite_feature.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/edit_campsite_type.sql b/test/edit_campsite_type.sql index 79e7535..eb56572 100644 --- a/test/edit_campsite_type.sql +++ b/test/edit_campsite_type.sql @@ -9,15 +9,15 @@ set search_path to camper, public; select plan(12); -select has_function('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean']); -select function_lang_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'sql'); -select function_returns('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'uuid'); -select isnt_definer('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean']); -select volatility_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'volatile'); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'guest', array[]::text[]); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'employee', array[]::text[]); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'admin', array['EXECUTE']); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'boolean', 'boolean', 'boolean', 'boolean'], 'authenticator', array[]::text[]); +select has_function('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean']); +select function_lang_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'sql'); +select function_returns('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'uuid'); +select isnt_definer('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean']); +select volatility_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'volatile'); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'guest', array[]::text[]); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'employee', array[]::text[]); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'int4range', 'boolean', 'boolean', 'boolean', 'boolean'], 'authenticator', array[]::text[]); set client_min_messages to warning; truncate campsite_type cascade; @@ -43,25 +43,25 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};')) ; -insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences, active) -values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

1

', '

info 1

', '

facilities A

', '

A

', '

Additional A

', '', '', 5, false, true, false, true) - , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

2

', '

info 2

', '

facilities B

', '

B

', '

Additional B

', '', '', 4, true, false, true, false) +insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, bookable_nights, dogs_allowed, overflow_allowed, ask_zone_preferences, active) +values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

1

', '

info 1

', '

facilities A

', '

A

', '

Additional A

', '', '', 5, '[1, 7]', false, true, false, true) + , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

2

', '

info 2

', '

facilities B

', '

B

', '

Additional B

', '', '', 4, '[2, 6]', true, false, true, false) ; select lives_ok( - $$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '

A

', '

Features A

', '

Pricing 1

', '

1

', '

Additional 1

', 'Check-in 1', 'Check-out 1', 2, true, false, true, false) $$, + $$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '

A

', '

Features A

', '

Pricing 1

', '

1

', '

Additional 1

', 'Check-in 1', 'Check-out 1', 2, '(1, 7)', true, false, true, false) $$, 'Should be able to edit the first type' ); select lives_ok( - $$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', null, 'Type 2', '

B

', '

Features B

', '

Pricing 2

', '

2

', '

Additional 2

', 'Check-in 2', 'Check-out 2', 9, false, true, false, true) $$, + $$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', null, 'Type 2', '

B

', '

Features B

', '

Pricing 2

', '

2

', '

Additional 2

', 'Check-in 2', 'Check-out 2', 9, '(2, 6)', false, true, false, true) $$, 'Should be able to edit the second type' ); select bag_eq( - $$ select slug::text, media_id, name, spiel::text, info::text, facilities::text, description::text, additional_info::text, check_in, check_out, max_campers, dogs_allowed, overflow_allowed, ask_zone_preferences, active from campsite_type $$, - $$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '

A

', '

Features A

', '

Pricing 1

', '

1

', '

Additional 1

', 'Check-in 1', 'Check-out 1', 2, true, false, true, false) - , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '

B

', '

Features B

', '

Pricing 2

', '

2

', '

Additional 2

', 'Check-in 2', 'Check-out 2', 9, false, true, false, true) + $$ select slug::text, media_id, name, spiel::text, info::text, facilities::text, description::text, additional_info::text, check_in, check_out, max_campers, bookable_nights, dogs_allowed, overflow_allowed, ask_zone_preferences, active from campsite_type $$, + $$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '

A

', '

Features A

', '

Pricing 1

', '

1

', '

Additional 1

', 'Check-in 1', 'Check-out 1', 2, int4range(2, 7), true, false, true, false) + , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '

B

', '

Features B

', '

Pricing 2

', '

2

', '

Additional 2

', 'Check-in 2', 'Check-out 2', 9, int4range(3, 6), false, true, false, true) $$, 'Should have updated all campsite types.' ); diff --git a/test/edit_campsite_type_feature.sql b/test/edit_campsite_type_feature.sql index 457442c..148c65e 100644 --- a/test/edit_campsite_type_feature.sql +++ b/test/edit_campsite_type_feature.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) diff --git a/test/edit_campsite_type_option.sql b/test/edit_campsite_type_option.sql index d410438..b25d57a 100644 --- a/test/edit_campsite_type_option.sql +++ b/test/edit_campsite_type_option.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) diff --git a/test/order_campsite_carousel.sql b/test/order_campsite_carousel.sql index 1bfff74..f27c033 100644 --- a/test/order_campsite_carousel.sql +++ b/test/order_campsite_carousel.sql @@ -56,9 +56,9 @@ values ( 3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff"," , (12, 1, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) -values (13, 1, 3, 'Type A', '

A

', 5, false, true) - , (14, 2, 8, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (13, 1, 3, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (14, 2, 8, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/order_campsite_features.sql b/test/order_campsite_features.sql index 9ad0d3a..19645d3 100644 --- a/test/order_campsite_features.sql +++ b/test/order_campsite_features.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/order_campsite_type_carousel.sql b/test/order_campsite_type_carousel.sql index e81d6b8..15e9949 100644 --- a/test/order_campsite_type_carousel.sql +++ b/test/order_campsite_type_carousel.sql @@ -50,9 +50,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (6, 1, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) - , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite_type_carousel (campsite_type_id, media_id, caption) diff --git a/test/order_campsite_type_features.sql b/test/order_campsite_type_features.sql index 8b48a77..12c5e2e 100644 --- a/test/order_campsite_type_features.sql +++ b/test/order_campsite_type_features.sql @@ -56,8 +56,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (6, 2, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) -values (16, 2, 'Wooden lodge', 6, false, 7) +insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers, bookable_nights) +values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]') ; insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) diff --git a/test/order_campsite_type_options.sql b/test/order_campsite_type_options.sql index c1d7fa8..2192029 100644 --- a/test/order_campsite_type_options.sql +++ b/test/order_campsite_type_options.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) diff --git a/test/order_campsite_types.sql b/test/order_campsite_types.sql index 3c2411a..97ced20 100644 --- a/test/order_campsite_types.sql +++ b/test/order_campsite_types.sql @@ -40,12 +40,12 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, max_campers, dogs_allowed, active) -values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'A', '', '', '', '', 5, false, true) - , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 2, 'B', '', '', '', '', 5, false, true) - , (1, 'b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 2, 'C', '', '', '', '', 5, false, true) - , (1, '8c4465ec-a690-43d7-854b-7fcd35fccb1c', 2, 'D', '', '', '', '', 5, false, true) - , (1, 'd28c30fb-57ac-4243-a8c3-ad1a26637f5a', 2, 'E', '', '', '', '', 5, false, true) +insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, max_campers, bookable_nights, dogs_allowed, active) +values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'A', '', '', '', '', 5, '[1, 7]', false, true) + , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 2, 'B', '', '', '', '', 5, '[2, 6]', false, true) + , (1, 'b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 2, 'C', '', '', '', '', 5, '[3, 5]', false, true) + , (1, '8c4465ec-a690-43d7-854b-7fcd35fccb1c', 2, 'D', '', '', '', '', 5, '[4, 8]', false, true) + , (1, 'd28c30fb-57ac-4243-a8c3-ad1a26637f5a', 2, 'E', '', '', '', '', 5, '[5, 9]', false, true) ; select lives_ok( diff --git a/test/remove_campsite_carousel_slide.sql b/test/remove_campsite_carousel_slide.sql index 8946f47..6f70df4 100644 --- a/test/remove_campsite_carousel_slide.sql +++ b/test/remove_campsite_carousel_slide.sql @@ -51,9 +51,9 @@ values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (7, 2, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, 3, 'Type A', '

A

', 5, false, true) - , (11, 2, 7, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, 3, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 2, 7, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite (campsite_id, label, company_id, campsite_type_id) diff --git a/test/remove_campsite_feature.sql b/test/remove_campsite_feature.sql index 77ff46c..f036da6 100644 --- a/test/remove_campsite_feature.sql +++ b/test/remove_campsite_feature.sql @@ -47,8 +47,8 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/remove_campsite_type_carousel_slide.sql b/test/remove_campsite_type_carousel_slide.sql index bfcd7ea..957028a 100644 --- a/test/remove_campsite_type_carousel_slide.sql +++ b/test/remove_campsite_type_carousel_slide.sql @@ -48,9 +48,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (6, 1, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) - , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite_type_carousel (campsite_type_id, media_id, caption) diff --git a/test/remove_campsite_type_feature.sql b/test/remove_campsite_type_feature.sql index 0f5b56a..8b950a3 100644 --- a/test/remove_campsite_type_feature.sql +++ b/test/remove_campsite_type_feature.sql @@ -46,9 +46,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) - , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) diff --git a/test/remove_campsite_type_option.sql b/test/remove_campsite_type_option.sql index bc5cd65..4216c77 100644 --- a/test/remove_campsite_type_option.sql +++ b/test/remove_campsite_type_option.sql @@ -47,9 +47,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) - , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) diff --git a/test/set_campsite_type_cost.sql b/test/set_campsite_type_cost.sql index 1aa5598..a9f0bd8 100644 --- a/test/set_campsite_type_cost.sql +++ b/test/set_campsite_type_cost.sql @@ -9,15 +9,15 @@ select plan(13); set search_path to camper, public; -select has_function('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer']); -select function_lang_is('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer'], 'sql'); -select function_returns('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer'], 'void'); -select isnt_definer('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer']); -select volatility_is('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer'], 'volatile'); -select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'integer', 'text', 'integer'], 'guest', array[]::text[]); -select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'integer', 'text', 'integer'], 'employee', array[]::text[]); -select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'integer', 'text', 'integer'], 'admin', array['EXECUTE']); -select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'integer', 'text', 'integer'], 'authenticator', array[]::text[]); +select has_function('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'text', 'integer']); +select function_lang_is('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'text', 'integer'], 'sql'); +select function_returns('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'text', 'integer'], 'void'); +select isnt_definer('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'text', 'integer']); +select volatility_is('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'text', 'integer'], 'volatile'); +select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'text', 'integer'], 'guest', array[]::text[]); +select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'text', 'integer'], 'employee', array[]::text[]); +select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'text', 'integer'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'text', 'integer'], 'authenticator', array[]::text[]); set client_min_messages to warning; truncate campsite_type_cost cascade; @@ -41,8 +41,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '', 5, false, true) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '', 5, '[1, 7]', false, true) ; insert into season (season_id, company_id, name) @@ -51,31 +51,31 @@ values (4, 1, 'High') , (6, 1, 'Low') ; -insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) -values (3, 4, 44, 4) - , (3, 5, 55, 5) +insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night) +values (3, 4, 44) + , (3, 5, 55) ; select lives_ok( - $$ select set_campsite_type_cost('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 2, '12.34') $$, + $$ select set_campsite_type_cost('87452b88-b48f-48d3-bb6c-0296de64164e', 4, '12.34') $$, 'Should be able to edit the cost for high season' ); select lives_ok( - $$ select set_campsite_type_cost('87452b88-b48f-48d3-bb6c-0296de64164e', 5, 6, '0.0') $$, + $$ select set_campsite_type_cost('87452b88-b48f-48d3-bb6c-0296de64164e', 5, '0.0') $$, 'Should be able to set the cost for mid season to zero' ); select lives_ok( - $$ select set_campsite_type_cost('87452b88-b48f-48d3-bb6c-0296de64164e', 6, 1, '3.21') $$, + $$ select set_campsite_type_cost('87452b88-b48f-48d3-bb6c-0296de64164e', 6, '3.21') $$, 'Should be able to set the cost for low season, adding it.' ); select bag_eq( - $$ select campsite_type_id, season_id, cost_per_night, min_nights from campsite_type_cost $$, - $$ values (3, 4, 1234, 2) - , (3, 5, 0, 6) - , (3, 6, 321, 1) + $$ select campsite_type_id, season_id, cost_per_night from campsite_type_cost $$, + $$ values (3, 4, 1234) + , (3, 5, 0) + , (3, 6, 321) $$, 'Should have updated all campsite type costs.' ); diff --git a/test/set_campsite_type_option_cost.sql b/test/set_campsite_type_option_cost.sql index f0d48f6..9b60047 100644 --- a/test/set_campsite_type_option_cost.sql +++ b/test/set_campsite_type_option_cost.sql @@ -43,8 +43,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '', 5, false, true) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '', 5, '[1, 7]', false, true) ; insert into season (season_id, company_id, name) diff --git a/test/translate_campsite.sql b/test/translate_campsite.sql index 31e9d94..f6be704 100644 --- a/test/translate_campsite.sql +++ b/test/translate_campsite.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers) -values (11, 1, 3, 'Type A', false, 5) +insert into campsite_type (campsite_type_id, company_id, media_id, name, dogs_allowed, max_campers, bookable_nights) +values (11, 1, 3, 'Type A', false, 5, '[1, 7]') ; insert into campsite (campsite_id, company_id, campsite_type_id, label, info1, info2, active) diff --git a/test/translate_campsite_carousel_slide.sql b/test/translate_campsite_carousel_slide.sql index 7879c97..f2d6451 100644 --- a/test/translate_campsite_carousel_slide.sql +++ b/test/translate_campsite_carousel_slide.sql @@ -51,9 +51,9 @@ values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (7, 2, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, 3, 'Type A', '

A

', 5, false, true) - , (11, 2, 7, 'Type B', '

B

', 7, true, false) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, 3, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 2, 7, 'Type B', '

B

', 7, '[2, 6]', true, false) ; insert into campsite (campsite_id, label, company_id, campsite_type_id) diff --git a/test/translate_campsite_feature.sql b/test/translate_campsite_feature.sql index 79beb11..b178a95 100644 --- a/test/translate_campsite_feature.sql +++ b/test/translate_campsite_feature.sql @@ -42,8 +42,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite (campsite_id, company_id, label, campsite_type_id) diff --git a/test/translate_campsite_type.sql b/test/translate_campsite_type.sql index 3b134fd..42c9f07 100644 --- a/test/translate_campsite_type.sql +++ b/test/translate_campsite_type.sql @@ -43,9 +43,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};')) ; -insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, active, dogs_allowed, max_campers) -values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

One

', '

Features A

', '

Pricing A

', '

A

', '

Additional A

', '', '', true, false, 4) - , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

Two

', '

Features B

', '

Pricing B

', '

B

', '

Additional B

', '', '', false, true, 5) +insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, active, dogs_allowed, max_campers, bookable_nights) +values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

One

', '

Features A

', '

Pricing A

', '

A

', '

Additional A

', '', '', true, false, 4, '[1, 7]') + , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

Two

', '

Features B

', '

Pricing B

', '

B

', '

Additional B

', '', '', false, true, 5, '[2, 6]') ; insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, info, facilities, description, additional_info, check_in, check_out) diff --git a/test/translate_campsite_type_carousel_slide.sql b/test/translate_campsite_type_carousel_slide.sql index a6204eb..96c29d0 100644 --- a/test/translate_campsite_type_carousel_slide.sql +++ b/test/translate_campsite_type_carousel_slide.sql @@ -48,9 +48,9 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a , (6, 1, 'image.svg', sha256('')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) -values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) - , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, bookable_nights, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, '[1, 7]', false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, '[2, 6]', true, false) ; insert into campsite_type_carousel (campsite_type_id, media_id, caption) diff --git a/test/translate_campsite_type_feature.sql b/test/translate_campsite_type_feature.sql index 6359b1c..d41412d 100644 --- a/test/translate_campsite_type_feature.sql +++ b/test/translate_campsite_type_feature.sql @@ -41,8 +41,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) diff --git a/test/translate_campsite_type_option.sql b/test/translate_campsite_type_option.sql index 5ff1358..c8186f5 100644 --- a/test/translate_campsite_type_option.sql +++ b/test/translate_campsite_type_option.sql @@ -41,8 +41,8 @@ insert into media (media_id, company_id, original_filename, content_hash) values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) ; -insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers) -values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4) +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, active, dogs_allowed, max_campers, bookable_nights) +values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', true, false, 4, '[1, 7]') ; insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) diff --git a/verify/add_campsite_type.sql b/verify/add_campsite_type.sql index 53e3e64..707916e 100644 --- a/verify/add_campsite_type.sql +++ b/verify/add_campsite_type.sql @@ -2,6 +2,6 @@ begin; -select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean)', 'execute'); +select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean)', 'execute'); rollback; diff --git a/verify/add_campsite_type@v3.sql b/verify/add_campsite_type@v3.sql new file mode 100644 index 0000000..53e3e64 --- /dev/null +++ b/verify/add_campsite_type@v3.sql @@ -0,0 +1,7 @@ +-- Verify camper:add_campsite_type on pg + +begin; + +select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean)', 'execute'); + +rollback; diff --git a/verify/campsite_type__bookable_nights.sql b/verify/campsite_type__bookable_nights.sql new file mode 100644 index 0000000..eef996d --- /dev/null +++ b/verify/campsite_type__bookable_nights.sql @@ -0,0 +1,10 @@ +-- Verify camper:campsite_type__bookable_nights on pg + +begin; + +select bookable_nights +from camper.campsite_type +where false +; + +rollback; diff --git a/verify/campsite_type_cost__-min_nights.sql b/verify/campsite_type_cost__-min_nights.sql new file mode 100644 index 0000000..948308c --- /dev/null +++ b/verify/campsite_type_cost__-min_nights.sql @@ -0,0 +1,11 @@ +-- Verify camper:campsite_type_cost__-min_nights on pg + +begin; + +select 1 / (1 - count(*)) +from pg_attribute +where attrelid = 'camper.campsite_type_cost'::regclass + and attname = 'min_nights' +; + +rollback; diff --git a/verify/edit_campsite_type.sql b/verify/edit_campsite_type.sql index a2870bb..71bc5ba 100644 --- a/verify/edit_campsite_type.sql +++ b/verify/edit_campsite_type.sql @@ -2,6 +2,6 @@ begin; -select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean)', 'execute'); +select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean, boolean, boolean)', 'execute'); rollback; diff --git a/verify/edit_campsite_type@v3.sql b/verify/edit_campsite_type@v3.sql new file mode 100644 index 0000000..a2870bb --- /dev/null +++ b/verify/edit_campsite_type@v3.sql @@ -0,0 +1,7 @@ +-- Verify camper:edit_campsite_type on pg + +begin; + +select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean, boolean)', 'execute'); + +rollback; diff --git a/verify/set_campsite_type_cost.sql b/verify/set_campsite_type_cost.sql index df882b3..f89f497 100644 --- a/verify/set_campsite_type_cost.sql +++ b/verify/set_campsite_type_cost.sql @@ -2,6 +2,6 @@ begin; -select has_function_privilege('camper.set_campsite_type_cost(uuid, integer, integer, text, integer)', 'execute'); +select has_function_privilege('camper.set_campsite_type_cost(uuid, integer, text, integer)', 'execute'); rollback; diff --git a/verify/set_campsite_type_cost@v3.sql b/verify/set_campsite_type_cost@v3.sql new file mode 100644 index 0000000..df882b3 --- /dev/null +++ b/verify/set_campsite_type_cost@v3.sql @@ -0,0 +1,7 @@ +-- Verify camper:set_campsite_type_cost on pg + +begin; + +select has_function_privilege('camper.set_campsite_type_cost(uuid, integer, integer, text, integer)', 'execute'); + +rollback; diff --git a/web/static/booking-dates.js b/web/static/booking-dates.js index 84f002d..4df951a 100644 --- a/web/static/booking-dates.js +++ b/web/static/booking-dates.js @@ -11,7 +11,8 @@ return; } - arrivalDate.setUTCDate(arrivalDate.getUTCDate() + 1); + const minNights = Math.max(1, parseInt(departureDateField.dataset.minNights, 10)); + arrivalDate.setUTCDate(arrivalDate.getUTCDate() + minNights); const minDate = formatDate(arrivalDate); departureDateField.setAttribute('min', minDate); @@ -20,11 +21,14 @@ departureDateField.value = minDate; } - arrivalDate.setUTCDate(arrivalDate.getUTCDate() + 6); - const maxDate = formatDate(arrivalDate); - departureDateField.setAttribute('max', maxDate); - if (!isNaN(departureDate) && departureDate >= arrivalDate) { - departureDateField.value = maxDate; + const maxNights = parseInt(departureDateField.dataset.maxNights, 10); + if (maxNights > 0) { + arrivalDate.setUTCDate(arrivalDate.getUTCDate() + maxNights - minNights); + const maxDate = formatDate(arrivalDate); + departureDateField.setAttribute('max', maxDate); + if (!isNaN(departureDate) && departureDate >= arrivalDate) { + departureDateField.value = maxDate; + } } } diff --git a/web/templates/admin/campsite/type/form.gohtml b/web/templates/admin/campsite/type/form.gohtml index 655c912..d7e3a46 100644 --- a/web/templates/admin/campsite/type/form.gohtml +++ b/web/templates/admin/campsite/type/form.gohtml @@ -88,6 +88,22 @@ {{ template "error-message" . }} {{- end }} + {{ with .MinNights -}} + + {{- end }} + {{ with .MaxNights -}} + + {{- end }}
{{ with .MaxCampers -}} {{- end }} - {{ with .MinNights -}} - - {{- end }}
{{- end }} diff --git a/web/templates/public/campsite/type.gohtml b/web/templates/public/campsite/type.gohtml index d99ae92..19fa605 100644 --- a/web/templates/public/campsite/type.gohtml +++ b/web/templates/public/campsite/type.gohtml @@ -46,7 +46,9 @@ @@ -90,8 +92,8 @@ {{ range .Options }}
{{ printf (gettext "%s: %s €/night") .OptionName .PricePerNight }}
{{- end }} - {{ if gt .MinNights 1 -}} -
{{ printf (gettext "*Minimum %d nights per stay") .MinNights }}
+ {{ if gt $.MinNights 1 -}} +
{{ printf (gettext "*Minimum %d nights per stay") $.MinNights }}
{{- end }} {{- end }}