Replace min_nights from campsite_type_costs to range in campsite_type

Customer told us that the minimum number of nights is per campsite type,
not per season.  And he wants this, along with the maximum number of
nights, in order to limit the range of departure dates that guests can
choose when booking.
This commit is contained in:
jordi fita mas 2024-01-31 23:06:45 +01:00
parent 4f04d973c2
commit 4adad7fa7d
78 changed files with 905 additions and 462 deletions

View File

@ -127,11 +127,11 @@ select translate_services_carousel_slide(63, 'en', 'Safari Tents');
select translate_services_carousel_slide(63, 'es', 'Tiendas Safari'); select translate_services_carousel_slide(63, 'es', 'Tiendas Safari');
alter table campsite_type alter column campsite_type_id restart with 72; alter table campsite_type alter column campsite_type_id restart with 72;
select add_campsite_type(52, 62, 'Parceŀles', '<h3>Acampa enmig de la natura</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Parcel·les amples amb serveis a prop don ets per fer allò que vols.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 6, true, true, true); select add_campsite_type(52, 62, 'Parceŀles', '<h3>Acampa enmig de la natura</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Parcel·les amples amb serveis a prop don ets per fer allò que vols.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 6, '[1, 7]', true, true, true);
select add_campsite_type(52, 63, 'Safari Tents', '<h3>Glàmping a la teva disposició</h3><p>Un luxe de tendes per viure aventures.</p><p>Dues tendes amb terra de fusta, llits, cuina i tot de comoditats per gaudir de les teves vacances.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '16 h a 21 h', '10 h', 6, false, false, false); select add_campsite_type(52, 63, 'Safari Tents', '<h3>Glàmping a la teva disposició</h3><p>Un luxe de tendes per viure aventures.</p><p>Dues tendes amb terra de fusta, llits, cuina i tot de comoditats per gaudir de les teves vacances.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '16 h a 21 h', '10 h', 6, '[2, 7]', false, false, false);
select add_campsite_type(52, 64, 'Bungalous', '<h3>Allotjaments de luxe</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 5, false, false, false); select add_campsite_type(52, 64, 'Bungalous', '<h3>Allotjaments de luxe</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 5, '[2, 7]', false, false, false);
select add_campsite_type(52, 65, 'Bungalous prèmium', '<h3>Allotjaments de luxe</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 5, false, false, false); select add_campsite_type(52, 65, 'Bungalous prèmium', '<h3>Allotjaments de luxe</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 5, '[2, 7]', false, false, false);
select add_campsite_type(52, 66, 'Cabanes de fusta', '<h3>Allotjaments de luxe</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '15 h a 21 h', '12 h', 5, false, false, false); select add_campsite_type(52, 66, 'Cabanes de fusta', '<h3>Allotjaments de luxe</h3><p>Ubicats al costat muntanya del càmping i amb vista a la natura que ens envolta.</p><p>Dues cabanes de fusta massissa de dues plantes i amb porxo cobert per gaudir entre arbres.</p>', '<h4>Proxo/terrassa (13 m²)</h4><ul><li>Moblat</li></ul><h4>Planta baixa (32 m²)</h4><ul><li>Sala menjador</li><li>Cuina equipada</li><li>Una habitació llit doble (150×200)</li><li>Bany complet</li></ul><h4>Planta altell (16 m²)</h4><ul><li>Tres llits individuals (90×200)</li></ul>', '<h4>El preu inclou</h4><ul><li>Llençols i nòrdic</li><li>Cistella de benvinguda: oli doliva, sal, sucre, cafè i te</li><li>WiFi</li><li>Plaça daparcament per un cotxe</li><li>Kit nadó (bressol, trona i banyera) <em>sota reserva</em></li></ul><p>* Tovalloles: preu extra</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '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) 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', '<h3>Camp in the middle of nature</h3><p>Located on the campgrounds mountain-side and overlooking the nature that surrounds us.</p><p>Large plots with serivces close to where you are to do what you want.</p>', '<h4>Porch/terrace (13 m²)</h4><ul><li>Furnished</li></ul><h4>First floor (32 m²)</h4><ul><li>Dining room</li><li>Equipped kitchen</li><li>One room with a double bed (150×200)</li><li>Full bathroom</li></ul><h4>Loft floor (16 m²)</h4><ul><li>Three individual beds (90×200)</li></ul>', '<h4>Price includes</h4><ul><li>Sheets and duvet</li><li>Welcome basket: olive oil, salt, sugar, coffee, and tea</li><li>WiFi</li><li>Parking space for one car</li><li>Baby Kit (bassinet, high chair, and bathtub) <em>reservation required</em></li></ul><p>* Towels: extra cost</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '3 p.m. to 9 p.m.', '12 a.m.') values (72, 'en', 'Plots', '<h3>Camp in the middle of nature</h3><p>Located on the campgrounds mountain-side and overlooking the nature that surrounds us.</p><p>Large plots with serivces close to where you are to do what you want.</p>', '<h4>Porch/terrace (13 m²)</h4><ul><li>Furnished</li></ul><h4>First floor (32 m²)</h4><ul><li>Dining room</li><li>Equipped kitchen</li><li>One room with a double bed (150×200)</li><li>Full bathroom</li></ul><h4>Loft floor (16 m²)</h4><ul><li>Three individual beds (90×200)</li></ul>', '<h4>Price includes</h4><ul><li>Sheets and duvet</li><li>Welcome basket: olive oil, salt, sugar, coffee, and tea</li><li>WiFi</li><li>Parking space for one car</li><li>Baby Kit (bassinet, high chair, and bathtub) <em>reservation required</em></li></ul><p>* Towels: extra cost</p>', '<p>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.</p><p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p><p>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.</p>', '', '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(93, '[2023-09-29, 2023-09-30]');
select set_season_range(94, '[2023-10-01, 2023-10-12]'); 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) select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 72;
values (72, 92, 20000, 1) select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 72;
, (72, 93, 16500, 1) select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 72;
, (72, 94, 12500, 1) select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 73;
, (73, 92, 20000, 2) select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 73;
, (73, 93, 16500, 2) select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 73;
, (73, 94, 12500, 2) select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 74;
, (74, 92, 20000, 2) select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 74;
, (74, 93, 16500, 2) select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 74;
, (74, 94, 12500, 2) select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 75;
, (75, 92, 20000, 2) select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 75;
, (75, 93, 16500, 2) select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 75;
, (75, 94, 12500, 2) select set_campsite_type_cost (slug, 92, '20.00') from campsite_type where campsite_type_id = 76;
, (76, 92, 20000, 2) select set_campsite_type_cost (slug, 93, '16.50') from campsite_type where campsite_type_id = 76;
, (76, 93, 16500, 2) select set_campsite_type_cost (slug, 94, '12.50') from campsite_type where campsite_type_id = 76;
, (76, 94, 12500, 2)
;
alter table campsite_type_option alter column campsite_type_option_id restart with 102; alter table campsite_type_option alter column campsite_type_option_id restart with 102;
insert into campsite_type_option (campsite_type_id, name, range) insert into campsite_type_option (campsite_type_id, name, range)

View File

@ -11,18 +11,18 @@ begin;
set search_path to camper, public; 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) 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, 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; returning slug;
$$ $$
language sql 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; 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, boolean, boolean, boolean) to admin; 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; commit;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -11,9 +11,9 @@ begin;
set search_path to camper, public; 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 update campsite_type
set name = edit_campsite_type.name set name = edit_campsite_type.name
@ -26,6 +26,7 @@ $$
, facilities = xmlparse(content edit_campsite_type.facilities) , facilities = xmlparse(content edit_campsite_type.facilities)
, media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id) , media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id)
, max_campers = edit_campsite_type.max_campers , max_campers = edit_campsite_type.max_campers
, bookable_nights = edit_campsite_type.bookable_nights
, dogs_allowed = edit_campsite_type.dogs_allowed , dogs_allowed = edit_campsite_type.dogs_allowed
, overflow_allowed = edit_campsite_type.overflow_allowed , overflow_allowed = edit_campsite_type.overflow_allowed
, ask_zone_preferences = edit_campsite_type.ask_zone_preferences , ask_zone_preferences = edit_campsite_type.ask_zone_preferences
@ -36,7 +37,7 @@ $$
language sql 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; 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, boolean, boolean, boolean, boolean) to admin; 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; commit;

View File

@ -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;

View File

@ -8,21 +8,22 @@ begin;
set search_path to camper, public; 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) insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night)
select campsite_type_id, season_id, min_nights, parse_price(cost_per_night, decimal_places) select campsite_type_id, season_id, parse_price(cost_per_night, decimal_places)
from campsite_type from campsite_type
where campsite_type.slug = set_campsite_type_cost.slug where campsite_type.slug = set_campsite_type_cost.slug
on conflict (campsite_type_id, season_id) do update on conflict (campsite_type_id, season_id) do update
set min_nights = excluded.min_nights set cost_per_night = excluded.cost_per_night
, cost_per_night = excluded.cost_per_night
; ;
$$ $$
language sql language sql
; ;
revoke execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) from public; revoke execute on function set_campsite_type_cost(uuid, integer, text, integer) from public;
grant execute on function set_campsite_type_cost(uuid, integer, integer, text, integer) to admin; grant execute on function set_campsite_type_cost(uuid, integer, text, integer) to admin;
commit; commit;

View File

@ -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;

View File

@ -1,3 +1,3 @@
package build package build
const Version = "1.2~git" const Version = "1.3~git"

View File

