Add function to delete campsite type features

This commit is contained in:
jordi fita mas 2024-01-26 22:54:19 +01:00
parent bd124581cc
commit 629ef1a262
12 changed files with 225 additions and 40 deletions

View File

@ -0,0 +1,22 @@
-- Deploy camper:remove_campsite_type_feature to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type_feature
-- requires: campsite_type_feature_i18n
begin;
set search_path to camper, public;
create or replace function remove_campsite_type_feature(feature_id integer) returns void as
$$
delete from campsite_type_feature_i18n where campsite_type_feature_id = feature_id;
delete from campsite_type_feature where campsite_type_feature_id = feature_id;
$$
language sql
;
revoke execute on function remove_campsite_type_feature(integer) from public;
grant execute on function remove_campsite_type_feature(integer) to admin;
commit;

View File

@ -81,8 +81,10 @@ func (h *AdminHandler) featureHandler(user *auth.User, company *auth.Company, co
f.MustRender(w, r, user, company)
case http.MethodPut:
editFeature(w, r, user, company, conn, f)
case http.MethodDelete:
deleteFeature(w, r, user, conn, f.TypeSlug, f.ID)
default:
httplib.MethodNotAllowed(w, r, http.MethodGet, http.MethodPut)
httplib.MethodNotAllowed(w, r, http.MethodGet, http.MethodPut, http.MethodDelete)
}
default:
http.NotFound(w, r)
@ -202,6 +204,17 @@ func processFeatureForm(w http.ResponseWriter, r *http.Request, user *auth.User,
httplib.Redirect(w, r, "/admin/campsites/types/"+f.TypeSlug+"/features", http.StatusSeeOther)
}
func deleteFeature(w http.ResponseWriter, r *http.Request, user *auth.User, conn *database.Conn, typeSlug string, id int) {
if err := user.VerifyCSRFToken(r); err != nil {
http.Error(w, err.Error(), http.StatusForbidden)
return
}
if err := conn.RemoveCampsiteTypeFeature(r.Context(), id); err != nil {
panic(err)
}
httplib.Redirect(w, r, "/admin/campsites/types/"+typeSlug+"/features", http.StatusSeeOther)
}
type featureForm struct {
DefaultLang string
ID int

View File

@ -141,6 +141,11 @@ func (c *Conn) OrderCampsiteTypeFeatures(ctx context.Context, ids []int) error {
return err
}
func (c *Conn) RemoveCampsiteTypeFeature(ctx context.Context, id int) error {
_, err := c.Exec(ctx, "select remove_campsite_type_feature($1)", id)
return err
}
func (tx *Tx) AddCampsiteTypeCarouselSlide(ctx context.Context, typeSlug string, mediaID int, caption string) error {
_, err := tx.Exec(ctx, "select add_campsite_type_carousel_slide($1, $2, $3)", typeSlug, mediaID, caption)
return 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: 2024-01-26 21:20+0100\n"
"POT-Creation-Date: 2024-01-26 22:47+0100\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"
@ -604,6 +604,7 @@ msgstr "Afegeix característica"
#: web/templates/admin/campsite/feature/index.gohtml:31
#: web/templates/admin/campsite/carousel/index.gohtml:31
#: web/templates/admin/campsite/type/feature/index.gohtml:32
#: web/templates/admin/campsite/type/carousel/index.gohtml:32
#: web/templates/admin/campsite/type/option/index.gohtml:31
#: web/templates/admin/services/index.gohtml:30
@ -617,12 +618,13 @@ msgid "Actions"
msgstr "Accions"
#: web/templates/admin/campsite/feature/index.gohtml:35
#: web/templates/admin/campsite/type/option/index.gohtml:35
msgid "Are you sure you wish to delete this option?"
msgstr "Esteu segur de voler esborrar aquesta opció?"
#: web/templates/admin/campsite/type/feature/index.gohtml:36
msgid "Are you sure you wish to delete this feature?"
msgstr "Esteu segur de voler esborrar aquesta característica?"
#: web/templates/admin/campsite/feature/index.gohtml:47
#: web/templates/admin/campsite/carousel/index.gohtml:49
#: web/templates/admin/campsite/type/feature/index.gohtml:48
#: web/templates/admin/campsite/type/carousel/index.gohtml:50
#: web/templates/admin/campsite/type/option/index.gohtml:47
#: web/templates/admin/services/index.gohtml:47
@ -827,7 +829,7 @@ msgctxt "title"
msgid "Campsite Type Features"
msgstr "Característiques del tipus dallotjaments"
#: web/templates/admin/campsite/type/feature/index.gohtml:48
#: web/templates/admin/campsite/type/feature/index.gohtml:57
msgid "No campsite type features added yet."
msgstr "No sha afegit cap característica al tipus dallotjament encara."
@ -960,6 +962,10 @@ msgctxt "action"
msgid "Add Option"
msgstr "Afegeix opció"
#: web/templates/admin/campsite/type/option/index.gohtml:35
msgid "Are you sure you wish to delete this option?"
msgstr "Esteu segur de voler esborrar aquesta opció?"
#: web/templates/admin/campsite/type/option/index.gohtml:56
msgid "No campsite type options added yet."
msgstr "No sha afegit cap opció al tipus dallotjament encara."
@ -1538,14 +1544,14 @@ msgid "No booking found."
msgstr "No sha trobat cap reserva."
#: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357
#: pkg/campsite/types/feature.go:259 pkg/campsite/types/admin.go:483
#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:483
#: pkg/campsite/feature.go:269 pkg/season/admin.go:412
#: pkg/services/admin.go:316 pkg/surroundings/admin.go:340
msgid "Name can not be empty."
msgstr "No podeu deixar el nom en blanc."
#: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358
#: pkg/campsite/types/feature.go:260 pkg/campsite/types/admin.go:484
#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:484
#: pkg/campsite/feature.go:270
msgid "Name must have at least one letter."
msgstr "El nom ha de tenir com a mínim una lletra."
@ -1647,7 +1653,7 @@ msgstr "El preu per nit ha de ser un número decimal."
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/feature.go:258 pkg/campsite/feature.go:268
#: pkg/campsite/types/feature.go:271 pkg/campsite/feature.go:268
#: pkg/services/admin.go:315
msgid "Selected icon is not valid."
msgstr "La icona escollida no és vàlida."
@ -1702,11 +1708,11 @@ msgstr "El número mínim de nits ha de ser enter."
msgid "Minimum number of nights must be one or greater."
msgstr "El número mínim de nits no pot ser zero."
#: pkg/campsite/admin.go:274 pkg/booking/public.go:278
#: pkg/campsite/admin.go:275 pkg/booking/public.go:278
msgid "Selected campsite type is not valid."
msgstr "El tipus dallotjament escollit no és vàlid."
#: pkg/campsite/admin.go:275
#: pkg/campsite/admin.go:276
msgid "Label can not be empty."
msgstr "No podeu deixar letiqueta en blanc."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-01-26 21:20+0100\n"
"POT-Creation-Date: 2024-01-26 22:47+0100\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"
@ -604,6 +604,7 @@ msgstr "Añadir características"
#: web/templates/admin/campsite/feature/index.gohtml:31
#: web/templates/admin/campsite/carousel/index.gohtml:31
#: web/templates/admin/campsite/type/feature/index.gohtml:32
#: web/templates/admin/campsite/type/carousel/index.gohtml:32
#: web/templates/admin/campsite/type/option/index.gohtml:31
#: web/templates/admin/services/index.gohtml:30
@ -617,12 +618,13 @@ msgid "Actions"
msgstr "Acciones"
#: web/templates/admin/campsite/feature/index.gohtml:35
#: web/templates/admin/campsite/type/option/index.gohtml:35
msgid "Are you sure you wish to delete this option?"
msgstr "¿Estáis seguro de querer borrar esta opción?"
#: web/templates/admin/campsite/type/feature/index.gohtml:36
msgid "Are you sure you wish to delete this feature?"
msgstr "¿Estáis seguro de querer borrar esta característica?"
#: web/templates/admin/campsite/feature/index.gohtml:47
#: web/templates/admin/campsite/carousel/index.gohtml:49
#: web/templates/admin/campsite/type/feature/index.gohtml:48
#: web/templates/admin/campsite/type/carousel/index.gohtml:50
#: web/templates/admin/campsite/type/option/index.gohtml:47
#: web/templates/admin/services/index.gohtml:47
@ -827,7 +829,7 @@ msgctxt "title"
msgid "Campsite Type Features"
msgstr "Características del tipo de alojamiento"
#: web/templates/admin/campsite/type/feature/index.gohtml:48
#: web/templates/admin/campsite/type/feature/index.gohtml:57
msgid "No campsite type features added yet."
msgstr "No se ha añadido ninguna característica al tipo de alojamiento todavía."
@ -960,6 +962,10 @@ msgctxt "action"
msgid "Add Option"
msgstr "Añadir opción"
#: web/templates/admin/campsite/type/option/index.gohtml:35
msgid "Are you sure you wish to delete this option?"
msgstr "¿Estáis seguro de querer borrar esta opción?"
#: web/templates/admin/campsite/type/option/index.gohtml:56
msgid "No campsite type options added yet."
msgstr "No se ha añadido ninguna opció al tipo de alojamiento todavía."
@ -1538,14 +1544,14 @@ msgid "No booking found."
msgstr "No se ha encontrado ninguna reserva."
#: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357
#: pkg/campsite/types/feature.go:259 pkg/campsite/types/admin.go:483
#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:483
#: pkg/campsite/feature.go:269 pkg/season/admin.go:412
#: pkg/services/admin.go:316 pkg/surroundings/admin.go:340
msgid "Name can not be empty."
msgstr "No podéis dejar el nombre en blanco."
#: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358
#: pkg/campsite/types/feature.go:260 pkg/campsite/types/admin.go:484
#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:484
#: pkg/campsite/feature.go:270
msgid "Name must have at least one letter."
msgstr "El nombre tiene que tener como mínimo una letra."
@ -1647,7 +1653,7 @@ msgstr "El precio por noche tiene que ser un número decimal."
msgid "Price per night must be zero or greater."
msgstr "El precio por noche tiene que ser como mínimo cero."
#: pkg/campsite/types/feature.go:258 pkg/campsite/feature.go:268
#: pkg/campsite/types/feature.go:271 pkg/campsite/feature.go:268
#: pkg/services/admin.go:315
msgid "Selected icon is not valid."
msgstr "El icono escogido no es válido."
@ -1702,11 +1708,11 @@ msgstr "El número mínimo de noches tiene que ser entero."
msgid "Minimum number of nights must be one or greater."
msgstr "El número mínimo de noches no puede ser cero."
#: pkg/campsite/admin.go:274 pkg/booking/public.go:278
#: pkg/campsite/admin.go:275 pkg/booking/public.go:278
msgid "Selected campsite type is not valid."
msgstr "El tipo de alojamiento escogido no es válido."
#: pkg/campsite/admin.go:275
#: pkg/campsite/admin.go:276
msgid "Label can not be empty."
msgstr "No podéis dejar la etiqueta en blanco."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2024-01-26 21:20+0100\n"
"POT-Creation-Date: 2024-01-26 22:47+0100\n"
"PO-Revision-Date: 2023-12-20 10:13+0100\n"
"Last-Translator: Oriol Carbonell <info@oriolcarbonell.cat>\n"
"Language-Team: French <traduc@traduc.org>\n"
@ -582,7 +582,7 @@ msgstr "Modifier lentité de camping"
#: web/templates/admin/campsite/feature/form.gohtml:10
msgctxt "title"
msgid "New Campsite Feature"
msgstr "Nouvelle fonctionnalité de camping"
msgstr "Nouvelle caractéristique de camping"
#: web/templates/admin/campsite/feature/form.gohtml:17
#: web/templates/admin/campsite/feature/index.gohtml:6
@ -601,10 +601,11 @@ msgstr "Icône"
#: web/templates/admin/campsite/type/feature/index.gohtml:16
msgctxt "action"
msgid "Add Feature"
msgstr "Ajouter une fonctionnalité"
msgstr "Ajouter une caractéristique"
#: web/templates/admin/campsite/feature/index.gohtml:31
#: web/templates/admin/campsite/carousel/index.gohtml:31
#: web/templates/admin/campsite/type/feature/index.gohtml:32
#: web/templates/admin/campsite/type/carousel/index.gohtml:32
#: web/templates/admin/campsite/type/option/index.gohtml:31
#: web/templates/admin/services/index.gohtml:30
@ -618,12 +619,13 @@ msgid "Actions"
msgstr "Actions"
#: web/templates/admin/campsite/feature/index.gohtml:35
#: web/templates/admin/campsite/type/option/index.gohtml:35
msgid "Are you sure you wish to delete this option?"
msgstr "Êtes-vous sûr de vouloir supprimer cette option ?"
#: web/templates/admin/campsite/type/feature/index.gohtml:36
msgid "Are you sure you wish to delete this feature?"
msgstr "Êtes-vous sûr de vouloir supprimer cette caractéristique ?"
#: web/templates/admin/campsite/feature/index.gohtml:47
#: web/templates/admin/campsite/carousel/index.gohtml:49
#: web/templates/admin/campsite/type/feature/index.gohtml:48
#: web/templates/admin/campsite/type/carousel/index.gohtml:50
#: web/templates/admin/campsite/type/option/index.gohtml:47
#: web/templates/admin/services/index.gohtml:47
@ -639,7 +641,7 @@ msgstr "Supprimer"
#: web/templates/admin/campsite/feature/index.gohtml:56
msgid "No campsite features added yet."
msgstr "Aucune fonctionnalité de camping na encore été ajoutée."
msgstr "Aucune caractéristique de camping na encore été ajoutée."
#: web/templates/admin/campsite/carousel/form.gohtml:8
msgctxt "title"
@ -769,7 +771,7 @@ msgstr "Carrousel"
#: web/templates/admin/campsite/type/index.gohtml:45
msgctxt "action"
msgid "Edit Features"
msgstr "Edit Caractéristiques"
msgstr "Edit caractéristiques"
#: web/templates/admin/campsite/index.gohtml:39
#: web/templates/admin/campsite/type/index.gohtml:51
@ -799,13 +801,13 @@ msgstr "Aucun camping na encore été ajouté."
#: web/templates/admin/campsite/type/feature/form.gohtml:32
msgctxt "title"
msgid "Edit Campsite Type Feature"
msgstr "Modifier lentité de type de camping"
msgstr "Modifier la caractéristique de type de camping"
#: web/templates/admin/campsite/type/feature/form.gohtml:10
#: web/templates/admin/campsite/type/feature/form.gohtml:34
msgctxt "title"
msgid "New Campsite Type Feature"
msgstr "Nouvelle fonctionnalité de type de camping"
msgstr "Nouvelle caractéristique de type de camping"
#: web/templates/admin/campsite/type/feature/form.gohtml:17
#: web/templates/admin/campsite/type/feature/index.gohtml:11
@ -828,9 +830,9 @@ msgctxt "title"
msgid "Campsite Type Features"
msgstr "Caractéristiques du type demplacement de camping"
#: web/templates/admin/campsite/type/feature/index.gohtml:48
#: web/templates/admin/campsite/type/feature/index.gohtml:57
msgid "No campsite type features added yet."
msgstr "Aucune fonctionnalité de type camping na encore été ajoutée."
msgstr "Aucune caractéristique de type camping na encore été ajoutée."
#: web/templates/admin/campsite/type/carousel/form.gohtml:8
#: web/templates/admin/campsite/type/carousel/form.gohtml:32
@ -961,6 +963,10 @@ msgctxt "action"
msgid "Add Option"
msgstr "Ajouter une option"
#: web/templates/admin/campsite/type/option/index.gohtml:35
msgid "Are you sure you wish to delete this option?"
msgstr "Êtes-vous sûr de vouloir supprimer cette option ?"
#: web/templates/admin/campsite/type/option/index.gohtml:56
msgid "No campsite type options added yet."
msgstr "Aucune option de type de camping na encore été ajoutée."
@ -1539,14 +1545,14 @@ msgid "No booking found."
msgstr "Aucune réservation trouvée."
#: pkg/legal/admin.go:258 pkg/app/user.go:249 pkg/campsite/types/option.go:357
#: pkg/campsite/types/feature.go:259 pkg/campsite/types/admin.go:483
#: pkg/campsite/types/feature.go:272 pkg/campsite/types/admin.go:483
#: pkg/campsite/feature.go:269 pkg/season/admin.go:412
#: pkg/services/admin.go:316 pkg/surroundings/admin.go:340
msgid "Name can not be empty."
msgstr "Le nom ne peut pas être laissé vide."
#: pkg/legal/admin.go:259 pkg/campsite/types/option.go:358
#: pkg/campsite/types/feature.go:260 pkg/campsite/types/admin.go:484
#: pkg/campsite/types/feature.go:273 pkg/campsite/types/admin.go:484
#: pkg/campsite/feature.go:270
msgid "Name must have at least one letter."
msgstr "Le nom doit comporter au moins une lettre."
@ -1648,7 +1654,7 @@ msgstr "Le prix par nuit doit être un nombre décimal."
msgid "Price per night must be zero or greater."
msgstr "Le prix par nuit doit être égal ou supérieur."
#: pkg/campsite/types/feature.go:258 pkg/campsite/feature.go:268
#: pkg/campsite/types/feature.go:271 pkg/campsite/feature.go:268
#: pkg/services/admin.go:315
msgid "Selected icon is not valid."
msgstr "Licône sélectionnée nest pas valide."
@ -1703,11 +1709,11 @@ msgstr "Le nombre minimum de nuits doit être un entier."
msgid "Minimum number of nights must be one or greater."
msgstr "Le nombre minimum de nuits doit être supérieur ou égal à une nuit."
#: pkg/campsite/admin.go:274 pkg/booking/public.go:278
#: pkg/campsite/admin.go:275 pkg/booking/public.go:278
msgid "Selected campsite type is not valid."
msgstr "Le type demplacement sélectionné nest pas valide."
#: pkg/campsite/admin.go:275
#: pkg/campsite/admin.go:276
msgid "Label can not be empty."
msgstr "L'étiquette ne peut pas être vide."
@ -2093,7 +2099,7 @@ msgstr "%s doit être tout au plus %d."
#~ msgctxt "title"
#~ msgid "Translate Campsite Type Feature to %s"
#~ msgstr "Traduire Caractéristique de type de camping en %s"
#~ msgstr "Traduire caractéristique de type de camping en %s"
#~ msgctxt "title"
#~ msgid "Translate Campsite Type Carousel Slide to %s"

View File

@ -0,0 +1,7 @@
-- Revert camper:remove_campsite_type_feature from pg
begin;
drop function if exists camper.remove_campsite_type_feature(integer);
commit;

View File

@ -196,3 +196,4 @@ order_campsite_features [roles schema_camper campsite_feature] 2024-01-26T19:09:
campsite_feature_i18n [roles schema_camper campsite_feature language] 2024-01-26T19:17:09Z jordi fita mas <jordi@tandem.blog> # Add relation for campsite features translation
translate_campsite_feature [roles schema_camper campsite_feature_i18n] 2024-01-26T19:26:21Z jordi fita mas <jordi@tandem.blog> # Add function to translate campsite features
remove_campsite_feature [roles schema_camper campsite_feature campsite_feature_i18n] 2024-01-26T19:34:52Z jordi fita mas <jordi@tandem.blog> # Add function to remove campsite features
remove_campsite_type_feature [roles schema_camper campsite_type_feature campsite_type_feature_i18n] 2024-01-26T21:35:05Z jordi fita mas <jordi@tandem.blog> # Add function to remove campsite type features

View File

@ -0,0 +1,103 @@
-- Test remove_campsite_type_feature
set client_min_messages to warning;
create extension if not exists pgtap;
reset client_min_messages;
begin;
select plan(13);
set search_path to camper, public;
select has_function('camper', 'remove_campsite_type_feature', array['integer']);
select function_lang_is('camper', 'remove_campsite_type_feature', array['integer'], 'sql');
select function_returns('camper', 'remove_campsite_type_feature', array['integer'], 'void');
select isnt_definer('camper', 'remove_campsite_type_feature', array['integer']);
select volatility_is('camper', 'remove_campsite_type_feature', array['integer'], 'volatile');
select function_privs_are('camper', 'remove_campsite_type_feature', array['integer'], 'guest', array[]::text[]);
select function_privs_are('camper', 'remove_campsite_type_feature', array['integer'], 'employee', array[]::text[]);
select function_privs_are('camper', 'remove_campsite_type_feature', array['integer'], 'admin', array['EXECUTE']);
select function_privs_are('camper', 'remove_campsite_type_feature', array['integer'], 'authenticator', array[]::text[]);
set client_min_messages to warning;
truncate campsite_type_feature_i18n cascade;
truncate campsite_type_feature cascade;
truncate campsite_type cascade;
truncate media cascade;
truncate media_content cascade;
truncate company cascade;
reset client_min_messages;
insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, tourist_tax, country_code, currency_code, default_lang_tag)
values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 60, 'ES', 'EUR', 'ca')
;
insert into media_content (media_type, bytes)
values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};')
, ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ff00ff","a"};')
, ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffff00","a"};')
, ('text/plain', 'hello, world!')
, ('image/svg+xml', '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>')
;
insert into media (media_id, company_id, original_filename, content_hash)
values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};'))
, (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};'))
;
insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active)
values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '<p>A</p>', 5, false, true)
, (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '<p>B</p>', 4, true, false)
;
insert into campsite_type_feature (campsite_type_feature_id, campsite_type_id, icon_name, name)
values (12, 10, 'wifi', 'Feature 1')
, (13, 10, 'baby', 'Feature 2')
, (14, 11, 'castle', 'Feature 3')
, (15, 11, 'ecofriendly', 'Feature 4')
;
insert into campsite_type_feature_i18n (campsite_type_feature_id, lang_tag, name)
values (12, 'ca', 'Característica 1')
, (12, 'es', 'ES 1')
, (13, 'ca', 'Característica 2')
, (13, 'es', 'ES 2')
, (14, 'ca', 'Característica 3')
, (14, 'es', 'ES 3')
, (15, 'ca', 'Característica 4')
, (15, 'es', 'ES 4')
;
select lives_ok(
$$ select remove_campsite_type_feature(12) $$,
'Should be able to delete a feature from the first campsite type'
);
select lives_ok(
$$ select remove_campsite_type_feature(15) $$,
'Should be able to delete a feature from the second campsite type'
);
select bag_eq(
$$ select campsite_type_feature_id, name from campsite_type_feature $$,
$$ values (13, 'Feature 2')
, (14, 'Feature 3')
$$,
'Should have removed the features'
);
select bag_eq(
$$ select campsite_type_feature_id, lang_tag, name from campsite_type_feature_i18n $$,
$$ values (13, 'ca', 'Característica 2')
, (13, 'es', 'ES 2')
, (14, 'ca', 'Característica 3')
, (14, 'es', 'ES 3')
$$,
'Should have removed the features translations'
);
select *
from finish();
rollback;

