From 208952b96483b0ed00423d95af5dff196fcb7100 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Mon, 14 Aug 2023 11:43:58 +0200 Subject: [PATCH] =?UTF-8?q?Add=20the=20Active=20field=20to=20the=20campsit?= =?UTF-8?q?e=20type=E2=80=99s=20edit=20form=20and=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the new form this field is hidden and always active, because it makes no sense to add an inactive campsite type. --- deploy/edit_campsite_type.sql | 7 +- pkg/campsite/types/admin.go | 23 +-- pkg/form/checkbox.go | 29 ++++ po/ca.po | 136 +++++++++--------- po/es.po | 136 +++++++++--------- revert/edit_campsite_type.sql | 2 +- test/edit_campsite_type.sql | 38 ++--- verify/edit_campsite_type.sql | 2 +- .../campsite/type/{new.gohtml => form.gohtml} | 12 ++ .../admin/campsite/type/index.gohtml | 2 + 10 files changed, 219 insertions(+), 168 deletions(-) create mode 100644 pkg/form/checkbox.go rename web/templates/admin/campsite/type/{new.gohtml => form.gohtml} (78%) diff --git a/deploy/edit_campsite_type.sql b/deploy/edit_campsite_type.sql index b0bfe86..2315986 100644 --- a/deploy/edit_campsite_type.sql +++ b/deploy/edit_campsite_type.sql @@ -8,18 +8,19 @@ begin; set search_path to camper, public; -create or replace function edit_campsite_type(slug uuid, name text, description text) returns uuid as +create or replace function edit_campsite_type(slug uuid, name text, description text, active boolean) returns uuid as $$ update campsite_type set name = edit_campsite_type.name , description = xmlparse(content edit_campsite_type.description) + , active = edit_campsite_type.active where slug = edit_campsite_type.slug returning slug; $$ language sql ; -revoke execute on function edit_campsite_type(uuid, text, text) from public; -grant execute on function edit_campsite_type(uuid, text, text) to admin; +revoke execute on function edit_campsite_type(uuid, text, text, boolean) from public; +grant execute on function edit_campsite_type(uuid, text, text, boolean) to admin; commit; diff --git a/pkg/campsite/types/admin.go b/pkg/campsite/types/admin.go index 28c0661..9220ef1 100644 --- a/pkg/campsite/types/admin.go +++ b/pkg/campsite/types/admin.go @@ -81,12 +81,13 @@ func serveTypeIndex(w http.ResponseWriter, r *http.Request, user *auth.User, com } type typeEntry struct { - Slug string - Name string + Slug string + Name string + Active bool } func collectTypeEntries(ctx context.Context, company *auth.Company, conn *database.Conn) ([]*typeEntry, error) { - rows, err := conn.Query(ctx, "select slug, name from campsite_type where company_id = $1", company.ID) + rows, err := conn.Query(ctx, "select slug, name, active from campsite_type where company_id = $1", company.ID) if err != nil { return nil, err } @@ -95,7 +96,7 @@ func collectTypeEntries(ctx context.Context, company *auth.Company, conn *databa var types []*typeEntry for rows.Next() { entry := &typeEntry{} - if err = rows.Scan(&entry.Slug, &entry.Name); err != nil { + if err = rows.Scan(&entry.Slug, &entry.Name, &entry.Active); err != nil { return nil, err } types = append(types, entry) @@ -149,18 +150,23 @@ func editType(w http.ResponseWriter, r *http.Request, user *auth.User, company * f.MustRender(w, r, user, company) return } - conn.MustExec(r.Context(), "select edit_campsite_type($1, $2, $3)", f.Slug, f.Name, f.Description) + conn.MustExec(r.Context(), "select edit_campsite_type($1, $2, $3, $4)", f.Slug, f.Name, f.Description, f.Active) httplib.Redirect(w, r, "/admin/campsites/types", http.StatusSeeOther) } type typeForm struct { Slug string + Active *form.Checkbox Name *form.Input Description *form.Input } func newTypeForm() *typeForm { return &typeForm{ + Active: &form.Checkbox{ + Name: "active", + Checked: true, + }, Name: &form.Input{ Name: "name", }, @@ -172,14 +178,15 @@ func newTypeForm() *typeForm { func (f *typeForm) FillFromDatabase(ctx context.Context, conn *database.Conn, slug string) error { f.Slug = slug - row := conn.QueryRow(ctx, "select name, description from campsite_type where slug = $1", slug) - return row.Scan(&f.Name.Val, &f.Description.Val) + row := conn.QueryRow(ctx, "select name, description, active from campsite_type where slug = $1", slug) + return row.Scan(&f.Name.Val, &f.Description.Val, &f.Active.Checked) } func (f *typeForm) Parse(r *http.Request) error { if err := r.ParseForm(); err != nil { return err } + f.Active.FillValue(r) f.Name.FillValue(r) f.Description.FillValue(r) return nil @@ -192,5 +199,5 @@ func (f *typeForm) Valid(l *locale.Locale) bool { } func (f *typeForm) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company) { - template.MustRenderAdmin(w, r, user, company, "campsite/type/new.gohtml", f) + template.MustRenderAdmin(w, r, user, company, "campsite/type/form.gohtml", f) } diff --git a/pkg/form/checkbox.go b/pkg/form/checkbox.go new file mode 100644 index 0000000..4e71e89 --- /dev/null +++ b/pkg/form/checkbox.go @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2023 jordi fita mas + * SPDX-License-Identifier: AGPL-3.0-only + */ + +package form + +import ( + "database/sql/driver" + "net/http" +) + +type Checkbox struct { + Name string + Checked bool + Error error +} + +func (checkbox *Checkbox) setError(err error) { + checkbox.Error = err +} + +func (checkbox *Checkbox) FillValue(r *http.Request) { + checkbox.Checked = len(r.Form[checkbox.Name]) > 0 +} + +func (checkbox *Checkbox) Value() (driver.Value, error) { + return checkbox.Checked, nil +} diff --git a/po/ca.po b/po/ca.po index 903c9c9..50124ca 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-08-08 20:04+0200\n" +"POT-Creation-Date: 2023-08-14 11:39+0200\n" "PO-Revision-Date: 2023-07-22 23:45+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Catalan \n" @@ -35,83 +35,45 @@ msgstr "Salta al contingut principal" msgid "Singular Lodges" msgstr "Allotjaments singulars" -#: web/templates/admin/page/form.gohtml:16 -#: web/templates/admin/page/form.gohtml:33 -msgctxt "title" -msgid "Edit Page" -msgstr "Edició de pàgina" - -#: web/templates/admin/page/form.gohtml:18 -#: web/templates/admin/page/form.gohtml:35 -msgctxt "title" -msgid "New Page" -msgstr "Nova pàgina" - -#: web/templates/admin/page/form.gohtml:42 -msgctxt "input" -msgid "Title" -msgstr "Títol" - -#: web/templates/admin/page/form.gohtml:50 -msgctxt "input" -msgid "Content" -msgstr "Contingut" - -#: web/templates/admin/page/form.gohtml:59 -#: web/templates/admin/campsite/type/new.gohtml:59 -msgctxt "action" -msgid "Update" -msgstr "Actualitza" - -#: web/templates/admin/page/form.gohtml:61 -#: web/templates/admin/campsite/type/new.gohtml:61 -msgctxt "action" -msgid "Add" -msgstr "Afegeix" - -#: web/templates/admin/page/index.gohtml:6 -#: web/templates/admin/page/index.gohtml:12 -msgctxt "title" -msgid "Pages" -msgstr "Pàgines" - -#: web/templates/admin/page/index.gohtml:11 -msgctxt "action" -msgid "Add Page" -msgstr "Afegeix pàgina" - -#: web/templates/admin/page/index.gohtml:17 -msgctxt "header" -msgid "Title" -msgstr "Títol" - -#: web/templates/admin/page/index.gohtml:29 -msgid "No pages added yet." -msgstr "No s’ha afegit cap pàgina encara." - -#: web/templates/admin/campsite/type/new.gohtml:16 -#: web/templates/admin/campsite/type/new.gohtml:33 +#: web/templates/admin/campsite/type/form.gohtml:8 +#: web/templates/admin/campsite/type/form.gohtml:25 msgctxt "title" msgid "Edit Campsite Type" msgstr "Edició del tipus d’allotjament" -#: web/templates/admin/campsite/type/new.gohtml:18 -#: web/templates/admin/campsite/type/new.gohtml:35 +#: web/templates/admin/campsite/type/form.gohtml:10 +#: web/templates/admin/campsite/type/form.gohtml:27 msgctxt "title" msgid "New Campsite Type" msgstr "Nou tipus d’allotjament" -#: web/templates/admin/campsite/type/new.gohtml:42 +#: web/templates/admin/campsite/type/form.gohtml:37 +#: web/templates/admin/campsite/type/index.gohtml:18 +msgctxt "campsite type" +msgid "Active" +msgstr "Actiu" + +#: web/templates/admin/campsite/type/form.gohtml:46 #: web/templates/admin/profile.gohtml:26 msgctxt "input" msgid "Name" msgstr "Nom" -#: web/templates/admin/campsite/type/new.gohtml:50 +#: web/templates/admin/campsite/type/form.gohtml:54 msgctxt "input" msgid "Description" msgstr "Descripció" +#: web/templates/admin/campsite/type/form.gohtml:63 +msgctxt "action" +msgid "Update" +msgstr "Actualitza" + +#: web/templates/admin/campsite/type/form.gohtml:65 +msgctxt "action" +msgid "Add" +msgstr "Afegeix" + #: web/templates/admin/campsite/type/index.gohtml:6 #: web/templates/admin/campsite/type/index.gohtml:12 msgctxt "title" @@ -128,7 +90,15 @@ msgctxt "header" msgid "Name" msgstr "Nom" -#: web/templates/admin/campsite/type/index.gohtml:29 +#: web/templates/admin/campsite/type/index.gohtml:25 +msgid "Yes" +msgstr "Sí" + +#: web/templates/admin/campsite/type/index.gohtml:25 +msgid "No" +msgstr "No" + +#: web/templates/admin/campsite/type/index.gohtml:31 msgid "No campsite types added yet." msgstr "No s’ha afegit cap tipus d’allotjament encara." @@ -199,10 +169,6 @@ msgctxt "action" msgid "Logout" msgstr "Surt" -#: pkg/page/admin.go:157 -msgid "Title can not be empty." -msgstr "No podeu deixar el títol en blanc." - #: pkg/app/login.go:56 pkg/app/user.go:246 msgid "Email can not be empty." msgstr "No podeu deixar el correu-e en blanc." @@ -224,7 +190,7 @@ msgctxt "language option" msgid "Automatic" msgstr "Automàtic" -#: pkg/app/user.go:249 pkg/campsite/types/admin.go:190 +#: pkg/app/user.go:249 pkg/campsite/types/admin.go:197 msgid "Name can not be empty." msgstr "No podeu deixar el nom en blanc." @@ -240,10 +206,44 @@ msgstr "L’idioma escollit no és vàlid." msgid "File must be a valid PNG or JPEG image." msgstr "El fitxer has de ser una imatge PNG o JPEG vàlida." -#: pkg/app/admin.go:40 +#: pkg/app/admin.go:37 msgid "Access forbidden" msgstr "Accés prohibit" #: pkg/auth/user.go:40 msgid "Cross-site request forgery detected." msgstr "S’ha detectat un intent de falsificació de petició a llocs creuats." + +#~ msgctxt "title" +#~ msgid "Edit Page" +#~ msgstr "Edició de pàgina" + +#~ msgctxt "title" +#~ msgid "New Page" +#~ msgstr "Nova pàgina" + +#~ msgctxt "input" +#~ msgid "Title" +#~ msgstr "Títol" + +#~ msgctxt "input" +#~ msgid "Content" +#~ msgstr "Contingut" + +#~ msgctxt "title" +#~ msgid "Pages" +#~ msgstr "Pàgines" + +#~ msgctxt "action" +#~ msgid "Add Page" +#~ msgstr "Afegeix pàgina" + +#~ msgctxt "header" +#~ msgid "Title" +#~ msgstr "Títol" + +#~ msgid "No pages added yet." +#~ msgstr "No s’ha afegit cap pàgina encara." + +#~ msgid "Title can not be empty." +#~ msgstr "No podeu deixar el títol en blanc." diff --git a/po/es.po b/po/es.po index ec39984..a35bb89 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-08-08 20:04+0200\n" +"POT-Creation-Date: 2023-08-14 11:39+0200\n" "PO-Revision-Date: 2023-07-22 23:46+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Spanish \n" @@ -35,83 +35,45 @@ msgstr "Saltar al contenido principal" msgid "Singular Lodges" msgstr "Alojamientos singulares" -#: web/templates/admin/page/form.gohtml:16 -#: web/templates/admin/page/form.gohtml:33 -msgctxt "title" -msgid "Edit Page" -msgstr "Edición de página" - -#: web/templates/admin/page/form.gohtml:18 -#: web/templates/admin/page/form.gohtml:35 -msgctxt "title" -msgid "New Page" -msgstr "Nueva página" - -#: web/templates/admin/page/form.gohtml:42 -msgctxt "input" -msgid "Title" -msgstr "Título" - -#: web/templates/admin/page/form.gohtml:50 -msgctxt "input" -msgid "Content" -msgstr "Contenido" - -#: web/templates/admin/page/form.gohtml:59 -#: web/templates/admin/campsite/type/new.gohtml:59 -msgctxt "action" -msgid "Update" -msgstr "Actualitzar" - -#: web/templates/admin/page/form.gohtml:61 -#: web/templates/admin/campsite/type/new.gohtml:61 -msgctxt "action" -msgid "Add" -msgstr "Añadir" - -#: web/templates/admin/page/index.gohtml:6 -#: web/templates/admin/page/index.gohtml:12 -msgctxt "title" -msgid "Pages" -msgstr "Páginas" - -#: web/templates/admin/page/index.gohtml:11 -msgctxt "action" -msgid "Add Page" -msgstr "Añadir página" - -#: web/templates/admin/page/index.gohtml:17 -msgctxt "header" -msgid "Title" -msgstr "Título" - -#: web/templates/admin/page/index.gohtml:29 -msgid "No pages added yet." -msgstr "No se ha añadido ninguna página todavía." - -#: web/templates/admin/campsite/type/new.gohtml:16 -#: web/templates/admin/campsite/type/new.gohtml:33 +#: web/templates/admin/campsite/type/form.gohtml:8 +#: web/templates/admin/campsite/type/form.gohtml:25 msgctxt "title" msgid "Edit Campsite Type" msgstr "Edición del tipo de alojamientos" -#: web/templates/admin/campsite/type/new.gohtml:18 -#: web/templates/admin/campsite/type/new.gohtml:35 +#: web/templates/admin/campsite/type/form.gohtml:10 +#: web/templates/admin/campsite/type/form.gohtml:27 msgctxt "title" msgid "New Campsite Type" msgstr "Nuevo tipo de alojamiento" -#: web/templates/admin/campsite/type/new.gohtml:42 +#: web/templates/admin/campsite/type/form.gohtml:37 +#: web/templates/admin/campsite/type/index.gohtml:18 +msgctxt "campsite type" +msgid "Active" +msgstr "Activo" + +#: web/templates/admin/campsite/type/form.gohtml:46 #: web/templates/admin/profile.gohtml:26 msgctxt "input" msgid "Name" msgstr "Nombre" -#: web/templates/admin/campsite/type/new.gohtml:50 +#: web/templates/admin/campsite/type/form.gohtml:54 msgctxt "input" msgid "Description" msgstr "Descripción" +#: web/templates/admin/campsite/type/form.gohtml:63 +msgctxt "action" +msgid "Update" +msgstr "Actualitzar" + +#: web/templates/admin/campsite/type/form.gohtml:65 +msgctxt "action" +msgid "Add" +msgstr "Añadir" + #: web/templates/admin/campsite/type/index.gohtml:6 #: web/templates/admin/campsite/type/index.gohtml:12 msgctxt "title" @@ -128,7 +90,15 @@ msgctxt "header" msgid "Name" msgstr "Nombre" -#: web/templates/admin/campsite/type/index.gohtml:29 +#: web/templates/admin/campsite/type/index.gohtml:25 +msgid "Yes" +msgstr "Sí" + +#: web/templates/admin/campsite/type/index.gohtml:25 +msgid "No" +msgstr "No" + +#: web/templates/admin/campsite/type/index.gohtml:31 msgid "No campsite types added yet." msgstr "No se ha añadido ningún tipo de alojamiento todavía." @@ -199,10 +169,6 @@ msgctxt "action" msgid "Logout" msgstr "Salir" -#: pkg/page/admin.go:157 -msgid "Title can not be empty." -msgstr "No podéis dejar el título en blanco." - #: pkg/app/login.go:56 pkg/app/user.go:246 msgid "Email can not be empty." msgstr "No podéis dejar el correo-e en blanco." @@ -224,7 +190,7 @@ msgctxt "language option" msgid "Automatic" msgstr "Automático" -#: pkg/app/user.go:249 pkg/campsite/types/admin.go:190 +#: pkg/app/user.go:249 pkg/campsite/types/admin.go:197 msgid "Name can not be empty." msgstr "No podéis dejar el nombre en blanco." @@ -240,10 +206,44 @@ msgstr "El idioma escogido no es válido." msgid "File must be a valid PNG or JPEG image." msgstr "El archivo tiene que ser una imagen PNG o JPEG válida." -#: pkg/app/admin.go:40 +#: pkg/app/admin.go:37 msgid "Access forbidden" msgstr "Acceso prohibido" #: pkg/auth/user.go:40 msgid "Cross-site request forgery detected." msgstr "Se ha detectado un intento de falsificación de petición en sitios cruzados." + +#~ msgctxt "title" +#~ msgid "Edit Page" +#~ msgstr "Edición de página" + +#~ msgctxt "title" +#~ msgid "New Page" +#~ msgstr "Nueva página" + +#~ msgctxt "input" +#~ msgid "Title" +#~ msgstr "Título" + +#~ msgctxt "input" +#~ msgid "Content" +#~ msgstr "Contenido" + +#~ msgctxt "title" +#~ msgid "Pages" +#~ msgstr "Páginas" + +#~ msgctxt "action" +#~ msgid "Add Page" +#~ msgstr "Añadir página" + +#~ msgctxt "header" +#~ msgid "Title" +#~ msgstr "Título" + +#~ msgid "No pages added yet." +#~ msgstr "No se ha añadido ninguna página todavía." + +#~ msgid "Title can not be empty." +#~ msgstr "No podéis dejar el título en blanco." diff --git a/revert/edit_campsite_type.sql b/revert/edit_campsite_type.sql index 4aa8ab0..ab3ba75 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, text, text); +drop function if exists camper.edit_campsite_type(uuid, text, text, boolean); commit; diff --git a/test/edit_campsite_type.sql b/test/edit_campsite_type.sql index 7f7346a..395cd73 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', 'text', 'text']); -select function_lang_is('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'sql'); -select function_returns('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'uuid'); -select isnt_definer('camper', 'edit_campsite_type', array ['uuid', 'text', 'text']); -select volatility_is('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'volatile'); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'guest', array[]::text[]); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'employee', array[]::text[]); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'admin', array['EXECUTE']); -select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text'], 'authenticator', array[]::text[]); +select has_function('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean']); +select function_lang_is('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'sql'); +select function_returns('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'uuid'); +select isnt_definer('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean']); +select volatility_is('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'volatile'); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'guest', array[]::text[]); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'employee', array[]::text[]); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'edit_campsite_type', array ['uuid', 'text', 'text', 'boolean'], 'authenticator', array[]::text[]); set client_min_messages to warning; truncate campsite_type cascade; @@ -29,25 +29,25 @@ insert into company (company_id, business_name, vatin, trade_name, phone, email, values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', 'ES', 'EUR', 'ca') ; -insert into campsite_type (company_id, slug, name, description) -values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 'Type A', '

A

') - , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 'Type B', '

B

') +insert into campsite_type (company_id, slug, name, description, active) +values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 'Type A', '

A

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

B

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

1

') $$, - 'Should be ablo to edit the first type' + $$ select edit_campsite_type('87452b88-b48f-48d3-bb6c-0296de64164e', 'Type 1', '

1

', false) $$, + 'Should be able to edit the first type' ); select lives_ok( - $$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'Type 2', '

2

') $$, - 'Should be ablo to edit the second type' + $$ select edit_campsite_type('9b6370f7-f941-46f2-bc6e-de455675bd0a', 'Type 2', '

2

', true) $$, + 'Should be able to edit the second type' ); select bag_eq( - $$ select slug::text, name, description::text from campsite_type $$, - $$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 'Type 1', '

1

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

2

') + $$ select slug::text, name, description::text, active from campsite_type $$, + $$ values ('87452b88-b48f-48d3-bb6c-0296de64164e', 'Type 1', '

1

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

2

', true) $$, 'Should have updated all campsite types.' ); diff --git a/verify/edit_campsite_type.sql b/verify/edit_campsite_type.sql index 28d51c6..6a82ba0 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, text, text)', 'execute'); +select has_function_privilege('camper.edit_campsite_type(uuid, text, text, boolean)', 'execute'); rollback; diff --git a/web/templates/admin/campsite/type/new.gohtml b/web/templates/admin/campsite/type/form.gohtml similarity index 78% rename from web/templates/admin/campsite/type/new.gohtml rename to web/templates/admin/campsite/type/form.gohtml index 1937930..765acac 100644 --- a/web/templates/admin/campsite/type/new.gohtml +++ b/web/templates/admin/campsite/type/form.gohtml @@ -29,6 +29,18 @@ {{ CSRFInput }}
+ {{ if .Slug }} + {{ with .Active -}} + + {{ template "error-message" . }} + {{- end }} + {{ else }} + + {{ end }} {{ with .Name -}}