Add the sample campsite types to the demo file

Since campsite types need a media, i have to insert also images to the
media relation.  The best would be to use PostgreSQL’s
pg_read_binary_file to read the media content from actual files when
inserting the new rows, but the files need to be within the database
cluster directory, or have to use an absolute path when running as a
superuser to read from files outside the cluster directory, which means
that it would depend on the path where i leave the files, that is
different in development that in staging.

To avoid that problem i can simply insert the rows using their base64
strings, with PostgreSQL’s decode.  The images are kind of small, but
i was worried that each change in demo.sql would duplicate that data in
git, even if the change is not related to the images, because git stores
the whole file; even if small, soon everything adds up.

I do not care if the _final_ demo.sql is big, as this file is packaged
in a different deb and is only installed in staging, so i’ve chosen to
use m4 to build a single “amalgamated” SQL file from the base .sql
file and the individual image files converted to base64 strings.  That
way, each image is individually managed by git and the base .sql file
does not balloon up for each little change.

Changed m4’s quotes to [[ ]] because the default ` ' was interfering
with Intellij’s syntax highlighting.
This commit is contained in:
jordi fita mas 2023-09-10 03:57:46 +02:00
parent da127124a1
commit 151f7fc84e
10 changed files with 84 additions and 40 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.idea/
/locale/
/po/*.pot
/demo.sql

View File

@ -5,6 +5,9 @@ POT_FILE = po/$(DEFAULT_DOMAIN).pot
LINGUAS = ca es
MO_FILES = $(patsubst %,locale/%/LC_MESSAGES/$(DEFAULT_DOMAIN).mo,$(LINGUAS))
XGETTEXTFLAGS = --no-wrap --from-code=UTF-8 --package-name=camper --msgid-bugs-address=jordi@tandem.blog
DEMO_SQL = demo.sql
all: locales $(DEMO_SQL)
locales: $(MO_FILES)
@ -23,7 +26,11 @@ test-deploy:
sqitch deploy --db-name $(PGDATABASE)
pg_prove test/*
$(DEMO_SQL): demo/demo.sql demo/plots.avif demo/safari_tents.avif demo/bungalows.avif demo/wooden_lodges.avif
m4 --prefix-builtins $< > $@
clean:
$(RM) $(DEMO_SQL)
$(RM) $(MO_FILES)
$(RM) $(POT_FILE)
$(RM) debian/debhelper-build-stamp

1
debian/control vendored
View File

@ -4,6 +4,7 @@ Priority: optional
Maintainer: jordi fita mas <jordi@tandem.blog>
Build-Depends:
debhelper-compat (= 13),
m4,
dh-golang,
gettext,
golang-any,

BIN
demo/bungalows.avif Normal file

Binary file not shown.

View File

@ -1,3 +1,4 @@
-- m4_changequote(`[[', `]]')
begin;
set search_path to camper, auth, public;
@ -22,4 +23,20 @@ values (52, 42, 'employee')
, (52, 43, 'admin')
;
alter sequence media_media_id_seq restart with 62;
insert into media (company_id, original_filename, media_type, content)
values (52, 'plots.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/plots.avif]])', 'base64'))
, (52, 'safari_tents.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/safari_tents.avif]])', 'base64'))
, (52, 'bungalows.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/bungalows.avif]])', 'base64'))
, (52, 'wooden_lodges.avif', 'image/avif', decode('m4_esyscmd([[base64 -w0 demo/wooden_lodges.avif]])', 'base64'))
;
alter sequence campsite_type_campsite_type_id_seq restart with 72;
insert into campsite_type (company_id, name, media_id, description)
values (52, 'Parceŀles', 62, '')
, (52, 'Safari Tents', 63, '')
, (52, 'Bungalows', 64, '')
, (52, 'Cabanes de fusta', 65, '')
;
commit;

BIN
demo/plots.avif Normal file

Binary file not shown.

BIN
demo/safari_tents.avif Normal file

Binary file not shown.

BIN
demo/wooden_lodges.avif Normal file

