Add the “spiel” for campsite types

This is the text that introduces the carousel; it is not a spiel, but
this is what i call it.

It turns out that this text needs to have paragraphs and headings, much
like home’s slider, rather than the one in services page, thus no need
to change its font size or to align all items in the carousel in the
middle.
This commit is contained in:
jordi fita mas 2023-10-12 18:47:08 +02:00
parent 471ed9e870
commit ebf47b5d75
28 changed files with 207 additions and 142 deletions

View File

@ -111,23 +111,23 @@ values (77, 'en', 'Tent')
;
alter table campsite_type alter column campsite_type_id restart with 72;
select add_campsite_type(52, 62, 'Parceŀles', '', 6, true);
select add_campsite_type(52, 63, 'Safari Tents', '', 6, false);
select add_campsite_type(52, 64, 'Bungalous', '', 5, false);
select add_campsite_type(52, 65, 'Bungalous prèmium', '', 5, false);
select add_campsite_type(52, 66, 'Cabanes de fusta', '', 5, false);
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>', '<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>', 6, 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>', '<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>', 6, 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>', '<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>', 5, 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>', '<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>', 5, 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>', '<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>', 5, false);
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, description)
values (72, 'en', 'Plots', '')
, (72, 'es', 'Parcelas', '')
, (73, 'en', 'Safari Tents', '')
, (73, 'es', 'Tiendas Safari', '')
, (74, 'en', 'Bungalows', '')
, (74, 'es', 'Bungalós', '')
, (75, 'en', 'Bungalows premium', '')
, (75, 'es', 'Bungalós prémium', '')
, (76, 'en', 'Wooden Lodges', '')
, (76, 'es', 'Cabañas de madera', '')
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, description)
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>', '<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>')
, (72, 'es', 'Parcelas', '<h3>Acampa enmedio de la naturaleza</h3><p>Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.</p><p>Parcelas amplias con servicios cerca de donde eres para hacer aquello que quieres.</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>')
, (73, 'en', 'Safari Tents', '<h3>Glamping at your disposal</h3><p>A luxury of tent for unforgettable adventures.</p><p>Two tents with wooden floors, beds, kitchen, and all the amenities to enjoy your vacation.</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>')
, (73, 'es', 'Tiendas Safari', '<h3>Glamping a tu disposición</h3><p>Un lujo de tiendas para vivir aventuras.</p><p>Dos tiendas con suelo de madera, camas, cocina y todo de comodidades para disfrutar de tus vacanciones.</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>')
, (74, 'en', 'Bungalows', '<h3>Luxury accomomdations</h3><p>Located on the campgrounds mountain-side and overlooking the nature that surrounds us.</p><p>Two two-story solid wood cabins with a covered porch to enjoy among the trees.</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>')
, (74, 'es', 'Bungalós', '<h3>Alojamientos de lujo</h3><p>Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.</p><p>Dos cabañas de madera maciza de dos plantas y con porche cubierto para disfutrar entre árboles.</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>')
, (75, 'en', 'Bungalows premium', '<h3>Luxury accomomdations</h3><p>Located on the campgrounds mountain-side and overlooking the nature that surrounds us.</p><p>Two two-story solid wood cabins with a covered porch to enjoy among the trees.</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>')
, (75, 'es', 'Bungalós prémium', '<h3>Alojamientos de lujo</h3><p>Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.</p><p>Dos cabañas de madera maciza de dos plantas y con porche cubierto para disfutrar entre árboles.</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>')
, (76, 'en', 'Wooden Lodges', '<h3>Luxury accomomdations</h3><p>Located on the campgrounds mountain-side and overlooking the nature that surrounds us.</p><p>Two two-story solid wood cabins with a covered porch to enjoy among the trees.</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>')
, (76, 'es', 'Cabañas de madera', '<h3>Alojamientos de lujo</h3><p>Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.</p><p>Dos cabañas de madera maciza de dos plantas y con porche cubierto para disfutrar entre árboles.</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>')
;
alter table campsite alter column campsite_id restart with 82;

View File

@ -8,16 +8,16 @@ begin;
set search_path to camper, public;
create or replace function add_campsite_type(company integer, media_id integer, name text, description 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, description text, max_campers integer, dogs_allowed boolean) returns uuid as
$$
insert into campsite_type (company_id, media_id, name, description, max_campers, dogs_allowed)
values (company, media_id, name, xmlparse (content description), max_campers, dogs_allowed)
insert into campsite_type (company_id, media_id, name, spiel, description, max_campers, dogs_allowed)
values (company, media_id, name, xmlparse(content spiel), xmlparse(content description), max_campers, dogs_allowed)
returning slug;
$$
language sql
;
revoke execute on function add_campsite_type(integer, integer, text, text, integer, boolean) from public;
grant execute on function add_campsite_type(integer, integer, text, text, integer, boolean) to admin;
revoke execute on function add_campsite_type(integer, integer, text, text, text, integer, boolean) from public;
grant execute on function add_campsite_type(integer, integer, text, text, text, integer, boolean) to admin;
commit;

View File