@ -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 { processTypeForm(w, r, user, company, conn, f, func(ctx context.Context, tx *database.Tx) error {
var err 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 { if err != nil {
return err 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 { func setTypePrices(ctx context.Context, tx *database.Tx, slug string, prices map[int]*typePriceForm) error {
for seasonID, p := range prices { 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 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) { 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 { 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 return err
} }
if err := translateTypes(ctx, tx, company, f); err != nil { if err := translateTypes(ctx, tx, company, f); err != nil {
@ -276,6 +276,8 @@ type typeForm struct {
Media *form.Media Media *form.Media
Name form.I18nInput Name form.I18nInput
MaxCampers *form.Input MaxCampers *form.Input
MinNights *form.Input
MaxNights *form.Input
DogsAllowed *form.Checkbox DogsAllowed *form.Checkbox
OverflowAllowed *form.Checkbox OverflowAllowed *form.Checkbox
AskZonePreferences *form.Checkbox AskZonePreferences *form.Checkbox
@ -292,7 +294,6 @@ type typeForm struct {
type typePriceForm struct { type typePriceForm struct {
SeasonName string SeasonName string
PricePerNight *form.Input PricePerNight *form.Input
MinNights *form.Input
} }
func newTypeForm(ctx context.Context, company *auth.Company, conn *database.Conn) (*typeForm, error) { 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{ MaxCampers: &form.Input{
Name: "max_campers", Name: "max_campers",
}, },
MinNights: &form.Input{
Name: "min_nights",
Val: "1",
},
MaxNights: &form.Input{
Name: "max_nights",
Val: "7",
},
DogsAllowed: &form.Checkbox{ DogsAllowed: &form.Checkbox{
Name: "dogs_allowed", 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), Name: fmt.Sprintf("season.%d.price_per_night", id),
Val: "0", 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 , campsite_type.check_out::text
, media_id::text , media_id::text
, max_campers::text , max_campers::text
, lower(bookable_nights)::text
, (upper(bookable_nights) - 1)::text
, dogs_allowed , dogs_allowed
, overflow_allowed , overflow_allowed
, ask_zone_preferences , ask_zone_preferences
@ -406,12 +413,38 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl
, campsite_type.check_out , campsite_type.check_out
, media_id::text , media_id::text
, max_campers::text , max_campers::text
, bookable_nights
, dogs_allowed , dogs_allowed
, overflow_allowed , overflow_allowed
, ask_zone_preferences , ask_zone_preferences
, active , active
`, pgx.QueryResultFormats{pgx.BinaryFormatCode}, slug) `, 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 return err
} }
if err := f.Name.FillArray(name); err != nil { 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, ` rows, err := conn.Query(ctx, `
select season_id select season_id
, min_nights::text
, to_price(cost_per_night) , to_price(cost_per_night)
from campsite_type from campsite_type
join campsite_type_cost using (campsite_type_id) 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() { for rows.Next() {
var seasonID int var seasonID int
var minNights string
var pricePerNight string var pricePerNight string
if err := rows.Scan(&seasonID, &minNights, &pricePerNight); err != nil { if err = rows.Scan(&seasonID, &pricePerNight); err != nil {
return err return err
} }
if p, ok := f.Prices[seasonID]; ok { if p, ok := f.Prices[seasonID]; ok {
p.MinNights.Val = minNights
p.PricePerNight.Val = pricePerNight p.PricePerNight.Val = pricePerNight
} }
} }
@ -474,6 +504,8 @@ func (f *typeForm) Parse(r *http.Request) error {
f.Active.FillValue(r) f.Active.FillValue(r)
f.Name.FillValue(r) f.Name.FillValue(r)
f.MaxCampers.FillValue(r) f.MaxCampers.FillValue(r)
f.MinNights.FillValue(r)
f.MaxNights.FillValue(r)
f.DogsAllowed.FillValue(r) f.DogsAllowed.FillValue(r)
f.OverflowAllowed.FillValue(r) f.OverflowAllowed.FillValue(r)
f.AskZonePreferences.FillValue(r) f.AskZonePreferences.FillValue(r)
@ -487,7 +519,6 @@ func (f *typeForm) Parse(r *http.Request) error {
f.Media.FillValue(r) f.Media.FillValue(r)
for _, p := range f.Prices { for _, p := range f.Prices {
p.PricePerNight.FillValue(r) p.PricePerNight.FillValue(r)
p.MinNights.FillValue(r)
} }
return nil 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.")) 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 { for _, p := range f.Prices {
if v.CheckRequired(p.PricePerNight, l.GettextNoop("Price per night can not be empty.")) { 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.")) { 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.")) 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 return v.AllOK, nil
} }

View File

@ -78,12 +78,13 @@ type publicPage struct {
AdditionalInfo gotemplate.HTML AdditionalInfo gotemplate.HTML
CheckIn string CheckIn string
CheckOut string CheckOut string
MinNights int
MaxNights int
} }
type typePrice struct { type typePrice struct {
SeasonName string SeasonName string
SeasonColor string SeasonColor string
MinNights int
PricePerNight string PricePerNight string
Options []*optionPrice 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.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_in, campsite_type.check_in)::text as l10n_check_in
, coalesce(i18n.check_out, campsite_type.check_out)::text as l10n_check_out , coalesce(i18n.check_out, campsite_type.check_out)::text as l10n_check_out
, lower(bookable_nights)
, upper(bookable_nights) - 1
, dogs_allowed , dogs_allowed
, '3.50' as dogs_prices , '3.50' as dogs_prices
from campsite_type from campsite_type
@ -136,7 +139,20 @@ func newPublicPage(ctx context.Context, company *auth.Company, conn *database.Co
where slug = $2 where slug = $2
and active and active
`, loc.Language, slug) `, 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 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 { 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, ` rows, err := conn.Query(ctx, `
select coalesce(i18n.name, season.name) as l10n_name select coalesce(i18n.name, season.name) as l10n_name
, to_color(season.color)::text , to_color(season.color)::text
, coalesce(cost.min_nights, 1)
, to_price(coalesce(cost.cost_per_night, 0)) , 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) , 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 from season
@ -169,7 +184,6 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T
group by i18n.name group by i18n.name
, season.name , season.name
, season.color , season.color
, cost.min_nights
, cost.cost_per_night , cost.cost_per_night
, season.position , season.position
order by season.position, l10n_name order by season.position, l10n_name
@ -182,7 +196,12 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T
for rows.Next() { for rows.Next() {
price := &typePrice{} price := &typePrice{}
var options database.RecordArray 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 return nil, err
} }
for _, el := range options.Elements { for _, el := range options.Elements {

View File

@ -130,12 +130,12 @@ func (c *Conn) RemoveCampsiteFeature(ctx context.Context, id int) error {
return err 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) { 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, $12, $13, $14)", companyID, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, dogsAllowed, overflowAllowed, askZonePreferences) 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) { 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, $12, $13, $14, $15)", slug, mediaID, name, spiel, info, facilities, description, additionalInfo, checkIn, checkOut, maxCampers, dogsAllowed, overflowAllowed, askZonePreferences, active) 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 { 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) _, 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 return err
} }
func (tx *Tx) SetCampsiteTypeCost(ctx context.Context, slug string, seasonID int, minNights int, costPerNight string) error { 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, $4)", slug, seasonID, minNights, costPerNight) _, err := tx.Exec(ctx, "select set_campsite_type_cost($1, $2, $3)", slug, seasonID, costPerNight)
return err return err
} }

133
po/ca.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: camper\n" "Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\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" "PO-Revision-Date: 2023-07-22 23:45+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n" "Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n" "Language-Team: Catalan <ca@dodds.net>\n"
@ -94,7 +94,7 @@ msgid "The campsite offers many different services."
msgstr "El càmping disposa de diversos serveis." msgstr "El càmping disposa de diversos serveis."
#: web/templates/public/amenity.gohtml:39 #: 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 #: web/templates/public/campsite/page.gohtml:39
msgctxt "title" msgctxt "title"
msgid "Features" msgid "Features"
@ -163,80 +163,80 @@ msgctxt "input"
msgid "Check-out Date" msgid "Check-out Date"
msgstr "Data de sortida" msgstr "Data de sortida"
#: web/templates/public/campsite/type.gohtml:54 #: web/templates/public/campsite/type.gohtml:56
#: web/templates/public/booking.gohtml:169 #: web/templates/public/booking.gohtml:171
msgctxt "action" msgctxt "action"
msgid "Book" msgid "Book"
msgstr "Reserva" msgstr "Reserva"
#: web/templates/public/campsite/type.gohtml:62 #: web/templates/public/campsite/type.gohtml:64
#: web/templates/admin/season/index.gohtml:54 #: web/templates/admin/season/index.gohtml:54
msgctxt "title" msgctxt "title"
msgid "Calendar" msgid "Calendar"
msgstr "Calendari" msgstr "Calendari"
#: web/templates/public/campsite/type.gohtml:73 #: web/templates/public/campsite/type.gohtml:75
#: web/templates/admin/campsite/type/form.gohtml:127 #: web/templates/admin/campsite/type/form.gohtml:143
#: web/templates/admin/campsite/type/option/form.gohtml:70 #: web/templates/admin/campsite/type/option/form.gohtml:70
msgctxt "title" msgctxt "title"
msgid "Prices" msgid "Prices"
msgstr "Preus" msgstr "Preus"
#: web/templates/public/campsite/type.gohtml:85 #: web/templates/public/campsite/type.gohtml:87
#: web/templates/public/campsite/type.gohtml:91 #: web/templates/public/campsite/type.gohtml:93
msgid "%s: %s €/night" msgid "%s: %s €/night"
msgstr "%s: %s €/nit" msgstr "%s: %s €/nit"
#: web/templates/public/campsite/type.gohtml:87 #: web/templates/public/campsite/type.gohtml:89
msgid "%s €/night" msgid "%s €/night"
msgstr "%s €/nit" msgstr "%s €/nit"
#: web/templates/public/campsite/type.gohtml:94 #: web/templates/public/campsite/type.gohtml:96
msgid "*Minimum %d nights per stay" msgid "*Minimum %d nights per stay"
msgstr "*Mínim %d nits per estada" 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." msgid "10 % VAT included."
msgstr "IVA del 10 % inclòs." 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." msgid "Tourist tax: %s/night per person aged 17 or older."
msgstr "Impost turístic: %s/nit per persona major de 16 anys." 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." msgid "Dogs: %s/night, tied, accompanied, and minimal barking."
msgstr "Gossos: %s/night, lligats, acompanyats i el mínim de lladrucs." 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." msgid "No dogs allowed."
msgstr "No es permeten gossos." msgstr "No es permeten gossos."
#: web/templates/public/campsite/type.gohtml:123 #: web/templates/public/campsite/type.gohtml:125
msgctxt "title" msgctxt "title"
msgid "Info" msgid "Info"
msgstr "Informació" msgstr "Informació"
#: web/templates/public/campsite/type.gohtml:127 #: web/templates/public/campsite/type.gohtml:129
msgctxt "title" msgctxt "title"
msgid "Facilities" msgid "Facilities"
msgstr "Equipaments" msgstr "Equipaments"
#: web/templates/public/campsite/type.gohtml:131 #: web/templates/public/campsite/type.gohtml:133
msgctxt "title" msgctxt "title"
msgid "Description" msgid "Description"
msgstr "Descripció" msgstr "Descripció"
#: web/templates/public/campsite/type.gohtml:135 #: web/templates/public/campsite/type.gohtml:137
msgctxt "title" msgctxt "title"
msgid "Additional Information" msgid "Additional Information"
msgstr "Informació addicional" msgstr "Informació addicional"
#: web/templates/public/campsite/type.gohtml:138 #: web/templates/public/campsite/type.gohtml:140
msgctxt "time" msgctxt "time"
msgid "Check-in" msgid "Check-in"
msgstr "Entrada" msgstr "Entrada"
#: web/templates/public/campsite/type.gohtml:142 #: web/templates/public/campsite/type.gohtml:144
msgctxt "time" msgctxt "time"
msgid "Check-out" msgid "Check-out"
msgstr "Sortida" msgstr "Sortida"
@ -560,17 +560,17 @@ msgctxt "input"
msgid "Arrival date" msgid "Arrival date"
msgstr "Data darribada" msgstr "Data darribada"
#: web/templates/public/booking.gohtml:138 #: web/templates/public/booking.gohtml:139
msgctxt "input" msgctxt "input"
msgid "Departure date" msgid "Departure date"
msgstr "Data de sortida" msgstr "Data de sortida"
#: web/templates/public/booking.gohtml:149 #: web/templates/public/booking.gohtml:151
msgctxt "input" msgctxt "input"
msgid "ACSI card? (optional)" msgid "ACSI card? (optional)"
msgstr "Targeta ACSI? (opcional)" msgstr "Targeta ACSI? (opcional)"
#: web/templates/public/booking.gohtml:156 #: web/templates/public/booking.gohtml:158
msgctxt "input" msgctxt "input"
msgid "I have read and I accept %[1]sthe reservation conditions%[2]s" 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" 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/form.gohtml:92
#: web/templates/admin/campsite/type/feature/form.gohtml:74 #: web/templates/admin/campsite/type/feature/form.gohtml:74
#: web/templates/admin/campsite/type/carousel/form.gohtml:59 #: 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/campsite/type/option/form.gohtml:90
#: web/templates/admin/season/form.gohtml:73 #: web/templates/admin/season/form.gohtml:73
#: web/templates/admin/services/form.gohtml:81 #: web/templates/admin/services/form.gohtml:81
@ -697,7 +697,7 @@ msgstr "Actualitza"
#: web/templates/admin/campsite/form.gohtml:94 #: web/templates/admin/campsite/form.gohtml:94
#: web/templates/admin/campsite/type/feature/form.gohtml:76 #: web/templates/admin/campsite/type/feature/form.gohtml:76
#: web/templates/admin/campsite/type/carousel/form.gohtml:61 #: 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/campsite/type/option/form.gohtml:92
#: web/templates/admin/season/form.gohtml:75 #: web/templates/admin/season/form.gohtml:75
#: web/templates/admin/services/form.gohtml:83 #: web/templates/admin/services/form.gohtml:83
@ -1110,60 +1110,65 @@ msgctxt "input"
msgid "Check-out" msgid "Check-out"
msgstr "Sortida" 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" msgctxt "input"
msgid "Maximum number of campers" msgid "Maximum number of campers"
msgstr "Número màxim de persones" 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" msgctxt "input"
msgid "Allow overflowing guests to neighbouring campsites" msgid "Allow overflowing guests to neighbouring campsites"
msgstr "Permet reservar allotjaments veïns si es supera el màxim de persones" 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" msgctxt "input"
msgid "Ask for zone preferences when booking" msgid "Ask for zone preferences when booking"
msgstr "Demana la preferència de zona durant la reserva" 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" msgctxt "input"
msgid "Dogs allowed" msgid "Dogs allowed"
msgstr "Es permeten gossos" 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 #: web/templates/admin/campsite/type/option/form.gohtml:76
msgctxt "input" msgctxt "input"
msgid "Price per night" msgid "Price per night"
msgstr "Preu per nit" msgstr "Preu per nit"
#: web/templates/admin/campsite/type/form.gohtml:141 #: web/templates/admin/campsite/type/form.gohtml:161
msgctxt "input"
msgid "Minimum number of nights"
msgstr "Número mínim de nits"
#: web/templates/admin/campsite/type/form.gohtml:153
msgctxt "input" msgctxt "input"
msgid "Spiel" msgid "Spiel"
msgstr "Introducció" msgstr "Introducció"
#: web/templates/admin/campsite/type/form.gohtml:166 #: web/templates/admin/campsite/type/form.gohtml:174
msgctxt "input" msgctxt "input"
msgid "Info" msgid "Info"
msgstr "Informació" msgstr "Informació"
#: web/templates/admin/campsite/type/form.gohtml:179 #: web/templates/admin/campsite/type/form.gohtml:187
msgctxt "input" msgctxt "input"
msgid "Facilities" msgid "Facilities"
msgstr "Equipaments" 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/services/form.gohtml:66
#: web/templates/admin/surroundings/form.gohtml:54 #: web/templates/admin/surroundings/form.gohtml:54
msgctxt "input" msgctxt "input"
msgid "Description" msgid "Description"
msgstr "Descripció" msgstr "Descripció"
#: web/templates/admin/campsite/type/form.gohtml:205 #: web/templates/admin/campsite/type/form.gohtml:213
msgctxt "input" msgctxt "input"
msgid "Additional Information" msgid "Additional Information"
msgstr "Informació addicional" msgstr "Informació addicional"
@ -1860,7 +1865,7 @@ msgid "No booking found."
msgstr "No sha trobat cap reserva." msgstr "No sha trobat cap reserva."
#: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357 #: 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/campsite/feature.go:269 pkg/season/admin.go:412
#: pkg/services/admin.go:316 pkg/surroundings/admin.go:340 #: pkg/services/admin.go:316 pkg/surroundings/admin.go:340
#: pkg/amenity/feature.go:269 pkg/amenity/admin.go:283 #: 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." msgstr "No podeu deixar el nom en blanc."
#: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358 #: 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 #: pkg/campsite/feature.go:270 pkg/amenity/feature.go:270
msgid "Name must have at least one letter." msgid "Name must have at least one letter."
msgstr "El nom ha de tenir com a mínim una lletra." 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." 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." 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." msgid "Price per night can not be empty."
msgstr "No podeu deixar el preu per nit en blanc." 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." msgid "Price per night must be a decimal number."
msgstr "El preu per nit ha de ser un número decimal." 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." msgid "Price per night must be zero or greater."
msgstr "El preu per nit ha de ser com a mínim zero." 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." msgid "Selected icon is not valid."
msgstr "La icona escollida no és vàlida." msgstr "La icona escollida no és vàlida."
#: pkg/campsite/types/admin.go:309 #: pkg/campsite/types/admin.go:310
msgctxt "input" msgctxt "input"
msgid "Cover image" msgid "Cover image"
msgstr "Imatge de portada" msgstr "Imatge de portada"
#: pkg/campsite/types/admin.go:310 #: pkg/campsite/types/admin.go:311
msgctxt "action" msgctxt "action"
msgid "Set campsite type cover" msgid "Set campsite type cover"
msgstr "Estableix la portada del tipus dallotjament" msgstr "Estableix la portada del tipus dallotjament"
#: pkg/campsite/types/admin.go:500 #: pkg/campsite/types/admin.go:531
msgid "Check-in can not be empty." msgid "Check-in can not be empty."
msgstr "No podeu deixar lentrada en blanc." msgstr "No podeu deixar lentrada en blanc."
#: pkg/campsite/types/admin.go:501 #: pkg/campsite/types/admin.go:532
msgid "Check-out can not be empty." msgid "Check-out can not be empty."
msgstr "No podeu deixar la sortida en blanc." 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." msgid "Cover image can not be empty."
msgstr "No podeu deixar la imatge de portada en blanc." 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." msgid "Cover image must be an image media type."
msgstr "La imatge de portada ha de ser un mèdia de tipus imatge." 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." msgid "Maximum number of campers can not be empty."
msgstr "No podeu deixar el número màxim de persones en blanc." 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." msgid "Maximum number of campers must be an integer number."
msgstr "El número màxim de persones ha de ser enter." 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." msgid "Maximum number of campers must be one or greater."
msgstr "El número màxim de persones no pot ser zero." 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." msgid "Minimum number of nights can not be empty."
msgstr "No podeu deixar el número mínim de nits en blanc." 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." msgid "Minimum number of nights must be an integer."
msgstr "El número mínim de nits ha de ser enter." 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." msgid "Minimum number of nights must be one or greater."
msgstr "El número mínim de nits no pot ser zero." 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 #: pkg/campsite/admin.go:275 pkg/booking/public.go:321
msgid "Selected campsite type is not valid." msgid "Selected campsite type is not valid."
msgstr "El tipus dallotjament escollit no és vàlid." msgstr "El tipus dallotjament escollit no és vàlid."

133
po/es.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: camper\n" "Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\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" "PO-Revision-Date: 2023-07-22 23:46+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n" "Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n" "Language-Team: Spanish <es@tp.org.es>\n"
@ -94,7 +94,7 @@ msgid "The campsite offers many different services."
msgstr "El camping dispone de varios servicios." msgstr "El camping dispone de varios servicios."
#: web/templates/public/amenity.gohtml:39 #: 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 #: web/templates/public/campsite/page.gohtml:39
msgctxt "title" msgctxt "title"
msgid "Features" msgid "Features"
@ -163,80 +163,80 @@ msgctxt "input"
msgid "Check-out Date" msgid "Check-out Date"
msgstr "Fecha de salida" msgstr "Fecha de salida"
#: web/templates/public/campsite/type.gohtml:54 #: web/templates/public/campsite/type.gohtml:56
#: web/templates/public/booking.gohtml:169 #: web/templates/public/booking.gohtml:171
msgctxt "action" msgctxt "action"
msgid "Book" msgid "Book"
msgstr "Reservar" msgstr "Reservar"
#: web/templates/public/campsite/type.gohtml:62 #: web/templates/public/campsite/type.gohtml:64
#: web/templates/admin/season/index.gohtml:54 #: web/templates/admin/season/index.gohtml:54
msgctxt "title" msgctxt "title"
msgid "Calendar" msgid "Calendar"
msgstr "Calendario" msgstr "Calendario"
#: web/templates/public/campsite/type.gohtml:73 #: web/templates/public/campsite/type.gohtml:75
#: web/templates/admin/campsite/type/form.gohtml:127 #: web/templates/admin/campsite/type/form.gohtml:143
#: web/templates/admin/campsite/type/option/form.gohtml:70 #: web/templates/admin/campsite/type/option/form.gohtml:70
msgctxt "title" msgctxt "title"
msgid "Prices" msgid "Prices"
msgstr "Precios" msgstr "Precios"
#: web/templates/public/campsite/type.gohtml:85 #: web/templates/public/campsite/type.gohtml:87
#: web/templates/public/campsite/type.gohtml:91 #: web/templates/public/campsite/type.gohtml:93
msgid "%s: %s €/night" msgid "%s: %s €/night"
msgstr "%s: %s €/noche" msgstr "%s: %s €/noche"
#: web/templates/public/campsite/type.gohtml:87 #: web/templates/public/campsite/type.gohtml:89
msgid "%s €/night" msgid "%s €/night"
msgstr "%s €/noche" msgstr "%s €/noche"
#: web/templates/public/campsite/type.gohtml:94 #: web/templates/public/campsite/type.gohtml:96
msgid "*Minimum %d nights per stay" msgid "*Minimum %d nights per stay"
msgstr "*Mínimo %d noches por estancia" 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." msgid "10 % VAT included."
msgstr "IVA del 10 % incluido." 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." 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." 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." msgid "Dogs: %s/night, tied, accompanied, and minimal barking."
msgstr "Perros: %s/noche, atados, acompañados y con mínimo de ladrido." 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." msgid "No dogs allowed."
msgstr "No se permiten perros" msgstr "No se permiten perros"
#: web/templates/public/campsite/type.gohtml:123 #: web/templates/public/campsite/type.gohtml:125
msgctxt "title" msgctxt "title"
msgid "Info" msgid "Info"
msgstr "Información" msgstr "Información"
#: web/templates/public/campsite/type.gohtml:127 #: web/templates/public/campsite/type.gohtml:129
msgctxt "title" msgctxt "title"
msgid "Facilities" msgid "Facilities"
msgstr "Equipamiento" msgstr "Equipamiento"
#: web/templates/public/campsite/type.gohtml:131 #: web/templates/public/campsite/type.gohtml:133
msgctxt "title" msgctxt "title"
msgid "Description" msgid "Description"
msgstr "Descripción" msgstr "Descripción"
#: web/templates/public/campsite/type.gohtml:135 #: web/templates/public/campsite/type.gohtml:137
msgctxt "title" msgctxt "title"
msgid "Additional Information" msgid "Additional Information"
msgstr "Información adicional" msgstr "Información adicional"
#: web/templates/public/campsite/type.gohtml:138 #: web/templates/public/campsite/type.gohtml:140
msgctxt "time" msgctxt "time"
msgid "Check-in" msgid "Check-in"
msgstr "Entrada" msgstr "Entrada"
#: web/templates/public/campsite/type.gohtml:142 #: web/templates/public/campsite/type.gohtml:144
msgctxt "time" msgctxt "time"
msgid "Check-out" msgid "Check-out"
msgstr "Salida" msgstr "Salida"
@ -560,17 +560,17 @@ msgctxt "input"
msgid "Arrival date" msgid "Arrival date"
msgstr "Fecha de llegada" msgstr "Fecha de llegada"
#: web/templates/public/booking.gohtml:138 #: web/templates/public/booking.gohtml:139
msgctxt "input" msgctxt "input"
msgid "Departure date" msgid "Departure date"
msgstr "Fecha de salida" msgstr "Fecha de salida"
#: web/templates/public/booking.gohtml:149 #: web/templates/public/booking.gohtml:151
msgctxt "input" msgctxt "input"
msgid "ACSI card? (optional)" msgid "ACSI card? (optional)"
msgstr "¿Tarjeta ACSI? (opcional)" msgstr "¿Tarjeta ACSI? (opcional)"
#: web/templates/public/booking.gohtml:156 #: web/templates/public/booking.gohtml:158
msgctxt "input" msgctxt "input"
msgid "I have read and I accept %[1]sthe reservation conditions%[2]s" 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" 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/form.gohtml:92
#: web/templates/admin/campsite/type/feature/form.gohtml:74 #: web/templates/admin/campsite/type/feature/form.gohtml:74
#: web/templates/admin/campsite/type/carousel/form.gohtml:59 #: 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/campsite/type/option/form.gohtml:90
#: web/templates/admin/season/form.gohtml:73 #: web/templates/admin/season/form.gohtml:73
#: web/templates/admin/services/form.gohtml:81 #: web/templates/admin/services/form.gohtml:81
@ -697,7 +697,7 @@ msgstr "Actualizar"
#: web/templates/admin/campsite/form.gohtml:94 #: web/templates/admin/campsite/form.gohtml:94
#: web/templates/admin/campsite/type/feature/form.gohtml:76 #: web/templates/admin/campsite/type/feature/form.gohtml:76
#: web/templates/admin/campsite/type/carousel/form.gohtml:61 #: 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/campsite/type/option/form.gohtml:92
#: web/templates/admin/season/form.gohtml:75 #: web/templates/admin/season/form.gohtml:75
#: web/templates/admin/services/form.gohtml:83 #: web/templates/admin/services/form.gohtml:83
@ -1110,60 +1110,65 @@ msgctxt "input"
msgid "Check-out" msgid "Check-out"
msgstr "Salida" 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" msgctxt "input"
msgid "Maximum number of campers" msgid "Maximum number of campers"
msgstr "Número máximo de personas" 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" msgctxt "input"
msgid "Allow overflowing guests to neighbouring campsites" msgid "Allow overflowing guests to neighbouring campsites"
msgstr "Permitir reservar alojamientos vecinos si se supera el máximo de personas" 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" msgctxt "input"
msgid "Ask for zone preferences when booking" msgid "Ask for zone preferences when booking"
msgstr "Pedir la preferencia de zona durante la reserva" 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" msgctxt "input"
msgid "Dogs allowed" msgid "Dogs allowed"
msgstr "Se permiten perros" 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 #: web/templates/admin/campsite/type/option/form.gohtml:76
msgctxt "input" msgctxt "input"
msgid "Price per night" msgid "Price per night"
msgstr "Precio por noche" msgstr "Precio por noche"
#: web/templates/admin/campsite/type/form.gohtml:141 #: web/templates/admin/campsite/type/form.gohtml:161
msgctxt "input"
msgid "Minimum number of nights"
msgstr "Número mínimos de noches"
#: web/templates/admin/campsite/type/form.gohtml:153
msgctxt "input" msgctxt "input"
msgid "Spiel" msgid "Spiel"
msgstr "Introducción" msgstr "Introducción"
#: web/templates/admin/campsite/type/form.gohtml:166 #: web/templates/admin/campsite/type/form.gohtml:174
msgctxt "input" msgctxt "input"
msgid "Info" msgid "Info"
msgstr "Información" msgstr "Información"
#: web/templates/admin/campsite/type/form.gohtml:179 #: web/templates/admin/campsite/type/form.gohtml:187
msgctxt "input" msgctxt "input"
msgid "Facilities" msgid "Facilities"
msgstr "Equipamento" 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/services/form.gohtml:66
#: web/templates/admin/surroundings/form.gohtml:54 #: web/templates/admin/surroundings/form.gohtml:54
msgctxt "input" msgctxt "input"
msgid "Description" msgid "Description"
msgstr "Descripción" msgstr "Descripción"
#: web/templates/admin/campsite/type/form.gohtml:205 #: web/templates/admin/campsite/type/form.gohtml:213
msgctxt "input" msgctxt "input"
msgid "Additional Information" msgid "Additional Information"
msgstr "Información adicional" msgstr "Información adicional"
@ -1860,7 +1865,7 @@ msgid "No booking found."
msgstr "No se ha encontrado ninguna reserva." msgstr "No se ha encontrado ninguna reserva."
#: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357 #: 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/campsite/feature.go:269 pkg/season/admin.go:412
#: pkg/services/admin.go:316 pkg/surroundings/admin.go:340 #: pkg/services/admin.go:316 pkg/surroundings/admin.go:340
#: pkg/amenity/feature.go:269 pkg/amenity/admin.go:283 #: 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." msgstr "No podéis dejar el nombre en blanco."
#: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358 #: 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 #: pkg/campsite/feature.go:270 pkg/amenity/feature.go:270
msgid "Name must have at least one letter." msgid "Name must have at least one letter."
msgstr "El nombre tiene que tener como mínimo una letra." 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." 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." 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." msgid "Price per night can not be empty."
msgstr "No podéis dejar el precio por noche en blanco." 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." msgid "Price per night must be a decimal number."
msgstr "El precio por noche tiene que ser un número decimal." 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." msgid "Price per night must be zero or greater."
msgstr "El precio por noche tiene que ser como mínimo cero." 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." msgid "Selected icon is not valid."
msgstr "El icono escogido no es válido." msgstr "El icono escogido no es válido."
#: pkg/campsite/types/admin.go:309 #: pkg/campsite/types/admin.go:310
msgctxt "input" msgctxt "input"
msgid "Cover image" msgid "Cover image"
msgstr "Imagen de portada" msgstr "Imagen de portada"
#: pkg/campsite/types/admin.go:310 #: pkg/campsite/types/admin.go:311
msgctxt "action" msgctxt "action"
msgid "Set campsite type cover" msgid "Set campsite type cover"
msgstr "Establecer la portada del tipo de alojamiento" 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." msgid "Check-in can not be empty."
msgstr "No podéis dejar la entrada en blanco." 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." msgid "Check-out can not be empty."
msgstr "No podéis dejar la salida en blanco." 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." msgid "Cover image can not be empty."
msgstr "No podéis dejar la imagen de portada en blanco." 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." msgid "Cover image must be an image media type."
msgstr "La imagen de portada tiene que ser un medio de tipo imagen." 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." msgid "Maximum number of campers can not be empty."
msgstr "No podéis dejar el número máximo de personas en blanco." 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." msgid "Maximum number of campers must be an integer number."
msgstr "El número máximo de personas tiene que ser entero." 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." msgid "Maximum number of campers must be one or greater."
msgstr "El número máximo de personas no puede ser cero." 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." msgid "Minimum number of nights can not be empty."
msgstr "No podéis dejar el número mínimo de noches en blanco." 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." msgid "Minimum number of nights must be an integer."
msgstr "El número mínimo de noches tiene que ser entero." 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." msgid "Minimum number of nights must be one or greater."
msgstr "El número mínimo de noches no puede ser cero." 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 #: pkg/campsite/admin.go:275 pkg/booking/public.go:321
msgid "Selected campsite type is not valid." msgid "Selected campsite type is not valid."
msgstr "El tipo de alojamiento escogido no es válido." msgstr "El tipo de alojamiento escogido no es válido."

133
po/fr.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: camper\n" "Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\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" "PO-Revision-Date: 2023-12-20 10:13+0100\n"
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n" "Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
"Language-Team: French <traduc@traduc.org>\n" "Language-Team: French <traduc@traduc.org>\n"
@ -95,7 +95,7 @@ msgid "The campsite offers many different services."
msgstr "Le camping propose de nombreux services différents." msgstr "Le camping propose de nombreux services différents."
#: web/templates/public/amenity.gohtml:39 #: 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 #: web/templates/public/campsite/page.gohtml:39
msgctxt "title" msgctxt "title"
msgid "Features" msgid "Features"
@ -164,80 +164,80 @@ msgctxt "input"
msgid "Check-out Date" msgid "Check-out Date"
msgstr "Date de départ" msgstr "Date de départ"
#: web/templates/public/campsite/type.gohtml:54 #: web/templates/public/campsite/type.gohtml:56
#: web/templates/public/booking.gohtml:169 #: web/templates/public/booking.gohtml:171
msgctxt "action" msgctxt "action"
msgid "Book" msgid "Book"
msgstr "Réserver" msgstr "Réserver"
#: web/templates/public/campsite/type.gohtml:62 #: web/templates/public/campsite/type.gohtml:64
#: web/templates/admin/season/index.gohtml:54 #: web/templates/admin/season/index.gohtml:54
msgctxt "title" msgctxt "title"
msgid "Calendar" msgid "Calendar"
msgstr "Calendrier" msgstr "Calendrier"
#: web/templates/public/campsite/type.gohtml:73 #: web/templates/public/campsite/type.gohtml:75
#: web/templates/admin/campsite/type/form.gohtml:127 #: web/templates/admin/campsite/type/form.gohtml:143
#: web/templates/admin/campsite/type/option/form.gohtml:70 #: web/templates/admin/campsite/type/option/form.gohtml:70
msgctxt "title" msgctxt "title"
msgid "Prices" msgid "Prices"
msgstr "Prix" msgstr "Prix"
#: web/templates/public/campsite/type.gohtml:85 #: web/templates/public/campsite/type.gohtml:87
#: web/templates/public/campsite/type.gohtml:91 #: web/templates/public/campsite/type.gohtml:93
msgid "%s: %s €/night" msgid "%s: %s €/night"
msgstr "%s : %s €/nuit" msgstr "%s : %s €/nuit"
#: web/templates/public/campsite/type.gohtml:87 #: web/templates/public/campsite/type.gohtml:89
msgid "%s €/night" msgid "%s €/night"
msgstr "%s €/nuit" msgstr "%s €/nuit"
#: web/templates/public/campsite/type.gohtml:94 #: web/templates/public/campsite/type.gohtml:96
msgid "*Minimum %d nights per stay" msgid "*Minimum %d nights per stay"
msgstr "*Minimum %d nuits par séjour" 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." msgid "10 % VAT included."
msgstr "10 % TVA incluse." 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." msgid "Tourist tax: %s/night per person aged 17 or older."
msgstr "Taxe touristique: %s/nuit par personne de plus de 16 ans." 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." msgid "Dogs: %s/night, tied, accompanied, and minimal barking."
msgstr "Chiens : %s/nuit, attachés, accompagnés et aboiements minimes." 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." msgid "No dogs allowed."
msgstr "Chiens interdits." msgstr "Chiens interdits."
#: web/templates/public/campsite/type.gohtml:123 #: web/templates/public/campsite/type.gohtml:125
msgctxt "title" msgctxt "title"
msgid "Info" msgid "Info"
msgstr "Info" msgstr "Info"
#: web/templates/public/campsite/type.gohtml:127 #: web/templates/public/campsite/type.gohtml:129
msgctxt "title" msgctxt "title"
msgid "Facilities" msgid "Facilities"
msgstr "Installations" msgstr "Installations"
#: web/templates/public/campsite/type.gohtml:131 #: web/templates/public/campsite/type.gohtml:133
msgctxt "title" msgctxt "title"
msgid "Description" msgid "Description"
msgstr "Description" msgstr "Description"
#: web/templates/public/campsite/type.gohtml:135 #: web/templates/public/campsite/type.gohtml:137
msgctxt "title" msgctxt "title"
msgid "Additional Information" msgid "Additional Information"
msgstr "Informations Complémentaires" msgstr "Informations Complémentaires"
#: web/templates/public/campsite/type.gohtml:138 #: web/templates/public/campsite/type.gohtml:140
msgctxt "time" msgctxt "time"
msgid "Check-in" msgid "Check-in"
msgstr "Arrivée" msgstr "Arrivée"
#: web/templates/public/campsite/type.gohtml:142 #: web/templates/public/campsite/type.gohtml:144
msgctxt "time" msgctxt "time"
msgid "Check-out" msgid "Check-out"
msgstr "Départ" msgstr "Départ"
@ -561,17 +561,17 @@ msgctxt "input"
msgid "Arrival date" msgid "Arrival date"
msgstr "Date darrivée" msgstr "Date darrivée"
#: web/templates/public/booking.gohtml:138 #: web/templates/public/booking.gohtml:139
msgctxt "input" msgctxt "input"
msgid "Departure date" msgid "Departure date"
msgstr "Date de depart" msgstr "Date de depart"
#: web/templates/public/booking.gohtml:149 #: web/templates/public/booking.gohtml:151
msgctxt "input" msgctxt "input"
msgid "ACSI card? (optional)" msgid "ACSI card? (optional)"
msgstr "Carte ACSI ? (Facultatif)" msgstr "Carte ACSI ? (Facultatif)"
#: web/templates/public/booking.gohtml:156 #: web/templates/public/booking.gohtml:158
msgctxt "input" msgctxt "input"
msgid "I have read and I accept %[1]sthe reservation conditions%[2]s" msgid "I have read and I accept %[1]sthe reservation conditions%[2]s"
msgstr "Jai lu et jaccepte %[1]sles conditions de réservation%[2]s" msgstr "Jai lu et jaccepte %[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/form.gohtml:92
#: web/templates/admin/campsite/type/feature/form.gohtml:74 #: web/templates/admin/campsite/type/feature/form.gohtml:74
#: web/templates/admin/campsite/type/carousel/form.gohtml:59 #: 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/campsite/type/option/form.gohtml:90
#: web/templates/admin/season/form.gohtml:73 #: web/templates/admin/season/form.gohtml:73
#: web/templates/admin/services/form.gohtml:81 #: 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/form.gohtml:94
#: web/templates/admin/campsite/type/feature/form.gohtml:76 #: web/templates/admin/campsite/type/feature/form.gohtml:76
#: web/templates/admin/campsite/type/carousel/form.gohtml:61 #: 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/campsite/type/option/form.gohtml:92
#: web/templates/admin/season/form.gohtml:75 #: web/templates/admin/season/form.gohtml:75
#: web/templates/admin/services/form.gohtml:83 #: web/templates/admin/services/form.gohtml:83
@ -1111,60 +1111,65 @@ msgctxt "input"
msgid "Check-out" msgid "Check-out"
msgstr "Départ" 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" msgctxt "input"
msgid "Maximum number of campers" msgid "Maximum number of campers"
msgstr "Nombre maximum de personnes" msgstr "Nombre maximum de personnes"
#: web/templates/admin/campsite/type/form.gohtml:104 #: web/templates/admin/campsite/type/form.gohtml:120
msgctxt "input" msgctxt "input"
msgid "Allow overflowing guests to neighbouring campsites" msgid "Allow overflowing guests to neighbouring campsites"
msgstr "Autoriser la réservation dun hébergement voisin si le nombre maximum de personnes est dépassé" msgstr "Autoriser la réservation dun 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" msgctxt "input"
msgid "Ask for zone preferences when booking" msgid "Ask for zone preferences when booking"
msgstr "Demandez la préférence de zone lors de la réservation" 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" msgctxt "input"
msgid "Dogs allowed" msgid "Dogs allowed"
msgstr "Chiens acceptés" 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 #: web/templates/admin/campsite/type/option/form.gohtml:76
msgctxt "input" msgctxt "input"
msgid "Price per night" msgid "Price per night"
msgstr "Prix par nuit" msgstr "Prix par nuit"
#: web/templates/admin/campsite/type/form.gohtml:141 #: web/templates/admin/campsite/type/form.gohtml:161
msgctxt "input"
msgid "Minimum number of nights"
msgstr "Nombre minimum de nuits"
#: web/templates/admin/campsite/type/form.gohtml:153
msgctxt "input" msgctxt "input"
msgid "Spiel" msgid "Spiel"
msgstr "Boniment" msgstr "Boniment"
#: web/templates/admin/campsite/type/form.gohtml:166 #: web/templates/admin/campsite/type/form.gohtml:174
msgctxt "input" msgctxt "input"
msgid "Info" msgid "Info"
msgstr "Info" msgstr "Info"
#: web/templates/admin/campsite/type/form.gohtml:179 #: web/templates/admin/campsite/type/form.gohtml:187
msgctxt "input" msgctxt "input"
msgid "Facilities" msgid "Facilities"
msgstr "Installations" 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/services/form.gohtml:66
#: web/templates/admin/surroundings/form.gohtml:54 #: web/templates/admin/surroundings/form.gohtml:54
msgctxt "input" msgctxt "input"
msgid "Description" msgid "Description"
msgstr "Description" msgstr "Description"
#: web/templates/admin/campsite/type/form.gohtml:205 #: web/templates/admin/campsite/type/form.gohtml:213
msgctxt "input" msgctxt "input"
msgid "Additional Information" msgid "Additional Information"
msgstr "Informations Complémentaires" msgstr "Informations Complémentaires"
@ -1861,7 +1866,7 @@ msgid "No booking found."
msgstr "Aucune réservation trouvée." msgstr "Aucune réservation trouvée."
#: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357 #: 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/campsite/feature.go:269 pkg/season/admin.go:412
#: pkg/services/admin.go:316 pkg/surroundings/admin.go:340 #: pkg/services/admin.go:316 pkg/surroundings/admin.go:340
#: pkg/amenity/feature.go:269 pkg/amenity/admin.go:283 #: 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." msgstr "Le nom ne peut pas être laissé vide."
#: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358 #: 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 #: pkg/campsite/feature.go:270 pkg/amenity/feature.go:270
msgid "Name must have at least one letter." msgid "Name must have at least one letter."
msgstr "Le nom doit comporter au moins une lettre." 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." msgid "Maximum must be equal or greater than minimum."
msgstr "Le maximum doit être égal ou supérieur au 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." msgid "Price per night can not be empty."
msgstr "Le prix par nuit ne peut pas être vide." 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." msgid "Price per night must be a decimal number."
msgstr "Le prix par nuit doit être un nombre décimal." 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." msgid "Price per night must be zero or greater."
msgstr "Le prix par nuit doit être égal ou supérieur." 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." msgid "Selected icon is not valid."
msgstr "Licône sélectionnée nest pas valide." msgstr "Licône sélectionnée nest pas valide."
#: pkg/campsite/types/admin.go:309 #: pkg/campsite/types/admin.go:310
msgctxt "input" msgctxt "input"
msgid "Cover image" msgid "Cover image"
msgstr "Image de couverture" msgstr "Image de couverture"
#: pkg/campsite/types/admin.go:310 #: pkg/campsite/types/admin.go:311
msgctxt "action" msgctxt "action"
msgid "Set campsite type cover" msgid "Set campsite type cover"
msgstr "Définir une couverture type camping" 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." msgid "Check-in can not be empty."
msgstr "Larrivée ne peut pas être vide." msgstr "Larrivé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." msgid "Check-out can not be empty."
msgstr "Le départ ne peut pas être vide." 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." msgid "Cover image can not be empty."
msgstr "Limage de couverture ne peut pas être vide." msgstr "Limage 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." msgid "Cover image must be an image media type."
msgstr "Limage de couverture doit être de type média dimage." msgstr "Limage de couverture doit être de type média dimage."
#: pkg/campsite/types/admin.go:507 #: pkg/campsite/types/admin.go:538
msgid "Maximum number of campers can not be empty." msgid "Maximum number of campers can not be empty."
msgstr "Le nombre maximum de campeurs ne peut pas être vide." 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." msgid "Maximum number of campers must be an integer number."
msgstr "Le nombre maximum de campeurs doit être un nombre entier." 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." msgid "Maximum number of campers must be one or greater."
msgstr "Le nombre maximum de campeurs doit être égal ou supérieur à un campeur." 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." msgid "Minimum number of nights can not be empty."
msgstr "Le nombre minimum de nuits ne peut pas être vide." 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." msgid "Minimum number of nights must be an integer."
msgstr "Le nombre minimum de nuits doit être un entier." 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." msgid "Minimum number of nights must be one or greater."
msgstr "Le nombre minimum de nuits doit être supérieur ou égal à une nuit." 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 #: pkg/campsite/admin.go:275 pkg/booking/public.go:321
msgid "Selected campsite type is not valid." msgid "Selected campsite type is not valid."
msgstr "Le type demplacement sélectionné nest pas valide." msgstr "Le type demplacement sélectionné nest pas valide."

View File

@ -4,23 +4,25 @@
-- requires: campsite_type -- requires: campsite_type
-- requires: company -- requires: company
-- requires: campsite_type__check_in_out -- requires: campsite_type__check_in_out
-- requires: campsite_type__overflow_allowed
-- requires: campsite_type__ask_zone_preferences
begin; begin;
set search_path to camper, public; 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) 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) 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; returning slug;
$$ $$
language sql language sql
; ;
revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean) from public; 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) to admin; grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean) to admin;
commit; commit;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -4,14 +4,16 @@
-- requires: campsite_type -- requires: campsite_type
-- requires: company -- requires: company
-- requires: campsite_type__check_in_out -- requires: campsite_type__check_in_out
-- requires: campsite_type__overflow_allowed
-- requires: campsite_type__ask_zone_preferences
begin; begin;
set search_path to camper, public; 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 update campsite_type
set name = edit_campsite_type.name set name = edit_campsite_type.name
@ -25,6 +27,8 @@ $$
, media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id) , media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id)
, max_campers = edit_campsite_type.max_campers , max_campers = edit_campsite_type.max_campers
, dogs_allowed = edit_campsite_type.dogs_allowed , 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 , active = edit_campsite_type.active
where slug = edit_campsite_type.slug where slug = edit_campsite_type.slug
returning slug; returning slug;
@ -32,7 +36,7 @@ $$
language sql language sql
; ;
revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean) from public; 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) to admin; 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; commit;

