From ebf47b5d75e70aefeece8bb177a355714e6cc71e Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Thu, 12 Oct 2023 18:47:08 +0200 Subject: [PATCH] =?UTF-8?q?Add=20the=20=E2=80=9Cspiel=E2=80=9D=20for=20cam?= =?UTF-8?q?psite=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- demo/demo.sql | 32 ++++++------ deploy/add_campsite_type.sql | 10 ++-- deploy/campsite_type.sql | 1 + deploy/campsite_type_i18n.sql | 1 + deploy/edit_campsite_type.sql | 7 +-- deploy/translate_campsite_type.sql | 11 ++-- pkg/campsite/types/admin.go | 14 ++++-- pkg/campsite/types/l10n.go | 8 ++- pkg/campsite/types/public.go | 4 +- po/ca.po | 50 +++++++++++-------- po/es.po | 50 +++++++++++-------- revert/add_campsite_type.sql | 2 +- revert/edit_campsite_type.sql | 2 +- revert/translate_campsite_type.sql | 2 +- test/add_campsite_type.sql | 28 +++++------ test/campsite_type.sql | 8 ++- test/campsite_type_i18n.sql | 7 ++- test/edit_campsite_type.sql | 34 ++++++------- test/translate_campsite_type.sql | 44 ++++++++-------- verify/add_campsite_type.sql | 2 +- verify/campsite_type.sql | 1 + verify/campsite_type_i18n.sql | 1 + verify/edit_campsite_type.sql | 2 +- verify/translate_campsite_type.sql | 2 +- web/static/public.css | 4 +- web/templates/admin/campsite/type/form.gohtml | 7 +++ web/templates/admin/campsite/type/l10n.gohtml | 13 +++++ web/templates/public/campsite/type.gohtml | 2 +- 28 files changed, 207 insertions(+), 142 deletions(-) diff --git a/demo/demo.sql b/demo/demo.sql index 5fbe04e..9b3cb50 100644 --- a/demo/demo.sql +++ b/demo/demo.sql @@ -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', '

Acampa enmig de la natura

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

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

', '

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

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

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

', 6, true); +select add_campsite_type(52, 63, 'Safari Tents', '

Glàmping a la teva disposició

Un luxe de tendes per viure aventures.

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

', '

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

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

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

', 6, false); +select add_campsite_type(52, 64, 'Bungalous', '

Allotjaments de luxe

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

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

', '

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

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

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

', 5, false); +select add_campsite_type(52, 65, 'Bungalous prèmium', '

Allotjaments de luxe

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

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

', '

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

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

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

', 5, false); +select add_campsite_type(52, 66, 'Cabanes de fusta', '

Allotjaments de luxe

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

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

', '

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

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

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

', 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', '

Camp in the middle of nature

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

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

', '

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

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

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

') + , (72, 'es', 'Parcelas', '

Acampa enmedio de la naturaleza

Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.

Parcelas amplias con servicios cerca de donde eres para hacer aquello que quieres.

', '

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

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

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

') + , (73, 'en', 'Safari Tents', '

Glamping at your disposal

A luxury of tent for unforgettable adventures.

Two tents with wooden floors, beds, kitchen, and all the amenities to enjoy your vacation.

', '

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

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

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

') + , (73, 'es', 'Tiendas Safari', '

Glamping a tu disposición

Un lujo de tiendas para vivir aventuras.

Dos tiendas con suelo de madera, camas, cocina y todo de comodidades para disfrutar de tus vacanciones.

', '

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

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

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

') + , (74, 'en', 'Bungalows', '

Luxury accomomdations

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

Two two-story solid wood cabins with a covered porch to enjoy among the trees.

', '

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

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

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

') + , (74, 'es', 'Bungalós', '

Alojamientos de lujo

Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.

Dos cabañas de madera maciza de dos plantas y con porche cubierto para disfutrar entre árboles.

', '

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

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

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

') + , (75, 'en', 'Bungalows premium', '

Luxury accomomdations

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

Two two-story solid wood cabins with a covered porch to enjoy among the trees.

', '

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

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

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

') + , (75, 'es', 'Bungalós prémium', '

Alojamientos de lujo

Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.

Dos cabañas de madera maciza de dos plantas y con porche cubierto para disfutrar entre árboles.

', '

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

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

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

') + , (76, 'en', 'Wooden Lodges', '

Luxury accomomdations

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

Two two-story solid wood cabins with a covered porch to enjoy among the trees.

', '

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

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

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

') + , (76, 'es', 'Cabañas de madera', '