@ -15,6 +15,7 @@ create table campsite_type (
slug uuid not null unique default gen_random_uuid(),
name text not null constraint name_not_empty check(length(trim(name)) > 0),
media_id integer not null references media,
spiel xml not null default ''::xml,
description xml not null default ''::xml,
max_campers integer not null constraint at_least_one_camper check(max_campers > 0),
dogs_allowed boolean not null,

View File

@ -12,6 +12,7 @@ create table campsite_type_i18n (
campsite_type_id integer not null references campsite_type,
lang_tag text not null references language,
name text not null,
spiel xml not null,
description xml not null,
primary key (campsite_type_id, lang_tag)
);

View File

@ -8,10 +8,11 @@ begin;
set search_path to camper, public;
create or replace function edit_campsite_type(slug uuid, media_id integer, name text, description 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, description 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)
, media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id)
, max_campers = edit_campsite_type.max_campers
@ -23,7 +24,7 @@ $$
language sql
;
revoke execute on function edit_campsite_type(uuid, integer, text, text, integer, boolean, boolean) from public;
grant execute on function edit_campsite_type(uuid, integer, text, text, integer, boolean, boolean) to admin;
revoke execute on function edit_campsite_type(uuid, integer, text, text, text, integer, boolean, boolean) from public;
grant execute on function edit_campsite_type(uuid, integer, text, text, text, integer, boolean, boolean) to admin;
commit;

View File

@ -7,20 +7,21 @@ begin;
set search_path to camper, public;
create or replace function translate_campsite_type (slug uuid, lang_tag text, name text, description text) returns void as
create or replace function translate_campsite_type (slug uuid, lang_tag text, name text, spiel text, description text) returns void as
$$
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, description)
select campsite_type_id, translate_campsite_type.lang_tag, translate_campsite_type.name, xmlparse(content coalesce(translate_campsite_type.description, ''))
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, description)
select campsite_type_id, translate_campsite_type.lang_tag, translate_campsite_type.name, xmlparse(content coalesce(translate_campsite_type.spiel, '')), xmlparse(content coalesce(translate_campsite_type.description, ''))
from campsite_type
where slug = translate_campsite_type.slug
on conflict (campsite_type_id, lang_tag) do update
set name = excluded.name
, spiel = excluded.spiel
, description = excluded.description
$$
language sql
;
revoke execute on function translate_campsite_type (uuid, text, text, text) from public;
grant execute on function translate_campsite_type(uuid, text, text, text) to admin;
revoke execute on function translate_campsite_type (uuid, text, text, text, text) from public;
grant execute on function translate_campsite_type(uuid, text, text, text, text) to admin;
commit;

View File