Binary file not shown.

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-09-05 04:34+0200\n"
"POT-Creation-Date: 2023-09-10 03:42+0200\n"
"PO-Revision-Date: 2023-07-22 23:45+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n"
@ -23,32 +23,32 @@ msgctxt "title"
msgid "Home"
msgstr "Inici"
#: web/templates/public/home.gohtml:16
#: web/templates/public/home.gohtml:17
msgid "The pleasure of camping in the middle of nature…"
msgstr "El plaer dacampar en plena natura…"
#: web/templates/public/home.gohtml:17
#: web/templates/public/home.gohtml:18
msgctxt "link"
msgid "Booking"
msgstr "Reserva"
#: web/templates/public/home.gohtml:30
#: web/templates/public/home.gohtml:31
msgid "Our services"
msgstr "Els nostres serveis"
#: web/templates/public/home.gohtml:33
#: web/templates/public/home.gohtml:34
msgid "Environment"
msgstr "Entorn"
#: web/templates/public/home.gohtml:48 web/templates/public/home.gohtml:52
#: web/templates/public/home.gohtml:56 web/templates/public/home.gohtml:60
#: web/templates/public/home.gohtml:64 web/templates/public/home.gohtml:68
#: web/templates/public/home.gohtml:72 web/templates/public/home.gohtml:76
#: web/templates/public/home.gohtml:80
#: web/templates/public/home.gohtml:49 web/templates/public/home.gohtml:53
#: web/templates/public/home.gohtml:57 web/templates/public/home.gohtml:61
#: web/templates/public/home.gohtml:65 web/templates/public/home.gohtml:69
#: web/templates/public/home.gohtml:73 web/templates/public/home.gohtml:77
#: web/templates/public/home.gohtml:81
msgid "Legend"
msgstr "Llegenda"
#: web/templates/public/home.gohtml:84
#: web/templates/public/home.gohtml:85
msgid "Come and enjoy!"
msgstr "Vine a gaudir!"
@ -98,14 +98,14 @@ msgid "Label"
msgstr "Etiqueta"
#: web/templates/admin/campsite/form.gohtml:71
#: web/templates/admin/campsite/type/form.gohtml:64
#: web/templates/admin/campsite/type/form.gohtml:77
#: web/templates/admin/season/form.gohtml:65
msgctxt "action"
msgid "Update"
msgstr "Actualitza"
#: web/templates/admin/campsite/form.gohtml:73
#: web/templates/admin/campsite/type/form.gohtml:66
#: web/templates/admin/campsite/type/form.gohtml:79
#: web/templates/admin/season/form.gohtml:67
msgctxt "action"
msgid "Add"
@ -150,31 +150,36 @@ msgid "No campsites added yet."
msgstr "No sha afegit cap allotjament encara."
#: web/templates/admin/campsite/type/form.gohtml:8
#: web/templates/admin/campsite/type/form.gohtml:26
#: web/templates/admin/campsite/type/form.gohtml:27
msgctxt "title"
msgid "Edit Campsite Type"
msgstr "Edició del tipus dallotjament"
#: web/templates/admin/campsite/type/form.gohtml:10
#: web/templates/admin/campsite/type/form.gohtml:28
#: web/templates/admin/campsite/type/form.gohtml:29
msgctxt "title"
msgid "New Campsite Type"
msgstr "Nou tipus dallotjament"
#: web/templates/admin/campsite/type/form.gohtml:38
#: web/templates/admin/campsite/type/form.gohtml:39
#: web/templates/admin/campsite/type/index.gohtml:19
msgctxt "campsite type"
msgid "Active"
msgstr "Actiu"
#: web/templates/admin/campsite/type/form.gohtml:47
#: web/templates/admin/campsite/type/form.gohtml:48
#: web/templates/admin/season/form.gohtml:47
#: web/templates/admin/profile.gohtml:26
msgctxt "input"
msgid "Name"
msgstr "Nom"
#: web/templates/admin/campsite/type/form.gohtml:55
#: web/templates/admin/campsite/type/form.gohtml:59
msgctxt "input"
msgid "Cover image"
msgstr "Imatge de portada"
#: web/templates/admin/campsite/type/form.gohtml:68
msgctxt "input"
msgid "Description"
msgstr "Descripció"
@ -413,7 +418,7 @@ msgctxt "language option"
msgid "Automatic"
msgstr "Automàtic"
#: pkg/app/user.go:249 pkg/campsite/types/admin.go:197 pkg/season/admin.go:203
#: pkg/app/user.go:249 pkg/campsite/types/admin.go:227 pkg/season/admin.go:203
msgid "Name can not be empty."
msgstr "No podeu deixar el nom en blanc."
@ -425,7 +430,7 @@ msgstr "La confirmació no es correspon amb la contrasenya."
msgid "Selected language is not valid."
msgstr "Lidioma escollit no és vàlid."
#: pkg/app/user.go:253
#: pkg/app/user.go:253 pkg/campsite/types/admin.go:229
msgid "File must be a valid PNG or JPEG image."
msgstr "El fitxer has de ser una imatge PNG o JPEG vàlida."
@ -433,6 +438,10 @@ msgstr "El fitxer has de ser una imatge PNG o JPEG vàlida."
msgid "Access forbidden"
msgstr "Accés prohibit"
#: pkg/campsite/types/admin.go:231
msgid "Cover image can not be empty."
msgstr "No podeu deixar la imatge de portada en blanc."
#: pkg/campsite/admin.go:218
msgid "Selected campsite type is not valid."
msgstr "El tipus dallotjament escollit no és vàlid."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-09-05 04:34+0200\n"
"POT-Creation-Date: 2023-09-10 03:42+0200\n"
"PO-Revision-Date: 2023-07-22 23:46+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n"
@ -23,32 +23,32 @@ msgctxt "title"
msgid "Home"
msgstr "Inicio"
#: web/templates/public/home.gohtml:16
#: web/templates/public/home.gohtml:17
msgid "The pleasure of camping in the middle of nature…"
msgstr "El placer de acampar en plena naturaleza…"
#: web/templates/public/home.gohtml:17
#: web/templates/public/home.gohtml:18
msgctxt "link"
msgid "Booking"
msgstr "Reservar"
#: web/templates/public/home.gohtml:30
#: web/templates/public/home.gohtml:31
msgid "Our services"
msgstr "Nuestros servicios"
#: web/templates/public/home.gohtml:33
#: web/templates/public/home.gohtml:34
msgid "Environment"
msgstr "Entorno"
#: web/templates/public/home.gohtml:48 web/templates/public/home.gohtml:52
#: web/templates/public/home.gohtml:56 web/templates/public/home.gohtml:60
#: web/templates/public/home.gohtml:64 web/templates/public/home.gohtml:68
#: web/templates/public/home.gohtml:72 web/templates/public/home.gohtml:76
#: web/templates/public/home.gohtml:80
#: web/templates/public/home.gohtml:49 web/templates/public/home.gohtml:53
#: web/templates/public/home.gohtml:57 web/templates/public/home.gohtml:61
#: web/templates/public/home.gohtml:65 web/templates/public/home.gohtml:69
#: web/templates/public/home.gohtml:73 web/templates/public/home.gohtml:77
#: web/templates/public/home.gohtml:81
msgid "Legend"
msgstr "Leyenda"
#: web/templates/public/home.gohtml:84
#: web/templates/public/home.gohtml:85
msgid "Come and enjoy!"
msgstr "¡Ven a disfrutar!"
@ -98,14 +98,14 @@ msgid "Label"
msgstr "Etiqueta"
#: web/templates/admin/campsite/form.gohtml:71
#: web/templates/admin/campsite/type/form.gohtml:64
#: web/templates/admin/campsite/type/form.gohtml:77
#: web/templates/admin/season/form.gohtml:65
msgctxt "action"
msgid "Update"
msgstr "Actualizar"
#: web/templates/admin/campsite/form.gohtml:73
#: web/templates/admin/campsite/type/form.gohtml:66
#: web/templates/admin/campsite/type/form.gohtml:79
#: web/templates/admin/season/form.gohtml:67
msgctxt "action"
msgid "Add"
@ -150,31 +150,36 @@ msgid "No campsites added yet."
msgstr "No se ha añadido ningún alojamiento todavía."
#: web/templates/admin/campsite/type/form.gohtml:8
#: web/templates/admin/campsite/type/form.gohtml:26
#: web/templates/admin/campsite/type/form.gohtml:27
msgctxt "title"
msgid "Edit Campsite Type"
msgstr "Edición del tipo de alojamientos"
#: web/templates/admin/campsite/type/form.gohtml:10
#: web/templates/admin/campsite/type/form.gohtml:28
#: web/templates/admin/campsite/type/form.gohtml:29
msgctxt "title"
msgid "New Campsite Type"
msgstr "Nuevo tipo de alojamiento"
#: web/templates/admin/campsite/type/form.gohtml:38
#: web/templates/admin/campsite/type/form.gohtml:39
#: web/templates/admin/campsite/type/index.gohtml:19
msgctxt "campsite type"
msgid "Active"
msgstr "Activo"
#: web/templates/admin/campsite/type/form.gohtml:47
#: web/templates/admin/campsite/type/form.gohtml:48
#: web/templates/admin/season/form.gohtml:47
#: web/templates/admin/profile.gohtml:26
msgctxt "input"
msgid "Name"
msgstr "Nombre"
#: web/templates/admin/campsite/type/form.gohtml:55
#: web/templates/admin/campsite/type/form.gohtml:59
msgctxt "input"
msgid "Cover image"
msgstr "Imagen de portada"
#: web/templates/admin/campsite/type/form.gohtml:68
msgctxt "input"
msgid "Description"
msgstr "Descripción"
@ -413,7 +418,7 @@ msgctxt "language option"
msgid "Automatic"
msgstr "Automático"
#: pkg/app/user.go:249 pkg/campsite/types/admin.go:197 pkg/season/admin.go:203
#: pkg/app/user.go:249 pkg/campsite/types/admin.go:227 pkg/season/admin.go:203
msgid "Name can not be empty."
msgstr "No podéis dejar el nombre en blanco."
@ -425,7 +430,7 @@ msgstr "La confirmación no se corresponde con la contraseña."
msgid "Selected language is not valid."
msgstr "El idioma escogido no es válido."
#: pkg/app/user.go:253
#: pkg/app/user.go:253 pkg/campsite/types/admin.go:229
msgid "File must be a valid PNG or JPEG image."
msgstr "El archivo tiene que ser una imagen PNG o JPEG válida."
@ -433,6 +438,10 @@ msgstr "El archivo tiene que ser una imagen PNG o JPEG válida."
msgid "Access forbidden"
msgstr "Acceso prohibido"
#: pkg/campsite/types/admin.go:231
msgid "Cover image can not be empty."
msgstr "No podéis dejar la imagen de portada en blanco."
#: pkg/campsite/admin.go:218
msgid "Selected campsite type is not valid."
msgstr "El tipo de alojamiento escogido no es válido."