View File

@ -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;

View File

@ -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; 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; commit;

View File

@ -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;

View File

@ -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 <jordi@tandem.blog> # Add ask_zone_preferences column to campsite_type campsite_type__ask_zone_preferences [campsite_type] 2024-01-29T01:08:14Z jordi fita mas <jordi@tandem.blog> # 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 <jordi@tandem.blog> # Add overflow_allowed and ask_zone_preferences parameters to add_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 <jordi@tandem.blog> # 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 <jordi@tandem.blog> # Add overflow_allowed and ask_zone_preferences parameters to edit_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 <jordi@tandem.blog> # Add overflow_allowed and ask_zone_preferences parameters to edit_campsite_type
@v3 2024-01-31T20:40:16Z jordi fita mas <jordi@tandem.blog> # Tag v3
campsite_type__bookable_nights [campsite_type campsite_type_cost] 2024-01-31T19:45:46Z jordi fita mas <jordi@tandem.blog> # 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 <jordi@tandem.blog> # 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 <jordi@tandem.blog> # 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 <jordi@tandem.blog> # 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 <jordi@tandem.blog> # Remove min_nights field from campsite_type_cost relation

View File

@ -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"};')) , (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) 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) values (11, 1, 3, 'A', false, 5, '[1, 7]')
, (12, 1, 3, 'B', false, 5) , (12, 1, 3, 'B', false, 5, '[2, 6]')
, (21, 2, 4, 'C', false, 5) , (21, 2, 4, 'C', false, 5, '[3, 5]')
; ;
select lives_ok( select lives_ok(

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (7, 1, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, 3, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 2, 4, 'Type A', '<p>A</p>', 5, false, true) , (11, 2, 4, 'Type A', '<p>A</p>', 5, '[2, 5]', false, true)
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (4, 1, 3, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
, (5, 1, 3, 'Type B', '<p>B</p>', true, false, 5) , (5, 1, 3, 'Type B', '<p>B</p>', true, false, 5, '[2, 5]')
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -9,15 +9,15 @@ set search_path to camper, public;
select plan(13); 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 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', 'boolean', 'boolean', 'boolean'], 'sql'); 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', 'boolean', 'boolean', 'boolean'], 'uuid'); 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', 'boolean', 'boolean', 'boolean']); 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', 'boolean', 'boolean', 'boolean'], 'volatile'); 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', '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'], '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', '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', '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'], '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 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; 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 lives_ok(
$$ select add_campsite_type(1, 3, 'Type A', '', '<p>Features</p>', '', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', '', 'After 4 p.m.', '12 a.m.', 5, true, false, true) $$, $$ select add_campsite_type(1, 3, 'Type A', '', '<p>Features</p>', '', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', '', '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' 'Should be able to add a campsite type to the first company'
); );
select lives_ok( select lives_ok(
$$ select add_campsite_type(2, 4, 'Type B', '<p>One</p><p>Two</p>', '', '<p>Pricing</p>', '', '<p>More</p>', 'After 9 p.m.', '9 a.m.', 2, false, true, false) $$, $$ select add_campsite_type(2, 4, 'Type B', '<p>One</p><p>Two</p>', '', '<p>Pricing</p>', '', '<p>More</p>', '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' 'Should be able to add a campsite type to the second company'
); );
select bag_eq( 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 $$, $$ 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', '', '<p>Features</p>', '', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', '', 'After 4 p.m.', '12 a.m.', true, 5, true, false, true) $$ values (1, 3, 'Type A', '', '<p>Features</p>', '', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', '', 'After 4 p.m.', '12 a.m.', true, 5, int4range(1, 8), true, false, true)
, (2, 4, 'Type B', '<p>One</p><p>Two</p>', '', '<p>Pricing</p>', '', '<p>More</p>', 'After 9 p.m.', '9 a.m.', true, 2, false, true, false) , (2, 4, 'Type B', '<p>One</p><p>Two</p>', '', '<p>Pricing</p>', '', '<p>More</p>', 'After 9 p.m.', '9 a.m.', true, 2, int4range(2, 7), false, true, false)
$$, $$,
'Should have added all two campsite type' 'Should have added all two campsite type'
); );

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (6, 1, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false) , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite_type_carousel (campsite_type_id, media_id, caption) insert into campsite_type_carousel (campsite_type_id, media_id, caption)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
, (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '<p>B</p>', true, false, 5) , (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '<p>B</p>', true, false, 5, '[2, 6]')
; ;
select lives_ok( select lives_ok(

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
, (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '<p>B</p>', true, false, 5) , (4, 1, '9ae5cf87-cd69-4541-b5a5-75f937cc9e58', 2, 'Type B', '<p>B</p>', true, false, 5, '[1, 6]')
; ;
select lives_ok( select lives_ok(

View File

@ -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"};')) , (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) 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) values (10, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (12, 4, 'Bungalow', 8, false, 6) , (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) insert into booking (company_id, campsite_type_id, holder_name, arrival_date, departure_date, number_dogs, acsi_card)

View File

@ -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"};')) , (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) 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) values (22, 2, 6, 'Wooden lodge', true, 5, '[1, 7]')
, (44, 4, 8, 'Bungalow', false, 4) , (44, 4, 8, 'Bungalow', false, 4, '[2, 6]')
; ;
insert into campsite (company_id, campsite_type_id, label) insert into campsite (company_id, campsite_type_id, label)

View File

@ -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')) , (11, 4, 'text5.txt', sha256('content5'))
; ;
insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) 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) values (21, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (22, 4, 'Bungalow', 9, false, 6) , (22, 4, 'Bungalow', 9, false, 6, '[2, 6]')
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -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"};')) , (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) 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) values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (18, 4, 'Bungalow', 8, false, 6) , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]')
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -5,7 +5,7 @@ reset client_min_messages;
begin; begin;
select plan(106); select plan(112);
set search_path to camper, public; 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_has_default('campsite_type', 'check_out');
select col_default_is('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 has_column('campsite_type', 'active');
select col_type_is('campsite_type', 'active', 'boolean'); select col_type_is('campsite_type', 'active', 'boolean');
select col_not_null('campsite_type', 'active'); 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"};')) , (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) insert into campsite_type (company_id, name, media_id, dogs_allowed, max_campers, bookable_nights)
values (2, 'Wooden lodge', 6, false, 7) values (2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (4, 'Bungalow', 8, false, 6) , (4, 'Bungalow', 8, false, 6, '[2, 6]')
; ;
prepare campsite_type_data as prepare campsite_type_data as
@ -187,7 +192,7 @@ reset role;
select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog', 'co2'); select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog', 'co2');
select lives_ok( 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.' '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( 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"', '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.' '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( 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"', '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.' 'Should not be able to insert campsite types with a blank name.'
); );
select throws_ok( 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"', '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.' '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; reset role;

View File

@ -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')) , (11, 4, 'text5.txt', sha256('content5'))
; ;
insert into campsite_type (campsite_type_id, company_id, name, media_id, dogs_allowed, max_campers) 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) values (21, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (22, 4, 'Bungalow', 9, false, 6) , (22, 4, 'Bungalow', 9, false, 6, '[2, 6]')
; ;
insert into campsite_type_carousel (campsite_type_id, media_id, caption) insert into campsite_type_carousel (campsite_type_id, media_id, caption)

View File

@ -5,7 +5,7 @@ reset client_min_messages;
begin; begin;
select plan(47); select plan(42);
set search_path to camper, public; 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_not_null('campsite_type_cost', 'cost_per_night');
select col_hasnt_default('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; set client_min_messages to warning;
truncate campsite_type_cost cascade; 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"};')) , (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) 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) values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (18, 4, 'Bungalow', 8, false, 6) , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]')
; ;
insert into season (season_id, company_id, name) insert into season (season_id, company_id, name)
@ -95,9 +90,9 @@ values (26, 2, 'Low')
, (29, 4, 'Mid') , (29, 4, 'Mid')
; ;
insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night)
values (16, 26, 2, 2) values (16, 26, 2)
, (18, 28, 4, 4) , (18, 28, 4)
; ;
prepare campsite_season_data as prepare campsite_season_data as
@ -118,7 +113,7 @@ reset role;
select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog', 'co2'); select set_cookie('44facbb30d8a419dfd4bfbc44a4b5539d4970148dfc84bed0e/demo@tandem.blog', 'co2');
select lives_ok( 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.' '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( 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"', '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.' 'Admin from company 2 should NOT be able to insert new campsite type costs to company 4.'
); );
select throws_ok( 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"', '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.' 'Admin from company 2 should NOT be able to insert new row with a campsite type from company 4.'
); );
select throws_ok( 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"', '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.' '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( 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"', '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.' '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; reset role;

View File

@ -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"};')) , (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) 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) values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (18, 4, 'Bungalow', 8, false, 6) , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]')
; ;
insert into campsite_type_feature (campsite_type_id, icon_name, name) insert into campsite_type_feature (campsite_type_id, icon_name, name)

View File

@ -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"};')) , (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) 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) values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (18, 4, 'Bungalow', 8, false, 6) , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]')
; ;
insert into campsite_type_option (campsite_type_id, name, range) insert into campsite_type_option (campsite_type_id, name, range)

View File

@ -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"};')) , (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) 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) values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
, (18, 4, 'Bungalow', 8, false, 6) , (18, 4, 'Bungalow', 8, false, 6, '[2, 6]')
; ;
insert into season (season_id, company_id, name) insert into season (season_id, company_id, name)

View File

@ -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"};')) 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) 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) values (11, 1, 3, 'Type A', false, 5, '[1, 7]')
, (12, 1, 3, 'Type B', false, 5) , (12, 1, 3, 'Type B', false, 5, '[2, 6]')
, (13, 1, 3, 'Type C', false, 5) , (13, 1, 3, 'Type C', false, 5, '[3, 5]')
; ;
insert into campsite (campsite_id, company_id, campsite_type_id, label, info1, info2, active) insert into campsite (campsite_id, company_id, campsite_type_id, label, info1, info2, active)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -9,15 +9,15 @@ set search_path to camper, public;
select plan(12); 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 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', 'boolean', 'boolean', 'boolean', 'boolean'], 'sql'); 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', 'boolean', 'boolean', 'boolean', 'boolean'], 'uuid'); 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', 'boolean', 'boolean', 'boolean', 'boolean']); 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', 'boolean', 'boolean', 'boolean', 'boolean'], 'volatile'); 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', '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'], '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', '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', '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'], '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 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; set client_min_messages to warning;
truncate campsite_type cascade; 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"};')) , (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) 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', '<h1>1</h1>', '<p>info 1</p>', '<p>facilities A</p>', '<p>A</p>', '<p>Additional A</p>', '', '', 5, false, true, false, true) values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<h1>1</h1>', '<p>info 1</p>', '<p>facilities A</p>', '<p>A</p>', '<p>Additional A</p>', '', '', 5, '[1, 7]', false, true, false, true)
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<h2>2</h2>', '<p>info 2</p>', '<p>facilities B</p>', '<p>B</p>', '<p>Additional B</p>', '', '', 4, true, false, true, false) , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<h2>2</h2>', '<p>info 2</p>', '<p>facilities B</p>', '<p>B</p>', '<p>Additional B</p>', '', '', 4, '[2, 6]', true, false, true, false)
; ;
select lives_ok( select lives_ok(
$$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<h3>A</h3>', '<p>Features A</p>', '<p>Pricing 1</p>', '<p>1</p>', '<p>Additional 1</p>', 'Check-in 1', 'Check-out 1', 2, true, false, true, false) $$, $$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<h3>A</h3>', '<p>Features A</p>', '<p>Pricing 1</p>', '<p>1</p>', '<p>Additional 1</p>', 'Check-in 1', 'Check-out 1', 2, '(1, 7)', true, false, true, false) $$,
'Should be able to edit the first type' 'Should be able to edit the first type'
); );
select lives_ok( select lives_ok(
$$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', null, 'Type 2', '<h1>B</h1>', '<p>Features B</p>', '<p>Pricing 2</p>', '<p>2</p>', '<p>Additional 2</p>', 'Check-in 2', 'Check-out 2', 9, false, true, false, true) $$, $$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', null, 'Type 2', '<h1>B</h1>', '<p>Features B</p>', '<p>Pricing 2</p>', '<p>2</p>', '<p>Additional 2</p>', 'Check-in 2', 'Check-out 2', 9, '(2, 6)', false, true, false, true) $$,
'Should be able to edit the second type' 'Should be able to edit the second type'
); );
select bag_eq( 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 $$, $$ 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', '<h3>A</h3>', '<p>Features A</p>', '<p>Pricing 1</p>', '<p>1</p>', '<p>Additional 1</p>', 'Check-in 1', 'Check-out 1', 2, true, false, true, false) $$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<h3>A</h3>', '<p>Features A</p>', '<p>Pricing 1</p>', '<p>1</p>', '<p>Additional 1</p>', 'Check-in 1', 'Check-out 1', 2, int4range(2, 7), true, false, true, false)
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '<h1>B</h1>', '<p>Features B</p>', '<p>Pricing 2</p>', '<p>2</p>', '<p>Additional 2</p>', 'Check-in 2', 'Check-out 2', 9, false, true, false, true) , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '<h1>B</h1>', '<p>Features B</p>', '<p>Pricing 2</p>', '<p>2</p>', '<p>Additional 2</p>', 'Check-in 2', 'Check-out 2', 9, int4range(3, 6), false, true, false, true)
$$, $$,
'Should have updated all campsite types.' 'Should have updated all campsite types.'
); );

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range)

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (12, 1, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (13, 1, 3, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (14, 2, 8, 'Type B', '<p>B</p>', 4, true, false) , (14, 2, 8, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -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"};')) 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) 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) values (16, 2, 'Wooden lodge', 6, false, 7, '[1, 7]')
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (6, 1, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false) , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite_type_carousel (campsite_type_id, media_id, caption) insert into campsite_type_carousel (campsite_type_id, media_id, caption)

View File

@ -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"};')) 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) 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) 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) insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range)

View File

@ -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"};')) 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) 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, false, true) values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'A', '', '', '', '', 5, '[1, 7]', false, true)
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 2, 'B', '', '', '', '', 5, false, true) , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 2, 'B', '', '', '', '', 5, '[2, 6]', false, true)
, (1, 'b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 2, 'C', '', '', '', '', 5, false, true) , (1, 'b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 2, 'C', '', '', '', '', 5, '[3, 5]', false, true)
, (1, '8c4465ec-a690-43d7-854b-7fcd35fccb1c', 2, 'D', '', '', '', '', 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, false, true) , (1, 'd28c30fb-57ac-4243-a8c3-ad1a26637f5a', 2, 'E', '', '', '', '', 5, '[5, 9]', false, true)
; ;
select lives_ok( select lives_ok(

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (7, 2, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, 3, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 2, 7, 'Type B', '<p>B</p>', 4, true, false) , (11, 2, 7, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite (campsite_id, label, company_id, campsite_type_id) insert into campsite (campsite_id, label, company_id, campsite_type_id)

View File

@ -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"};')) , (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) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (6, 1, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false) , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite_type_carousel (campsite_type_id, media_id, caption) insert into campsite_type_carousel (campsite_type_id, media_id, caption)

View File

@ -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"};')) , (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) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false) , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name)

View File

@ -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"};')) , (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) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false) , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range)

View File

@ -9,15 +9,15 @@ select plan(13);
set search_path to camper, public; set search_path to camper, public;
select has_function('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer']); 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', 'integer', 'text', 'integer'], 'sql'); 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', 'integer', 'text', 'integer'], 'void'); 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', 'integer', 'text', 'integer']); select isnt_definer('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'text', 'integer']);
select volatility_is('camper', 'set_campsite_type_cost', array['uuid', 'integer', 'integer', 'text', 'integer'], 'volatile'); 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', 'integer', 'text', 'integer'], 'guest', array[]::text[]); 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', 'integer', 'text', 'integer'], 'employee', 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', 'integer', 'text', 'integer'], 'admin', array['EXECUTE']); 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', 'integer', 'text', 'integer'], 'authenticator', array[]::text[]); select function_privs_are('camper', 'set_campsite_type_cost', array ['uuid', 'integer', 'text', 'integer'], 'authenticator', array[]::text[]);
set client_min_messages to warning; set client_min_messages to warning;
truncate campsite_type_cost cascade; 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"};')) 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) 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, false, true) values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '', 5, '[1, 7]', false, true)
; ;
insert into season (season_id, company_id, name) insert into season (season_id, company_id, name)
@ -51,31 +51,31 @@ values (4, 1, 'High')
, (6, 1, 'Low') , (6, 1, 'Low')
; ;
insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night, min_nights) insert into campsite_type_cost (campsite_type_id, season_id, cost_per_night)
values (3, 4, 44, 4) values (3, 4, 44)
, (3, 5, 55, 5) , (3, 5, 55)
; ;
select lives_ok( 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' 'Should be able to edit the cost for high season'
); );
select lives_ok( 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' 'Should be able to set the cost for mid season to zero'
); );
select lives_ok( 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.' 'Should be able to set the cost for low season, adding it.'
); );
select bag_eq( select bag_eq(
$$ select campsite_type_id, season_id, cost_per_night, min_nights from campsite_type_cost $$, $$ select campsite_type_id, season_id, cost_per_night from campsite_type_cost $$,
$$ values (3, 4, 1234, 2) $$ values (3, 4, 1234)
, (3, 5, 0, 6) , (3, 5, 0)
, (3, 6, 321, 1) , (3, 6, 321)
$$, $$,
'Should have updated all campsite type costs.' 'Should have updated all campsite type costs.'
); );