@ -197,7 +197,7 @@ func addType(w http.ResponseWriter, r *http.Request, user *auth.User, company *a
panic(err)
}
processTypeForm(w, r, user, company, conn, f, func(ctx context.Context, tx *database.Tx) error {
slug, err := tx.GetText(ctx, "select add_campsite_type($1, $2, $3, $4, $5, $6)", company.ID, f.Media, f.Name, f.Description, f.MaxCampers, f.DogsAllowed)
slug, err := tx.GetText(ctx, "select add_campsite_type($1, $2, $3, $4, $5, $6, $7)", company.ID, f.Media, f.Name, f.Spiel, f.Description, f.MaxCampers, f.DogsAllowed)
if err != nil {
return err
}
@ -216,7 +216,7 @@ func setTypePrices(ctx context.Context, tx *database.Tx, slug string, prices map
func editType(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, f *typeForm) {
processTypeForm(w, r, user, company, conn, f, func(ctx context.Context, tx *database.Tx) error {
if _, err := conn.Exec(ctx, "select edit_campsite_type($1, $2, $3, $4, $5, $6, $7)", f.Slug, f.Media, f.Name, f.Description, f.MaxCampers, f.DogsAllowed, f.Active); err != nil {
if _, err := conn.Exec(ctx, "select edit_campsite_type($1, $2, $3, $4, $5, $6, $7, $8)", f.Slug, f.Media, f.Name, f.Spiel, f.Description, f.MaxCampers, f.DogsAllowed, f.Active); err != nil {
return err
}
return setTypePrices(ctx, tx, f.Slug, f.Prices)
@ -259,6 +259,7 @@ type typeForm struct {
Name *form.Input
MaxCampers *form.Input
DogsAllowed *form.Checkbox
Spiel *form.Input
Description *form.Input
Prices map[int]*typePriceForm
}
@ -291,6 +292,9 @@ func newTypeForm(ctx context.Context, company *auth.Company, conn *database.Conn
DogsAllowed: &form.Checkbox{
Name: "dogs_allowed",
},
Spiel: &form.Input{
Name: "spiel",
},
Description: &form.Input{
Name: "description",
},
@ -329,7 +333,8 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl
f.Slug = slug
row := conn.QueryRow(ctx, `
select name
, description
, spiel::text
, description::text
, media_id::text
, max_campers::text
, dogs_allowed
@ -337,7 +342,7 @@ func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, sl
from campsite_type
where slug = $1
`, slug)
if err := row.Scan(&f.Name.Val, &f.Description.Val, &f.Media.Val, &f.MaxCampers.Val, &f.DogsAllowed.Checked, &f.Active.Checked); err != nil {
if err := row.Scan(&f.Name.Val, &f.Spiel.Val, &f.Description.Val, &f.Media.Val, &f.MaxCampers.Val, &f.DogsAllowed.Checked, &f.Active.Checked); err != nil {
return err
}
@ -377,6 +382,7 @@ func (f *typeForm) Parse(r *http.Request) error {
f.Name.FillValue(r)
f.MaxCampers.FillValue(r)
f.DogsAllowed.FillValue(r)
f.Spiel.FillValue(r)
f.Description.FillValue(r)
f.Media.FillValue(r)
for _, p := range f.Prices {

View File

@ -21,6 +21,7 @@ type typeL10nForm struct {
Locale *locale.Locale
Slug string
Name *form.L10nInput
Spiel *form.L10nInput
Description *form.L10nInput
}
@ -29,6 +30,7 @@ func newTypeL10nForm(f *typeForm, loc *locale.Locale) *typeL10nForm {
Locale: loc,
Slug: f.Slug,
Name: f.Name.L10nInput(),
Spiel: f.Spiel.L10nInput(),
Description: f.Description.L10nInput(),
}
}
@ -36,12 +38,13 @@ func newTypeL10nForm(f *typeForm, loc *locale.Locale) *typeL10nForm {
func (l10n *typeL10nForm) FillFromDatabase(ctx context.Context, conn *database.Conn) error {
row := conn.QueryRow(ctx, `
select coalesce(i18n.name, '') as l10n_name
, coalesce(i18n.spiel, '') as l10n_spiel
, coalesce(i18n.description, '') as l10n_description
from campsite_type
left join campsite_type_i18n as i18n on campsite_type.campsite_type_id = i18n.campsite_type_id and i18n.lang_tag = $1
where slug = $2
`, l10n.Locale.Language, l10n.Slug)
return row.Scan(&l10n.Name.Val, &l10n.Description.Val)
return row.Scan(&l10n.Name.Val, &l10n.Spiel.Val, &l10n.Description.Val)
}
func (l10n *typeL10nForm) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company) {
@ -55,7 +58,7 @@ func editTypeL10n(w http.ResponseWriter, r *http.Request, user *auth.User, compa
l10n.MustRender(w, r, user, company)
return
}
conn.MustExec(r.Context(), "select translate_campsite_type($1, $2, $3, $4)", l10n.Slug, l10n.Locale.Language, l10n.Name, l10n.Description)
conn.MustExec(r.Context(), "select translate_campsite_type($1, $2, $3, $4, $5)", l10n.Slug, l10n.Locale.Language, l10n.Name, l10n.Spiel, l10n.Description)
httplib.Redirect(w, r, "/admin/campsites/types", http.StatusSeeOther)
}
@ -64,6 +67,7 @@ func (l10n *typeL10nForm) Parse(r *http.Request) error {
return err
}
l10n.Name.FillValue(r)
l10n.Spiel.FillValue(r)
l10n.Description.FillValue(r)
return nil
}

View File

@ -54,6 +54,7 @@ type publicPage struct {
Name string
Carousel []*carousel.Slide
Prices []*typePrice
Spiel gotemplate.HTML
Description gotemplate.HTML
}
@ -77,13 +78,14 @@ func newPublicPage(ctx context.Context, conn *database.Conn, loc *locale.Locale,
}
row := conn.QueryRow(ctx, `
select coalesce(i18n.name, campsite_type.name) as l10n_name
, coalesce(i18n.spiel, campsite_type.spiel)::text as l10n_description
, coalesce(i18n.description, campsite_type.description)::text as l10n_description
from campsite_type
left join campsite_type_i18n as i18n on campsite_type.campsite_type_id = i18n.campsite_type_id and i18n.lang_tag = $1
where slug = $2
and active
`, loc.Language, slug)
if err := row.Scan(&page.Name, &page.Description); err != nil {
if err := row.Scan(&page.Name, &page.Spiel, &page.Description); err != nil {
return nil, err
}

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-10-12 16:26+0200\n"
"POT-Creation-Date: 2023-10-12 18:41+0200\n"
"PO-Revision-Date: 2023-07-22 23:45+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n"
@ -213,7 +213,7 @@ msgstr "Llegenda"
#: web/templates/admin/campsite/carousel/form.gohtml:47
#: web/templates/admin/campsite/form.gohtml:70
#: web/templates/admin/campsite/option/form.gohtml:78
#: web/templates/admin/campsite/type/form.gohtml:108
#: web/templates/admin/campsite/type/form.gohtml:115
#: web/templates/admin/season/form.gohtml:64
#: web/templates/admin/services/form.gohtml:69
#: web/templates/admin/media/form.gohtml:35
@ -225,7 +225,7 @@ msgstr "Actualitza"
#: web/templates/admin/campsite/carousel/form.gohtml:49
#: web/templates/admin/campsite/form.gohtml:72
#: web/templates/admin/campsite/option/form.gohtml:80
#: web/templates/admin/campsite/type/form.gohtml:110
#: web/templates/admin/campsite/type/form.gohtml:117
#: web/templates/admin/season/form.gohtml:66
#: web/templates/admin/services/form.gohtml:71
msgctxt "action"
@ -243,6 +243,7 @@ msgstr "Traducció de la diapositiva del carrusel a %s"
#: web/templates/admin/campsite/option/l10n.gohtml:21
#: web/templates/admin/campsite/type/l10n.gohtml:21
#: web/templates/admin/campsite/type/l10n.gohtml:33
#: web/templates/admin/campsite/type/l10n.gohtml:46
#: web/templates/admin/season/l10n.gohtml:21
#: web/templates/admin/services/l10n.gohtml:21
#: web/templates/admin/services/l10n.gohtml:33
@ -254,6 +255,7 @@ msgstr "Origen:"
#: web/templates/admin/campsite/option/l10n.gohtml:23
#: web/templates/admin/campsite/type/l10n.gohtml:23
#: web/templates/admin/campsite/type/l10n.gohtml:36
#: web/templates/admin/campsite/type/l10n.gohtml:49
#: web/templates/admin/season/l10n.gohtml:23
#: web/templates/admin/services/l10n.gohtml:23
#: web/templates/admin/services/l10n.gohtml:36
@ -264,7 +266,7 @@ msgstr "Traducció:"
#: web/templates/admin/carousel/l10n.gohtml:32
#: web/templates/admin/campsite/carousel/l10n.gohtml:32
#: web/templates/admin/campsite/option/l10n.gohtml:32
#: web/templates/admin/campsite/type/l10n.gohtml:45
#: web/templates/admin/campsite/type/l10n.gohtml:58
#: web/templates/admin/season/l10n.gohtml:32
#: web/templates/admin/services/l10n.gohtml:45
msgctxt "action"
@ -522,6 +524,12 @@ msgstr "Número mínim de nits"
#: web/templates/admin/campsite/type/form.gohtml:99
#: web/templates/admin/campsite/type/l10n.gohtml:32
msgctxt "input"
msgid "Spiel"
msgstr "Introducció"
#: web/templates/admin/campsite/type/form.gohtml:106
#: web/templates/admin/campsite/type/l10n.gohtml:45
#: web/templates/admin/services/form.gohtml:60
#: web/templates/admin/services/l10n.gohtml:32
msgctxt "input"
@ -981,9 +989,9 @@ msgctxt "language option"
msgid "Automatic"
msgstr "Automàtic"
#: pkg/app/user.go:249 pkg/campsite/types/l10n.go:73
#: pkg/campsite/types/l10n.go:128 pkg/campsite/types/option.go:336
#: pkg/campsite/types/admin.go:391 pkg/season/l10n.go:69
#: pkg/app/user.go:249 pkg/campsite/types/l10n.go:77
#: pkg/campsite/types/l10n.go:132 pkg/campsite/types/option.go:336
#: pkg/campsite/types/admin.go:397 pkg/season/l10n.go:69
#: pkg/season/admin.go:382 pkg/services/l10n.go:73 pkg/services/admin.go:266
msgid "Name can not be empty."
msgstr "No podeu deixar el nom en blanc."
@ -1004,7 +1012,7 @@ msgstr "El fitxer has de ser una imatge PNG o JPEG vàlida."
msgid "Access forbidden"
msgstr "Accés prohibit"
#: pkg/campsite/types/option.go:337 pkg/campsite/types/admin.go:392
#: pkg/campsite/types/option.go:337 pkg/campsite/types/admin.go:398
msgid "Name must have at least one letter."
msgstr "El nom ha de tenir com a mínim una lletra."
@ -1032,57 +1040,57 @@ msgstr "El valor del màxim ha de ser un número enter."
msgid "Maximum must be equal or greater than minimum."
msgstr "El valor del màxim ha de ser igual o superir al del mínim."
#: pkg/campsite/types/option.go:353 pkg/campsite/types/admin.go:405
#: pkg/campsite/types/option.go:353 pkg/campsite/types/admin.go:411
msgid "Price per night can not be empty."
msgstr "No podeu deixar el preu per nit en blanc."
#: pkg/campsite/types/option.go:354 pkg/campsite/types/admin.go:406
#: pkg/campsite/types/option.go:354 pkg/campsite/types/admin.go:412
msgid "Price per night must be a decimal number."
msgstr "El preu per nit ha de ser un número decimal."
#: pkg/campsite/types/option.go:355 pkg/campsite/types/admin.go:407
#: pkg/campsite/types/option.go:355 pkg/campsite/types/admin.go:413
msgid "Price per night must be zero or greater."
msgstr "El preu per nit ha de ser com a mínim zero."
#: pkg/campsite/types/admin.go:282
#: pkg/campsite/types/admin.go:283
msgctxt "input"
msgid "Cover image"
msgstr "Imatge de portada"
#: pkg/campsite/types/admin.go:283
#: pkg/campsite/types/admin.go:284
msgctxt "action"
msgid "Set campsite type cover"
msgstr "Estableix la portada del tipus dallotjament"
#: pkg/campsite/types/admin.go:394
#: pkg/campsite/types/admin.go:400
msgid "Cover image can not be empty."
msgstr "No podeu deixar la imatge de portada en blanc."
#: pkg/campsite/types/admin.go:395
#: pkg/campsite/types/admin.go:401
msgid "Cover image must be an image media type."
msgstr "La imatge de portada ha de ser un mèdia de tipus imatge."
#: pkg/campsite/types/admin.go:399
#: pkg/campsite/types/admin.go:405
msgid "Maximum number of campers can not be empty."
msgstr "No podeu deixar el número màxim de persones en blanc."
#: pkg/campsite/types/admin.go:400
#: pkg/campsite/types/admin.go:406
msgid "Maximum number of campers must be an integer number."
msgstr "El número màxim de persones ha de ser enter."
#: pkg/campsite/types/admin.go:401
#: pkg/campsite/types/admin.go:407
msgid "Maximum number of campers must be one or greater."
msgstr "El número màxim de persones no pot ser zero."
#: pkg/campsite/types/admin.go:410
#: pkg/campsite/types/admin.go:416
msgid "Minimum number of nights can not be empty."
msgstr "No podeu deixar el número mínim de nits en blanc."
#: pkg/campsite/types/admin.go:411
#: pkg/campsite/types/admin.go:417
msgid "Minimum number of nights must be an integer."
msgstr "El número mínim de nits ha de ser enter."
#: pkg/campsite/types/admin.go:412
#: pkg/campsite/types/admin.go:418
msgid "Minimum number of nights must be one or greater."
msgstr "El número mínim de nits no pot ser zero."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-10-12 16:26+0200\n"
"POT-Creation-Date: 2023-10-12 18:41+0200\n"
"PO-Revision-Date: 2023-07-22 23:46+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n"
@ -213,7 +213,7 @@ msgstr "Leyenda"
#: web/templates/admin/campsite/carousel/form.gohtml:47
#: web/templates/admin/campsite/form.gohtml:70
#: web/templates/admin/campsite/option/form.gohtml:78
#: web/templates/admin/campsite/type/form.gohtml:108
#: web/templates/admin/campsite/type/form.gohtml:115
#: web/templates/admin/season/form.gohtml:64
#: web/templates/admin/services/form.gohtml:69
#: web/templates/admin/media/form.gohtml:35
@ -225,7 +225,7 @@ msgstr "Actualizar"
#: web/templates/admin/campsite/carousel/form.gohtml:49
#: web/templates/admin/campsite/form.gohtml:72
#: web/templates/admin/campsite/option/form.gohtml:80
#: web/templates/admin/campsite/type/form.gohtml:110
#: web/templates/admin/campsite/type/form.gohtml:117
#: web/templates/admin/season/form.gohtml:66
#: web/templates/admin/services/form.gohtml:71
msgctxt "action"
@ -243,6 +243,7 @@ msgstr "Traducción de la diapositiva de carrusel a %s"
#: web/templates/admin/campsite/option/l10n.gohtml:21
#: web/templates/admin/campsite/type/l10n.gohtml:21
#: web/templates/admin/campsite/type/l10n.gohtml:33
#: web/templates/admin/campsite/type/l10n.gohtml:46
#: web/templates/admin/season/l10n.gohtml:21
#: web/templates/admin/services/l10n.gohtml:21
#: web/templates/admin/services/l10n.gohtml:33
@ -254,6 +255,7 @@ msgstr "Origen:"
#: web/templates/admin/campsite/option/l10n.gohtml:23
#: web/templates/admin/campsite/type/l10n.gohtml:23
#: web/templates/admin/campsite/type/l10n.gohtml:36
#: web/templates/admin/campsite/type/l10n.gohtml:49
#: web/templates/admin/season/l10n.gohtml:23
#: web/templates/admin/services/l10n.gohtml:23
#: web/templates/admin/services/l10n.gohtml:36
@ -264,7 +266,7 @@ msgstr "Traducción"
#: web/templates/admin/carousel/l10n.gohtml:32
#: web/templates/admin/campsite/carousel/l10n.gohtml:32
#: web/templates/admin/campsite/option/l10n.gohtml:32
#: web/templates/admin/campsite/type/l10n.gohtml:45
#: web/templates/admin/campsite/type/l10n.gohtml:58
#: web/templates/admin/season/l10n.gohtml:32
#: web/templates/admin/services/l10n.gohtml:45
msgctxt "action"
@ -522,6 +524,12 @@ msgstr "Número mínimos de noches"
#: web/templates/admin/campsite/type/form.gohtml:99
#: web/templates/admin/campsite/type/l10n.gohtml:32
msgctxt "input"
msgid "Spiel"
msgstr "Introducción"
#: web/templates/admin/campsite/type/form.gohtml:106
#: web/templates/admin/campsite/type/l10n.gohtml:45
#: web/templates/admin/services/form.gohtml:60
#: web/templates/admin/services/l10n.gohtml:32
msgctxt "input"
@ -981,9 +989,9 @@ msgctxt "language option"
msgid "Automatic"
msgstr "Automático"
#: pkg/app/user.go:249 pkg/campsite/types/l10n.go:73
#: pkg/campsite/types/l10n.go:128 pkg/campsite/types/option.go:336
#: pkg/campsite/types/admin.go:391 pkg/season/l10n.go:69
#: pkg/app/user.go:249 pkg/campsite/types/l10n.go:77
#: pkg/campsite/types/l10n.go:132 pkg/campsite/types/option.go:336
#: pkg/campsite/types/admin.go:397 pkg/season/l10n.go:69
#: pkg/season/admin.go:382 pkg/services/l10n.go:73 pkg/services/admin.go:266
msgid "Name can not be empty."
msgstr "No podéis dejar el nombre en blanco."
@ -1004,7 +1012,7 @@ msgstr "El archivo tiene que ser una imagen PNG o JPEG válida."
msgid "Access forbidden"
msgstr "Acceso prohibido"
#: pkg/campsite/types/option.go:337 pkg/campsite/types/admin.go:392
#: pkg/campsite/types/option.go:337 pkg/campsite/types/admin.go:398
msgid "Name must have at least one letter."
msgstr "El nombre tiene que tener como mínimo una letra."
@ -1032,57 +1040,57 @@ msgstr "El valor del máximo tiene que ser un número entero."
msgid "Maximum must be equal or greater than minimum."
msgstr "El valor del máximo tiene que ser igual o mayor al del mínimo."
#: pkg/campsite/types/option.go:353 pkg/campsite/types/admin.go:405
#: pkg/campsite/types/option.go:353 pkg/campsite/types/admin.go:411
msgid "Price per night can not be empty."
msgstr "No podéis dejar el precio por noche en blanco."
#: pkg/campsite/types/option.go:354 pkg/campsite/types/admin.go:406
#: pkg/campsite/types/option.go:354 pkg/campsite/types/admin.go:412
msgid "Price per night must be a decimal number."
msgstr "El precio por noche tien que ser un número decimal."
#: pkg/campsite/types/option.go:355 pkg/campsite/types/admin.go:407
#: pkg/campsite/types/option.go:355 pkg/campsite/types/admin.go:413
msgid "Price per night must be zero or greater."
msgstr "El precio por noche tiene que ser como mínimo cero."
#: pkg/campsite/types/admin.go:282
#: pkg/campsite/types/admin.go:283
msgctxt "input"
msgid "Cover image"
msgstr "Imagen de portada"
#: pkg/campsite/types/admin.go:283
#: pkg/campsite/types/admin.go:284
msgctxt "action"
msgid "Set campsite type cover"
msgstr "Establecer la portada del tipo de alojamiento"
#: pkg/campsite/types/admin.go:394
#: pkg/campsite/types/admin.go:400
msgid "Cover image can not be empty."
msgstr "No podéis dejar la imagen de portada en blanco."
#: pkg/campsite/types/admin.go:395
#: pkg/campsite/types/admin.go:401
msgid "Cover image must be an image media type."
msgstr "La imagen de portada tiene que ser un medio de tipo imagen."
#: pkg/campsite/types/admin.go:399
#: pkg/campsite/types/admin.go:405
msgid "Maximum number of campers can not be empty."
msgstr "No podéis dejar el número máximo de personas en blanco."
#: pkg/campsite/types/admin.go:400
#: pkg/campsite/types/admin.go:406
msgid "Maximum number of campers must be an integer number."
msgstr "El número máximo de personas tiene que ser entero."
#: pkg/campsite/types/admin.go:401
#: pkg/campsite/types/admin.go:407
msgid "Maximum number of campers must be one or greater."
msgstr "El número máximo de personas no puede ser cero."
#: pkg/campsite/types/admin.go:410
#: pkg/campsite/types/admin.go:416
msgid "Minimum number of nights can not be empty."
msgstr "No podéis dejar el número mínimo de noches en blanco."
#: pkg/campsite/types/admin.go:411
#: pkg/campsite/types/admin.go:417
msgid "Minimum number of nights must be an integer."
msgstr "El número mínimo de noches tiene que ser entero."
#: pkg/campsite/types/admin.go:412
#: pkg/campsite/types/admin.go:418
msgid "Minimum number of nights must be one or greater."
msgstr "El número mínimo de noches no puede ser cero."

View File

@ -2,6 +2,6 @@
begin;
drop function if exists camper.add_campsite_type(integer, integer, text, text, integer, boolean);
drop function if exists camper.add_campsite_type(integer, integer, text, text, text, integer, boolean);
commit;

View File

@ -2,6 +2,6 @@
begin;
drop function if exists camper.edit_campsite_type(uuid, integer, text, text, integer, boolean, boolean);
drop function if exists camper.edit_campsite_type(uuid, integer, text, text, text, integer, boolean, boolean);
commit;

View File

@ -2,6 +2,6 @@
begin;
drop function if exists camper.translate_campsite_type(uuid, text, text, text);
drop function if exists camper.translate_campsite_type(uuid, text, text, text, text);
commit;

View File

@ -9,15 +9,15 @@ set search_path to camper, public;
select plan(13);
select has_function('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean']);
select function_lang_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'sql');
select function_returns('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'uuid');
select isnt_definer('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean']);
select volatility_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'volatile');
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'guest', array[]::text[]);
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'employee', array[]::text[]);
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'integer', 'boolean'], 'authenticator', array[]::text[]);
select has_function('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean']);
select function_lang_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'sql');
select function_returns('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'uuid');
select isnt_definer('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean']);
select volatility_is('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'volatile');
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'guest', array[]::text[]);
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'employee', array[]::text[]);
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', 'text', 'integer', 'boolean'], 'authenticator', array[]::text[]);
set client_min_messages to warning;
@ -44,19 +44,19 @@ values (3, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a
;
select lives_ok(
$$ select add_campsite_type(1, 3, 'Type A', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', 5, true) $$,
$$ select add_campsite_type(1, 3, 'Type A', '', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', 5, true) $$,
'Should be able to add a campsite type to the first company'
);
select lives_ok(
$$ select add_campsite_type(2, 4, 'Type B', '', 2, false) $$,
$$ select add_campsite_type(2, 4, 'Type B', '<p>One</p><p>Two</p>', '', 2, false) $$,
'Should be able to add a campsite type to the second company'
);
select bag_eq(
$$ select company_id, media_id, name, description::text, active, max_campers, dogs_allowed from campsite_type $$,
$$ values (1, 3, 'Type A', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', true, 5, true)
, (2, 4, 'Type B', '', true, 2, false)
$$ select company_id, media_id, name, spiel::text, description::text, active, max_campers, dogs_allowed from campsite_type $$,
$$ values (1, 3, 'Type A', '', '<!-- block --><h2>This is what, exactly?</h2><!-- /block --><p>Dunno</p>', true, 5, true)
, (2, 4, 'Type B', '<p>One</p><p>Two</p>', '', true, 2, false)
$$,
'Should have added all two campsite type'
);

View File

@ -5,7 +5,7 @@ reset client_min_messages;
begin;
select plan(65);
select plan(69);
set search_path to camper, public;
@ -48,6 +48,12 @@ select col_type_is('campsite_type', 'media_id', 'integer');
select col_not_null('campsite_type', 'media_id');
select col_hasnt_default('campsite_type', 'media_id');
select has_column('campsite_type', 'spiel');
select col_type_is('campsite_type', 'spiel', 'xml');
select col_not_null('campsite_type', 'spiel');
select col_has_default('campsite_type', 'spiel');
--select col_default_is('campsite_type', 'spiel', '');
select has_column('campsite_type', 'description');
select col_type_is('campsite_type', 'description', 'xml');
select col_not_null('campsite_type', 'description');

View File

@ -5,7 +5,7 @@ reset client_min_messages;
begin;
select plan(27);
select plan(31);
set search_path to camper, public;
@ -36,6 +36,11 @@ select col_type_is('campsite_type_i18n', 'name', 'text');
select col_not_null('campsite_type_i18n', 'name');
select col_hasnt_default('campsite_type_i18n', 'name');
select has_column('campsite_type_i18n', 'spiel');
select col_type_is('campsite_type_i18n', 'spiel', 'xml');
select col_not_null('campsite_type_i18n', 'spiel');
select col_hasnt_default('campsite_type_i18n', 'spiel');
select has_column('campsite_type_i18n', 'description');
select col_type_is('campsite_type_i18n', 'description', 'xml');
select col_not_null('campsite_type_i18n', 'description');

View File

@ -9,15 +9,15 @@ set search_path to camper, public;
select plan(12);
select has_function('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean']);
select function_lang_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'sql');
select function_returns('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'uuid');
select isnt_definer('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean']);
select volatility_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'volatile');
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'guest', array[]::text[]);
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'employee', array[]::text[]);
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'integer', 'boolean', 'boolean'], 'authenticator', array[]::text[]);
select has_function('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean']);
select function_lang_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'sql');
select function_returns('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'uuid');
select isnt_definer('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean']);
select volatility_is('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'volatile');
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'guest', array[]::text[]);
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'employee', array[]::text[]);
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', 'text', 'integer', 'boolean', 'boolean'], 'authenticator', array[]::text[]);
set client_min_messages to warning;
truncate campsite_type cascade;
@ -43,25 +43,25 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a
, (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};'))
;
insert into campsite_type (company_id, slug, media_id, name, description, max_campers, dogs_allowed, active)
values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, false, true)
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false)
insert into campsite_type (company_id, slug, media_id, name, spiel, description, max_campers, dogs_allowed, active)
values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<h1>1</h1>', '<p>A</p>', 5, false, true)
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<h2>2</h2>', '<p>B</p>', 4, true, false)
;
select lives_ok(
$$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<p>1</p>', 2, true, false) $$,
$$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<h3>A</h3>', '<p>1</p>', 2, true, false) $$,
'Should be able to edit the first type'
);
select lives_ok(
$$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', null, 'Type 2', '<p>2</p>', 9, false, true) $$,
$$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', null, 'Type 2', '<h1>B</h1>', '<p>2</p>', 9, false, true) $$,
'Should be able to edit the second type'
);
select bag_eq(
$$ select slug::text, media_id, name, description::text, max_campers, dogs_allowed, active from campsite_type $$,
$$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<p>1</p>', 2, true, false)
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '<p>2</p>', 9, false, true)
$$ select slug::text, media_id, name, spiel::text, description::text, max_campers, dogs_allowed, active from campsite_type $$,
$$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 4, 'Type 1', '<h3>A</h3>', '<p>1</p>', 2, true, false)
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '<h1>B</h1>', '<p>2</p>', 9, false, true)
$$,
'Should have updated all campsite types.'
);