Alojamientos de lujo

Ubicadas al lado montaña del camping y con vista a la naturaleza que nos rodea.

Dos cabañas de madera maciza de dos plantas y con porche cubierto para disfutrar entre árboles.

', '

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

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

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

') ; alter table campsite alter column campsite_id restart with 82; diff --git a/deploy/add_campsite_type.sql b/deploy/add_campsite_type.sql index 7686b4d..61f8b0b 100644 --- a/deploy/add_campsite_type.sql +++ b/deploy/add_campsite_type.sql @@ -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; diff --git a/deploy/campsite_type.sql b/deploy/campsite_type.sql index 4b41a87..5339462 100644 --- a/deploy/campsite_type.sql +++ b/deploy/campsite_type.sql @@ -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, diff --git a/deploy/campsite_type_i18n.sql b/deploy/campsite_type_i18n.sql index 7f9b1ff..b61e240 100644 --- a/deploy/campsite_type_i18n.sql +++ b/deploy/campsite_type_i18n.sql @@ -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) ); diff --git a/deploy/edit_campsite_type.sql b/deploy/edit_campsite_type.sql index 8c10e5a..756e35e 100644 --- a/deploy/edit_campsite_type.sql +++ b/deploy/edit_campsite_type.sql @@ -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; diff --git a/deploy/translate_campsite_type.sql b/deploy/translate_campsite_type.sql index d982d16..2fed97e 100644 --- a/deploy/translate_campsite_type.sql +++ b/deploy/translate_campsite_type.sql @@ -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; diff --git a/pkg/campsite/types/admin.go b/pkg/campsite/types/admin.go index f8864ba..9ac8235 100644 --- a/pkg/campsite/types/admin.go +++ b/pkg/campsite/types/admin.go @@ -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 { diff --git a/pkg/campsite/types/l10n.go b/pkg/campsite/types/l10n.go index 5202cb6..71b5aa4 100644 --- a/pkg/campsite/types/l10n.go +++ b/pkg/campsite/types/l10n.go @@ -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 } diff --git a/pkg/campsite/types/public.go b/pkg/campsite/types/public.go index e947a78..1d918f0 100644 --- a/pkg/campsite/types/public.go +++ b/pkg/campsite/types/public.go @@ -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 } diff --git a/po/ca.po b/po/ca.po index 01e67b9..506f49a 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 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 \n" "Language-Team: Catalan \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 d’allotjament" -#: 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." diff --git a/po/es.po b/po/es.po index 4678dae..31fd215 100644 --- a/po/es.po +++ b/po/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 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 \n" "Language-Team: Spanish \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." diff --git a/revert/add_campsite_type.sql b/revert/add_campsite_type.sql index 8c02597..98814de 100644 --- a/revert/add_campsite_type.sql +++ b/revert/add_campsite_type.sql @@ -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; diff --git a/revert/edit_campsite_type.sql b/revert/edit_campsite_type.sql index 84604cb..3cbb906 100644 --- a/revert/edit_campsite_type.sql +++ b/revert/edit_campsite_type.sql @@ -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; diff --git a/revert/translate_campsite_type.sql b/revert/translate_campsite_type.sql index 256c123..a92580f 100644 --- a/revert/translate_campsite_type.sql +++ b/revert/translate_campsite_type.sql @@ -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; diff --git a/test/add_campsite_type.sql b/test/add_campsite_type.sql index fb2ac06..208a493 100644 --- a/test/add_campsite_type.sql +++ b/test/add_campsite_type.sql @@ -9,15 +9,15 @@ set search_path to camper, public; select plan(13); -select has_function('camper', 'add_campsite_type', array ['integer', 'integer', 'text', 'text', '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', '

This is what, exactly?

Dunno

', 5, true) $$, + $$ select add_campsite_type(1, 3, 'Type A', '', '

This is what, exactly?

Dunno

', 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', '

One

Two

', '', 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', '

This is what, exactly?

Dunno

', 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', '', '

This is what, exactly?

Dunno

', true, 5, true) + , (2, 4, 'Type B', '

One

Two