View File

@ -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"};')) 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) 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, false, true) values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '', 5, '[1, 7]', false, true)
; ;
insert into season (season_id, company_id, name) insert into season (season_id, company_id, name)

View File

@ -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"};')) 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) 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) values (11, 1, 3, 'Type A', false, 5, '[1, 7]')
; ;
insert into campsite (campsite_id, company_id, campsite_type_id, label, info1, info2, active) insert into campsite (campsite_id, company_id, campsite_type_id, label, info1, info2, active)

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (7, 2, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, 3, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 2, 7, 'Type B', '<p>B</p>', 7, true, false) , (11, 2, 7, 'Type B', '<p>B</p>', 7, '[2, 6]', true, false)
; ;
insert into campsite (campsite_id, label, company_id, campsite_type_id) insert into campsite (campsite_id, label, company_id, campsite_type_id)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite (campsite_id, company_id, label, campsite_type_id) insert into campsite (campsite_id, company_id, label, campsite_type_id)

View File

@ -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"};')) , (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) 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', '<h2>One</h2>', '<p>Features A</p>', '<p>Pricing A</p>', '<p>A</p>', '<p>Additional A</p>', '', '', true, false, 4) values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<h2>One</h2>', '<p>Features A</p>', '<p>Pricing A</p>', '<p>A</p>', '<p>Additional A</p>', '', '', true, false, 4, '[1, 7]')
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<h2>Two</h2>', '<p>Features B</p>', '<p>Pricing B</p>', '<p>B</p>', '<p>Additional B</p>', '', '', false, true, 5) , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<h2>Two</h2>', '<p>Features B</p>', '<p>Pricing B</p>', '<p>B</p>', '<p>Additional B</p>', '', '', 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) insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, info, facilities, description, additional_info, check_in, check_out)