View File

@ -9,15 +9,15 @@ select plan(13);
set search_path to camper, public;
select has_function('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text']);
select function_lang_is('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'sql');
select function_returns('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'void');
select isnt_definer('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text']);
select volatility_is('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'volatile');
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'guest', array[]::text[]);
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'employee', array[]::text[]);
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text'], 'authenticator', array[]::text[]);
select has_function('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text']);
select function_lang_is('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'sql');
select function_returns('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'void');
select isnt_definer('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text']);
select volatility_is('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'volatile');
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'guest', array[]::text[]);
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'employee', array[]::text[]);
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'translate_campsite_type', array['uuid', 'text', 'text', 'text', 'text'], 'authenticator', array[]::text[]);
set client_min_messages to warning;
@ -43,36 +43,36 @@ values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a
, (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};'))
;
insert into campsite_type (company_id, slug, media_id, name, description, active, dogs_allowed, max_campers)
values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', true, false, 4)
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', false, true, 5)
insert into campsite_type (company_id, slug, media_id, name, spiel, description, active, dogs_allowed, max_campers)
values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<h2>One</h2>', '<p>A</p>', true, false, 4)
, (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<h2>Two</h2>', '<p>B</p>', false, true, 5)
;
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, description)
select campsite_type_id, 'ca', 'tipusb', '<p>B</p>' from campsite_type
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, description)
select campsite_type_id, 'ca', 'tipusb', '<h2>dos</h2>', '<p>B</p>' from campsite_type
where slug = '9b6370f7-f941-46f2-bc6e-de455675bd0a'
;
select lives_ok(
$$ select translate_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 'ca', 'Tipus A', '<p>a</p>') $$,
$$ select translate_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 'ca', 'Tipus A', '<h2>Un</h2>', '<p>a</p>') $$,
'Should be able to translate the first type'
);
select lives_ok(
$$ select translate_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '<p>b</p>') $$,
$$ select translate_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '<h2>Dos</h2>', '<p>b</p>') $$,
'Should be able to translate the second type'
);
select lives_ok(
$$ select translate_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'ca', 'Tipus B', null) $$,
'Should be able to overwrite the catalan translation of the second type, with no description'
$$ select translate_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'ca', 'Tipus B', null, null) $$,
'Should be able to overwrite the catalan translation of the second type, with no description nor spiel'
);
select bag_eq(
$$ select slug::text, lang_tag, i18n.name, i18n.description::text from campsite_type_i18n as i18n join campsite_type using (campsite_type_id) $$,
$$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 'ca', 'Tipus A', '<p>a</p>')
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'ca', 'Tipus B', '')
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '<p>b</p>')
$$ select slug::text, lang_tag, i18n.name, i18n.spiel::text, i18n.description::text from campsite_type_i18n as i18n join campsite_type using (campsite_type_id) $$,
$$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 'ca', 'Tipus A', '<h2>Un</h2>', '<p>a</p>')
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'ca', 'Tipus B', '', '')
, ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '<h2>Dos</h2>', '<p>b</p>')
$$,
'Should have added and updated all translations.'
);