', '', true, 2, false) $$, 'Should have added all two campsite type' ); diff --git a/test/campsite_type.sql b/test/campsite_type.sql index 9da82ea..02fb927 100644 --- a/test/campsite_type.sql +++ b/test/campsite_type.sql @@ -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'); diff --git a/test/campsite_type_i18n.sql b/test/campsite_type_i18n.sql index 92996d4..cc83c22 100644 --- a/test/campsite_type_i18n.sql +++ b/test/campsite_type_i18n.sql @@ -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'); diff --git a/test/edit_campsite_type.sql b/test/edit_campsite_type.sql index 3d50ccd..5291733 100644 --- a/test/edit_campsite_type.sql +++ b/test/edit_campsite_type.sql @@ -9,15 +9,15 @@ set search_path to camper, public; select plan(12); -select has_function('camper', 'edit_campsite_type', array ['uuid', 'integer', 'text', 'text', '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', '

A

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

B

', 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', '

1

', '

A

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

2

', '

B

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

1

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

A

', '

1

', 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', '

2

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

B

', '

2

', 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', '

1

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

2

', 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', '

A

', '

1

', 2, true, false) + , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type 2', '

B

', '

2

', 9, false, true) $$, 'Should have updated all campsite types.' ); diff --git a/test/translate_campsite_type.sql b/test/translate_campsite_type.sql index efb7e6c..acb507a 100644 --- a/test/translate_campsite_type.sql +++ b/test/translate_campsite_type.sql @@ -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', '

A

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

B

', 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', '

One

', '

A

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

Two

', '

B

', false, true, 5) ; -insert into campsite_type_i18n (campsite_type_id, lang_tag, name, description) -select campsite_type_id, 'ca', 'tipusb', '

B

' from campsite_type +insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, description) +select campsite_type_id, 'ca', 'tipusb', '

dos

', '

B

' 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', '

a

') $$, + $$ select translate_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 'ca', 'Tipus A', '

Un

', '

a

') $$, 'Should be able to translate the first type' ); select lives_ok( - $$ select translate_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '

b

') $$, + $$ select translate_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '

Dos

', '

b

') $$, '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', '

a

') - , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'ca', 'Tipus B', '') - , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '

b

') + $$ 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', '

Un

', '

a

') + , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'ca', 'Tipus B', '', '') + , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'es', 'Tipo B', '

Dos

', '

b

') $$, 'Should have added and updated all translations.' ); diff --git a/verify/add_campsite_type.sql b/verify/add_campsite_type.sql index a90a8b6..727d9e2 100644 --- a/verify/add_campsite_type.sql +++ b/verify/add_campsite_type.sql @@ -2,6 +2,6 @@ begin; -select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, integer, boolean)', 'execute'); +select has_function_privilege('camper.add_campsite_type(integer, integer, text, text, text, integer, boolean)', 'execute'); rollback; diff --git a/verify/campsite_type.sql b/verify/campsite_type.sql index c64a061..cb8342d 100644 --- a/verify/campsite_type.sql +++ b/verify/campsite_type.sql @@ -7,6 +7,7 @@ select campsite_type_id , slug , name , media_id + , spiel , description , max_campers , dogs_allowed diff --git a/verify/campsite_type_i18n.sql b/verify/campsite_type_i18n.sql index bfa49e1..0a77b13 100644 --- a/verify/campsite_type_i18n.sql +++ b/verify/campsite_type_i18n.sql @@ -5,6 +5,7 @@ begin; select campsite_type_id , lang_tag , name + , spiel , description from camper.campsite_type_i18n where false; diff --git a/verify/edit_campsite_type.sql b/verify/edit_campsite_type.sql index 4436b6e..210a12e 100644 --- a/verify/edit_campsite_type.sql +++ b/verify/edit_campsite_type.sql @@ -2,6 +2,6 @@ begin; -select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, integer, boolean, boolean)', 'execute'); +select has_function_privilege('camper.edit_campsite_type(uuid, integer, text, text, text, integer, boolean, boolean)', 'execute'); rollback; diff --git a/verify/translate_campsite_type.sql b/verify/translate_campsite_type.sql index f5c79d9..73247ae 100644 --- a/verify/translate_campsite_type.sql +++ b/verify/translate_campsite_type.sql @@ -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; diff --git a/web/static/public.css b/web/static/public.css index 6855949..e7c832a 100644 --- a/web/static/public.css +++ b/web/static/public.css @@ -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; } diff --git a/web/templates/admin/campsite/type/form.gohtml b/web/templates/admin/campsite/type/form.gohtml index 8cdf500..53fca2d 100644 --- a/web/templates/admin/campsite/type/form.gohtml +++ b/web/templates/admin/campsite/type/form.gohtml @@ -94,6 +94,13 @@ {{- end }} {{- end }} + {{ with .Spiel -}} + + {{ template "error-message" . }} + {{- end }} {{ with .Description -}}