View File

@ -0,0 +1,7 @@
-- Verify camper:remove_campsite_type_feature on pg
begin;
select has_function_privilege('camper.remove_campsite_type_feature(integer)', 'execute');
rollback;

View File

@ -32,7 +32,7 @@
</tr>
</thead>
<tbody>
{{ $confirm := (gettext "Are you sure you wish to delete this option?")}}
{{ $confirm := (gettext "Are you sure you wish to delete this feature?")}}
{{ range .Features -}}
<tr>
<td>

View File

@ -29,9 +29,11 @@
<tr>
<th scope="col" style="width: 1.5em"></th>
<th scope="col">{{( pgettext "Name" "header" )}}</th>
<th scope="col">{{( pgettext "Actions" "header" )}}</th>
</tr>
</thead>
<tbody>
{{ $confirm := (gettext "Are you sure you wish to delete this feature?")}}
{{ range .Features -}}
<tr>
<td>
@ -39,6 +41,13 @@
<input type="hidden" name="feature_id" value="{{ .ID }}">
</td>
<td class="icon_{{ .Icon }}"><a href="{{ .URL }}">{{ .Name }}</a></td>
<td>
<button data-hx-delete="{{ .URL }}"
data-hx-confirm="{{ $confirm }}"
data-hx-headers='{ {{ CSRFHeader }} }'>
{{( pgettext "Delete" "action" )}}
</button>
</td>
</tr>
{{- end }}
</tbody>