View File

@ -2,6 +2,6 @@
begin;
select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, integer, boolean)', 'execute');
select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, text, integer, boolean)', 'execute');
rollback;

View File

@ -7,6 +7,7 @@ select campsite_type_id
, slug
, name
, media_id
, spiel
, description
, max_campers
, dogs_allowed

View File

@ -5,6 +5,7 @@ begin;
select campsite_type_id
, lang_tag
, name
, spiel
, description
from camper.campsite_type_i18n
where false;

View File

@ -2,6 +2,6 @@
begin;
select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, integer, boolean, boolean)', 'execute');
select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, text, integer, boolean, boolean)', 'execute');
rollback;

View File

@ -2,6 +2,6 @@
begin;
select has_function_privilege('camper.translate_campsite_type(uuid, text, text, text)', 'execute');
select has_function_privilege('camper.translate_campsite_type(uuid, text, text, text, text)', 'execute');
rollback;

View File

@ -584,7 +584,7 @@ dt {
margin-top: 2rem;
}
.outside_activities h3, .campsite_services .spiel, .campsite_type .spiel {
.outside_activities h3, .campsite_services .spiel {
font-size: calc(2.2rem + 4vw);
font-weight: 600;
line-height: .9em;
@ -662,7 +662,7 @@ dt {
margin-bottom: 5rem;
}
.campsite_services.carousel .slick-track, .campsite_type.carousel .slick-track {
.campsite_services.carousel .slick-track {
align-items: center;
}

View File

@ -94,6 +94,13 @@
{{- end }}
</fieldset>
{{- end }}
{{ with .Spiel -}}
<label>
{{( pgettext "Spiel" "input")}}<br>
<textarea class="html" name="{{ .Name }}" {{ template "error-attrs" . }}>{{ .Val }}</textarea><br>
</label>
{{ template "error-message" . }}
{{- end }}
{{ with .Description -}}
<label>
{{( pgettext "Description" "input")}}<br>

View File

@ -27,6 +27,19 @@
{{ template "error-message" . }}
</fieldset>
{{- end }}
{{ with .Spiel -}}
<fieldset>
<legend{{( pgettext "Spiel" "input")}}></legend>
{{( gettext "Source:" )}}<br>
{{ .Source | raw }}<br>
<label>
{{( pgettext "Translation:" "input" )}}
<textarea class="html"
name="{{ .Name }}" {{ template "error-attrs" . }}>{{ .Val }}</textarea><br>
</label>
{{ template "error-message" . }}
</fieldset>
{{- end }}
{{ with .Description -}}
<fieldset>
<legend{{( pgettext "Description" "input")}}></legend>

View File

@ -18,7 +18,7 @@
{{ with .Carousel -}}
<div class="campsite_type carousel">
<div class="spiel">
<p>TODO</p>
{{ $.Spiel }}
</div>
{{ range . -}}
{{ if .Caption -}}