View File

@ -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('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')) , (6, 1, 'image.svg', sha256('<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'))
; ;
insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) 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', '<p>A</p>', 5, false, true) values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, '[1, 7]', false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false) , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, '[2, 6]', true, false)
; ;
insert into campsite_type_carousel (campsite_type_id, media_id, caption) insert into campsite_type_carousel (campsite_type_id, media_id, caption)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name) insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name)

View File

@ -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"};')) 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) 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', '<p>A</p>', true, false, 4) values (3, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', true, false, 4, '[1, 7]')
; ;
insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range)

View File

@ -2,6 +2,6 @@
begin; 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; rollback;

View File

@ -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;

View File

@ -0,0 +1,10 @@
-- Verify camper:campsite_type__bookable_nights on pg
begin;
select bookable_nights
from camper.campsite_type
where false
;
rollback;

View File

@ -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;

View File

@ -2,6 +2,6 @@
begin; 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; rollback;

View File

@ -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;

View File

@ -2,6 +2,6 @@
begin; 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; rollback;

View File

@ -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;

View File

@ -11,7 +11,8 @@
return; 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); const minDate = formatDate(arrivalDate);
departureDateField.setAttribute('min', minDate); departureDateField.setAttribute('min', minDate);
@ -20,13 +21,16 @@
departureDateField.value = minDate; departureDateField.value = minDate;
} }
arrivalDate.setUTCDate(arrivalDate.getUTCDate() + 6); const maxNights = parseInt(departureDateField.dataset.maxNights, 10);
if (maxNights > 0) {
arrivalDate.setUTCDate(arrivalDate.getUTCDate() + maxNights - minNights);
const maxDate = formatDate(arrivalDate); const maxDate = formatDate(arrivalDate);
departureDateField.setAttribute('max', maxDate); departureDateField.setAttribute('max', maxDate);
if (!isNaN(departureDate) && departureDate >= arrivalDate) { if (!isNaN(departureDate) && departureDate >= arrivalDate) {
departureDateField.value = maxDate; departureDateField.value = maxDate;
} }
} }
}
function formatDate(date) { function formatDate(date) {
return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())}`; return `${date.getFullYear()}-${zeroPad(date.getMonth() + 1)}-${zeroPad(date.getDate())}`;

View File

@ -88,6 +88,22 @@
{{ template "error-message" . }} {{ template "error-message" . }}
</fieldset> </fieldset>
{{- end }} {{- end }}
{{ with .MinNights -}}
<label>
{{( pgettext "Minimum number of nights" "input")}}<br>
<input type="number" name="{{ .Name }}" value="{{ .Val }}" min="1"
required {{ template "error-attrs" . }}><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .MaxNights -}}
<label>
{{( pgettext "Maximum number of nights" "input")}}<br>
<input type="number" name="{{ .Name }}" value="{{ .Val }}" min="1"
required {{ template "error-attrs" . }}><br>
{{ template "error-message" . }}
</label>
{{- end }}
<fieldset> <fieldset>
{{ with .MaxCampers -}} {{ with .MaxCampers -}}
<label> <label>
@ -136,14 +152,6 @@
{{ template "error-message" . }} {{ template "error-message" . }}
</label> </label>
{{- end }} {{- end }}
{{ with .MinNights -}}
<label>
{{( pgettext "Minimum number of nights" "input")}}<br>
<input type="number" name="{{ .Name }}" value="{{ .Val }}" min="1"
required {{ template "error-attrs" . }}><br>
{{ template "error-message" . }}
</label>
{{- end }}
</fieldset> </fieldset>
{{- end }} {{- end }}
</fieldset> </fieldset>

View File

@ -46,7 +46,9 @@
<label> <label>
{{( pgettext "Check-out Date" "input")}} {{( pgettext "Check-out Date" "input")}}
<br> <br>
<input name="departure_date" type="date" min="{{ overmorrow }}"> <input name="departure_date" type="date" min="{{ overmorrow }}"
data-min-nights="{{ .MinNights}}" data-max-nights="{{ .MaxNights }}"
>
<br> <br>
</label> </label>
</fieldset> </fieldset>
@ -90,8 +92,8 @@
{{ range .Options }} {{ range .Options }}
<dd x-show="open">{{ printf (gettext "%s: %s €/night") .OptionName .PricePerNight }}</dd> <dd x-show="open">{{ printf (gettext "%s: %s €/night") .OptionName .PricePerNight }}</dd>
{{- end }} {{- end }}
{{ if gt .MinNights 1 -}} {{ if gt $.MinNights 1 -}}
<dd x-show="open">{{ printf (gettext "*Minimum %d nights per stay") .MinNights }}</dd> <dd x-show="open">{{ printf (gettext "*Minimum %d nights per stay") $.MinNights }}</dd>
{{- end }} {{- end }}
</div> </div>
{{- end }} {{- end }}