Commit Graph

211 Commits

Author SHA1 Message Date
jordi fita mas 15dde3f491 Add ready_payment function and use their slug as URL
Now that the payments have slug, i can use them in the URL to show the
actual data of a payment, and kickstart the payment process with Redsys.
2024-02-12 18:06:17 +01:00
jordi fita mas 148d9075da Refactor base URL for the payment success, failure, and notification 2024-02-12 05:21:30 +01:00
jordi fita mas e4636592c5 Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance.  There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.

To compute the total for that payment i had to do the same as was doing
until now for the cart.  To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.

Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values.  Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation.  It still allows payment without customer, but at least there
are no NULL values.

Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.

To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug.  A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 05:21:00 +01:00
jordi fita mas d22fe39c80 Add a small note to the booking form when there is overflow
Customer wants to warn customers that plots are not guaranteed to be
next to each other.
2024-02-11 22:06:00 +01:00
jordi fita mas ea997a4154 Allow campsite type option to be just per unit, not per unit per night
Customer told us that there are some options, such as towels, that have
a fixed price for the whole stay, not a per night price.  Thus, had to
add a boolean to know whether to use sum or max when computing the
cart’s total for each option.
2024-02-11 21:45:00 +01:00
jordi fita mas 92dba96b29 Add campsite_type_pet_cost relation to hold price of dogs in campsites
It is a separate relation, instead of having a field in campsite_type,
because not all campsite types allow dogs.  I could have added a new
field to campsite_type, but then its values it would be meaningless for
campsites that do not allow dogs, and a nullable field is not a valid
solution because NULL means “unknown”, but we **do** know the price —
none.

A separate relation encodes the same information without ambiguities nor
null values, and, in fact, removed the dogs_allowed field from
campsite_type to prevent erroneous status, such as a campsite type that
allows dogs without having a cost — even if the cost is zero, it has to
be added to the new relation.
2024-02-10 06:18:30 +01:00
jordi fita mas e5023a2a41 Handle the booking cart entirely with HTMx
Besides the dynamic final cart, that was already handled by HTMx, i had
to check the maximum number of guests, whether the accommodation allows
“overflow”, whether dogs are allowed, and that the booking dates were
within the campground’s opening and closing dates.

I could do all of this with AlpineJS, but then i would have to add the
same validation to the backend, prior to accept the payment.  Would not
make more sense to have them in a single place, namely the backend? With
HTMx i can do that.

However, i now have to create the form “piecemeal”, because i may not
have the whole information when the visitor arrives to the booking page,
and i still had the same problem as in commit d2858302efa—parsing the
whole form as is would leave guests and options field empty, rather than
at their minimum values.

One of the fieldsets in that booking form are the arrival and departure
dates, that are the sames we use in the campsite type’s page to
“preselect” these values.  Since now are in a separate struct, i can
reuse the same type and validation logic for both pages, making my
JavaScript code useless, but requiring HTMx.  I think this is a good
tradeoff, in fact.
2024-02-10 03:49:44 +01:00
jordi fita mas cc26eddc7c Remove MethodPost from two URI handlers in payment that only accept GET 2024-02-04 06:37:56 +01:00
jordi fita mas 2c36e45663 Compute and show the “cart” for the booking form
I have to ask number and age ranges of hosts of guests for all campsite
types, not only those that have price options for adults, children, etc.
because i must compute the tourist tax for adults.  These numbers will
be used to generate de rows for guests when actually creating the
booking, which is not done already.

To satisfy the campsite types that do have a price per guest, not only
per night, i had to add the prices for each range in the
campsite_type_cost relation.  If a campsite type does not have price
per person, then that should be zero; the website then does not display
the price.

The minimal price for any campsite type is one adult for one night,
thus to compute the price i need at least the campsite type, the dates,
and the number of adults, that has a minimum of one.  I changed the
order of the form to ask for these values first, so i can compute the
initial price as soon as possible.  To help further, i show the
<fieldset>s progressively when visitors select options.
2024-02-04 06:37:25 +01:00
jordi fita mas b6044a7d4a Advance min dates of departure and arrival one day
Apparently, expecting people to book at least one day in advance is
being “too optimistic”.
2024-02-02 02:59:41 +01:00
jordi fita mas 4adad7fa7d Replace min_nights from campsite_type_costs to range in campsite_type
Customer told us that the minimum number of nights is per campsite type,
not per season.  And he wants this, along with the maximum number of
nights, in order to limit the range of departure dates that guests can
choose when booking.
2024-01-31 23:06:45 +01:00
jordi fita mas 4f04d973c2 Dynamically set min and max to arrival and departure date inputs
The departure must be at list one day after the arrival, but no longer
than seven, due to campground’s policy.
2024-01-31 20:00:38 +01:00
jordi fita mas 51540151ff Refactor ISO date, and datestamp format in constant 2024-01-31 19:58:46 +01:00
jordi fita mas ca7d343810 Do not freak out just because the is no blooding slogan 2024-01-30 12:24:49 +01:00
jordi fita mas 036c3bc9ce Do not panic is there is no home slogan yet 2024-01-29 19:58:05 +01:00
jordi fita mas 23be6ff26c Add ask_zone_preferences and overflow_allowed to campsite_type
The “overflow” is for when people want to book plots for more guests
than is permitted, which the system would need to add a new plot to the
“shopping cart”, as it were; not implemented yet.

The ask zone preferences is to whether show the corresponding input on
the booking form, that it was done implicitly when the campsite type had
options, because up until now it was only for plots, but it is no longer
the case, thus i need to know when to show it; now it is explicit.
2024-01-29 03:38:11 +01:00
jordi fita mas a31f5038db Do not include inactive campsite types in booking form 2024-01-29 03:03:20 +01:00
jordi fita mas 2ec363ca63 Tag database with v2 2024-01-29 02:52:52 +01:00
jordi fita mas eeaa3b415e Add amenities section and public page
This is more or less the same as the campsites, as public information
goes, but for buildings and other amenities that the camping provides
that are not campsites.
2024-01-27 22:51:41 +01:00
jordi fita mas 629ef1a262 Add function to delete campsite type features 2024-01-26 22:54:19 +01:00
jordi fita mas bd124581cc Handle null strings in I18nInput.FillArray
Until now i always had the translations be empty strings if some columns
did not have the full translation, but this is going too far on the
non-NULL policy: surely they have a translations, but we do not know it
yet; this is the exact type of situations NULL values are for.

Besides the philosophical distinction, having empty strings instead of
NULLs is less practical, because i no longer can user coalesce() to
retrieve the default language text in case the translation for that
particular field is not available, even if the row for a locale exists.

In time i will change all _i18n relations, but for now only these from
campsite follow the “new policy”.
2024-01-26 22:31:11 +01:00
jordi fita mas c284230436 Add public pages for each individual accommodation
A small page with a brief description, carousel, and feature list of
each individual accommodation.

Most of the relations and functions for carousel and features are like
the ones for campsite types, but i had to use the accommodation’s label
to find them, because they do not have slugs; i did not even though
these would be public, and they already have a label, although not
unique for all companies, like UUID slugs are.
2024-01-26 22:27:54 +01:00
jordi fita mas 186a5fdb38 Refactor the processing of the campsite form in a common function 2024-01-25 20:57:07 +01:00
jordi fita mas ad161f57b2 Add database functions for AddCampsite and EditCampsite 2024-01-25 20:48:39 +01:00
jordi fita mas f514f9132e Add ad management for surroundings
They only want a single ad (for now, i guess).
2024-01-23 14:53:15 +01:00
jordi fita mas e34f253620 Make the slogan user-editable and translatable
Because God forbid we have any performance; everything —**everything**—
must be user editable.
2024-01-23 11:52:39 +01:00
jordi fita mas 2db322a55c Add missing MethodPut to location/admin.gohtml’s MethodNotAllowed 2024-01-23 11:31:34 +01:00
jordi fita mas d96f62a0a3 Fix translation of carousel slides when changing media ID
I was trying to translate the slides that i just deleted before.
2024-01-22 21:03:00 +01:00
jordi fita mas 17aaf045bb Replace raw call to remove_campsite_type_carousel_slide with Go func 2024-01-22 20:56:48 +01:00
jordi fita mas bc790762d6 Add remove_campsite_type_option function 2024-01-22 20:54:03 +01:00
jordi fita mas 5cc5fca6b5 Remove unnecessary receiver from campsite.AdminHandler.deleteSlide 2024-01-22 20:53:01 +01:00
jordi fita mas 1f2ab494dd Add check_in and check_out fields to campsite_type
Apparently, each campsite type could have different check-in and
check-out times, thus i need them in the database.

I thought about using an integer or a datetime field, but customer seems
to want a text field to maybe add “before” and “after” there as well.
Translatable text it is.
2024-01-22 20:19:19 +01:00
jordi fita mas 4138eda5cb Add Error method to I18nInput
Otherwise, we can not show the error message to the user, although it
assumes only the default language has error message, which is the case
for now, but….
2024-01-22 20:15:26 +01:00
jordi fita mas 77cbb3c212 Fix SQL to get list of all accommodation options for booking form
I was using the wrong fields to join with i18n, and had the parameters
to coalesce function call reversed.
2024-01-22 03:24:53 +01:00
jordi fita mas cf527ce070 Add the application’s version to the footer
This is mostly because it is required for the “Digital Kit”, but it also
works in our favor because now i can version the URL to the static
resources.

Go 1.18 adds the info from git if the package is build from a git
repository, but this is not the case in OBS, so i instead relay on a
constant for the version number.  This constant is “updated” by Debian’s
rules, mostly due to the discussion in [0].

[0]: https://github.com/golang/go/issues/22706
2024-01-21 20:50:16 +01:00
jordi fita mas d945f55096 Add “part” of the bookings’ management
“Part”, because it is not possible to add or actually manage any
booking yet, but it has the export feature that we need to validate the
project.
2024-01-18 21:05:30 +01:00
jordi fita mas 1b7e7ed2c6 User and login attempt pages only accept GET 2024-01-18 19:34:58 +01:00
jordi fita mas a11ca5b470 Add page to see login attempts for a company 2024-01-17 20:28:42 +01:00
jordi fita mas f7fdc594d5 Add admin page to list the users
There is no way, for now, to add, edit or remove users, because
currently we only need to list users.

I can not give admins access to the user table, for security
permissions, so i had to create a new view.  I could name it also ‘user’
in ‘camper’ scheme, but then i was afraid i would have problems with
unit tests and their search_path, so instead i called it
‘company_user_profile’, which is like ‘user_profile’ but for all users
in ‘company_user’.

I created a new Go package for it, rather than add the admin handler in
‘auth’, because ‘template’ depends on ‘auth’, and rendering from ‘auth’
would cause a dependency loop.

I needed to have the roles in gettext to translate them, but there is
no obvious place where to put the call to PgettextNoop.  For now, there
are in ‘NewAdminHandler’ because it is called once in the application’s
lifetime and they actually do not matter much.
2024-01-17 19:42:47 +01:00
jordi fita mas b1e3f5017f Add home’s cover carousel
This is a separate carousel from the one displayed at the bottom with
location info; it is, i suppose, a carousel for the hero image.

For the database, it works exactly as the home carousel, but on the
front had to use AlpineJS instead of Slick because it needs to show a
text popping up from the bottom when the slide is show, something i do
not know how to do in Slick.

It now makes no sense to have the carousel inside the “nature” section,
because the heading is no longer in there, and moved it out into a new
“hero” div.

Since i now have two carousels in home, i had to add additional
attributes to carousel.AdminHandler to know which URL to point to when
POSTing, PUTting, or redirecting.
2024-01-16 21:05:52 +01:00
jordi fita mas 36213c75de Add a Go function for delete_service SQL function 2024-01-16 18:12:38 +01:00
jordi fita mas f24f69bbbd Add missing error handling when collecting service entries in admin 2024-01-16 01:26:35 +01:00
jordi fita mas c3c349fadf Remove a redundant handling of service’s form while editing 2024-01-16 01:26:35 +01:00
jordi fita mas a0f9c10193 Add management of surroundings’ highlights (points of interest)
Customer does not want the new “masonry-like” design of the surroundings
page, and wants the same style they already had: a regular list with
text and photo, alternating the photo’s side.

And, of course, they want to be able to add and edit them themselves. It
is like another carousel, but with an additional rich-text description.

The photos that we had in that page are no longer of use.
2024-01-16 01:26:35 +01:00
jordi fita mas 8205bec34d Remove now-unused locales field from admin handlers 2024-01-16 01:26:35 +01:00
jordi fita mas 50bcbf012f Allow updating images in CKEditor-“powered” textarea
Had to create a custom build of CKEditor with the following plugins
added-in:

  * Autoformat
  * Block quote
  * Bold
  * General HTML Support
  * Heading
  * Image
  * Image caption
  * Image resize
  * Image style
  * Image toolbar
  * Image upload
  * Indent
  * Italic
  * Link
  * Link image
  * List
  * Media embed
  * Simple upload adapter
  * Source editing
  * Table
  * Table toolbar
  * Text transformation

The important bit is the “Simple uploader adapter”, that i modified to
upload the file as `media` instead of the default `upload` (i.e.,
modified ckeditor.js to replace "upload" with "media").

I also had to add the CSRF header somewhere in the HTML document for
JavaScript to be able to retrieve it and pass it to the uploader
adapter, or i would have to disable CSRF validation in that form, which
i did not like at all.
2024-01-16 01:26:35 +01:00
jordi fita mas 0ed6c1b121 Added note about dogs to the campsite type page
The pets icon is just the same as the notpet but without the diagonal
bar.

The price is hardcoded in the query for now, as there is no field
in the campsite type.
2024-01-15 02:07:32 +01:00
jordi fita mas 0beb0bb315 Add VAT and tourist tax information
Since i need the number of decimals to format the price in the template,
i added them to the company, and used them in the call to price_parse().
2024-01-15 01:45:58 +01:00
jordi fita mas dabd197f02 Add additional information field to campsite types
This is actually just to have a fourth column in order to “balance”
lists for types that have a long descriptions.
2024-01-15 00:28:34 +01:00
jordi fita mas 79df1736f2 Add tourist tax to company
Not used anywhere yet, but i will need it when computing the booking’s
total.
2024-01-14 02:09:17 +01:00
jordi fita mas 976b2bcbcf Add position to services to be able to manually sort by admins 2024-01-13 01:15:24 +01:00
jordi fita mas 4e126237a0 Replace L10nInput with I18nInput in service
locale.Translation and form.L10nInput are no longer used.

The translation type in Postgres is now also useless, and i believe it
was never used, but i keep it because I already have a tag and i can not
just remove it, meaning that dropping it is more trouble that worth it.
2024-01-12 21:06:12 +01:00
jordi fita mas 58c3b607a1 Replace L10nInput with I18nInput in season 2024-01-12 20:26:45 +01:00
jordi fita mas 734178657d Do not translate legal to the default language
It is already in the “default relations”, and there is no need to repeat
them.
2024-01-12 19:57:11 +01:00
jordi fita mas 2b702d6632 Add golang template to initialize x-data for translation in admin
Had to add the DefaultLang to legal and location forms in order to use
the same template for all.
2024-01-12 19:51:12 +01:00
jordi fita mas b6cd2f7693 Use I18nInput instead of L10nInput to translate carousels 2024-01-12 19:33:44 +01:00
jordi fita mas 3d0f7b0dc1 Handle empty array_agg in I18nInput.FillArray
array_agg returns [null] instead of [] when it can not find any rows,
thus the range enters the loop, but it fails to convert the null to
string.
2024-01-12 19:28:13 +01:00
jordi fita mas f28664acce Replace use of L10NInput with I18nInput for campsite 2024-01-10 21:52:49 +01:00
jordi fita mas 4d0123def7 Bring back the whole list of options in type page, but in accordion
This is how the customer wants it.
2023-12-22 03:27:49 +01:00
jordi fita mas 03c20fec88 Add management of legal texts 2023-12-22 02:23:18 +01:00
jordi fita mas ee86b34e93 Do not panic if there is no location information 2023-12-22 00:26:40 +01:00
jordi fita mas 242e2b1c45 Pass the calendar days to the database as strings
Otherwise, it “helpfully” transforms the hours to UTC+02:00, in my case,
and returns a day extra, fucking up the request for the next sis months,
skipping almost a whole month.
2023-12-21 22:51:12 +01:00
jordi fita mas ff6e9497b5 Replace contact page with location
Customer does not want a contact page, but a page where they can write
the direction on how to reach the campground, with a Google map embed
instead of using Leaflet, because Google Maps shows the reviews right
in the map.

That means i had to replace the GPS locations with XML fields for the
customer to write.  In all four languages.

This time i tried a translation approach inspired by PrestaShop: instead
of opening a new page for each language, i have all languages in the
same page and use AlpineJS to show just a single language.  It is far
easier to write the translations, even though you do not have the source
text visible, specially in this section that there is no place for me
to put the language links.
2023-12-21 21:17:04 +01:00
jordi fita mas 5c4ce32143 Do not panic if there is no Redsys payment set up yet 2023-12-21 17:51:39 +01:00
jordi fita mas c9a6df658f Add position to campsite type features 2023-12-21 17:33:01 +01:00
jordi fita mas 8d3dd589aa Allow to “replace” carousel slides
We realized that it was impossible to update the image of the home and
services carousels: since i am using the add_{type}_carousel() function,
it actually added a new slide instead of replacing the old one.

We need this one for tomorrow, so i made a workaround creating the
new slide, moving the relevant data from the old slide to the new, and
then removing the old slide.  Yuck.
2023-12-21 16:43:46 +01:00
jordi fita mas b6c4eb790f Add the country name to the footer’s address
Customer requested it
2023-12-20 20:22:47 +01:00
jordi fita mas 678b5cc523 Add user-defined order to campsite types, options, seasons and carousels
I use Sortable, exactly like HTMx’s sorting example does[0].  Had to
export the slug or ID of some entries to be able to add it in the hidden
input.

For forms that use ID instead of slug, had to use an input name other
than “id” because otherwise the swap would fail due to bug #1496[1].  It
is apparently fixed in a recent version of HTMx, but i did not want to
update for fear of behaviour changes.

[0]: https://htmx.org/examples/sortable/
[1]: https://github.com/bigskysoftware/htmx/issues/1496
2023-12-20 19:52:14 +01:00
jordi fita mas d2858302ef Parse only campsite type and dates when getting booking form
If i parse everything, then the campsite type options no longer have
their minimum values preset, meaning that people have to input each and
every one of them.
2023-12-20 18:53:07 +01:00
jordi fita mas 20d32d6a6d Keep campsite type and date when going to booking form from type page 2023-12-13 23:42:18 +01:00
jordi fita mas ded10ded08 Only check for postal code if we have a valid country
Otherwise, there we can not know the pattern to check against.
2023-12-13 23:41:47 +01:00
jordi fita mas 6c090a63da Register PostgreSQL types once on start with guest user
There are types inaccessible to the authenticator role, such as
redsys_request, that can not be registered because that roles is unable
to get the OID of.

I could have moved these types to the public schema, but then it would
seem pointless to have a separate schema.
2023-12-13 16:47:31 +01:00
jordi fita mas cfd5d5675c Remove “Party Details” from booking form, and stylize it a bit 2023-12-12 23:16:04 +01:00
jordi fita mas ac09fd77da Use redsys_environment to choose the correct URL to send the payment to 2023-10-27 17:03:50 +02:00
jordi fita mas 0cbf973cbb Add the payment form to admin
Had to change setup_redsys because admins can not read the current
encrypt key, thus it is not possible to `set encrypt_key =
coalesce(…, encrypt_key)`.

Not that it did much sense, anyway, as i was already inside the branch
of the if when encrpty_key is null.

However, it seems that this also affects in the `on conflict` update. I
assume this is because `excluded` is some kind of row of the relation
and has the same restrictions.
2023-10-27 16:08:13 +02:00
jordi fita mas a37d11eed9 Use user.Locale.Language instead of user.Language to sign with Redsys
user.Language is the language set in the database for the user, that in
the case of guests is always going to be ‘und’, that means Redsys would
select Spanish for everyone.
2023-10-27 12:31:32 +02:00
jordi fita mas 007f401d33 Add a cache of OID in database to register types
It makes no sense to retrieve the same OIDs each and every connection,
because they are not going to change unless the database is reset,
something it is very unlikely to happen in production.

Thus, it is best to query them the first time the application connects
to the database, that it is done at startup to query the available
languages, and then reuse the OIDs.

I can get away of using an “unprotected” map, instead of sync.Map or a
map in tandem with sync.RWMutex, because the application establishes a
connection at startup from a single goroutine and it registers _all_
types we will need to register within the application’s lifespan, hence
it there will be no more writes to that map once the web server is
listening for incomming connections.

This is risky, however, and i hope i do not have to regret it.
2023-10-27 12:30:05 +02:00
jordi fita mas 62b54961f4 Implement Redsys request signature in PostgreSQL
Every company need to have its own merchant code and encryption key,
thus it is not possible to use environment variables to keep that data,
and i have to store it in the database.

I do not want to give SELECT permission on the encryption key to guest,
because i am going to fuck it up sooner or later, and everyone would be
able to read that secret; i know it would.  Therefore, i need a security
definer function that takes the data to encrypt, use the key to encrypt
it, and returns the result; nobody else should have access to that key,
not even admins!

By the way, i found out that every merchant receives the same key, thus
it is not a problem to keep it in the repository.

Since i need that SQL function to encrypt the data, i thought that i may
go the whole nine yards and sign the request in PostgreSQL too, after
all the data to sign comes from there, and it has JSON functions to
create and base64-code an object.

Fortunately, pg_crypto has all the functions that i need, but i can no
longer keep that extension inside the auth schema, because it is used
from others, and the public schema, like every other extensions, seems
more appropriate.

Instead of having the list of currency and language codes that Redsys
uses as constants in the code, i moved that as field to the currency
and language relations, so i can simply pass the lang_tag to the
function and it can transform that tag to the correct code; the currency
is from the company’s relation, since it is the only currency used in
the whole application (for now).

As a consequence, i had to grant execute to currency and the parse_price
functions to guest, too.

To generate the test data used in the unit tests, i used a third-party
PHP implementation[0], but i only got from that the resulting base64-coded
JSON object and signature, using the same that as in the unit test, and
did not use any code from there.

PostgreSQL formats the JSON as text differently than most
implementations i have seen: it adds spaces between the key name and
the colons, and space between the value and the separating comma.  The
first implementation used replace() to format the JSON as exactly as
the PHP implementation, so that the result matches, and then tried to do
generate the form by hand using the output from PostgreSQL without the
replace(), to verify that Redsys would still accept my input.  Finally,
i adjusted the unit test to whatever pg_prove said it was getting from
the function.

I still have the form’s action hard-codded to the test environment, but
the idea is that administrators should be able to switch from test to
live themselves.  That means that i need that info in the redsys
relation as well.  I think this is one of the few use cases for SQL’s
types, because it is unlikely to change anytime soon, and i do not need
the actual labels.

Unfortunately, i could not use enumerations for the request’s
transaction type because i can not attach an arbitrary number to the
enum’s values.  Having a relation is overkill, because i would need
a constant in Go to refer to its primary key anyway, thus i kept the
same constant i had before for that.  Language and currency constant
went out, as this is in the corresponding relations.

In setup_redsys i must have a separate update if the encrypt_key is null
because PostgreSQL checks constraints before key conflict, and i do
not want to give a default value to the key if the row is not there yet.
The problem is that i want to use null to mean “keep the same password”,
because it is what i intend to do with the user-facing form: leave the
input empty to keep the same password.

As now Go needs to pass composite types back and forth with PostgreSQL,
i need to register these types, and i have to do it every time because
the only moment i have access to the non-pooled connection is in the
AfterConnect function, but at that point i have no idea whether the
user is going to request a payment.  I do not know how much the
performance degrades because of this.

[0]: https://github.com/ssheduardo/sermepa/blob/master/src/Sermepa/Tpv/Tpv.php
2023-10-27 01:52:04 +02:00
jordi fita mas 048b7cbf90 Add the slug to the form in the campsite type public page
The idea is that the booking form will be prefilled with the values
passed from that other mini-form, and the campsite type is implicit
due to the page where the form is located at, but i need to give it to
the booking page.

The booking page does not yet use that information.
2023-10-19 21:38:44 +02:00
jordi fita mas 302ce29e4a Add the first draft of the booking and payment forms
The form is based on the one in the current website, but in a single
page instead of split into many pages; possibly each <fieldset> should
be in a separate page/view.  The idea is for Oriol to check the design
and decide how it would be presented to the user, so i needed something
to show him first.

I hardcoded the **test** data for the customer’s Redsys account.  Is
this bad? I hope not, but i am not really, really sure.

The data sent to Redsys is just a placeholder because there are booking
details that i do not know, like what i have to do with the “teenagers”
field or the area preferences, thus i can not yet have a booking
relation.  Nevertheless, had to generate a random order number up to
12-chars in length or Redsys would refuse the payment, claiming that
the order is duplicated.

The Redsys package is based on the PHP code provided by Redsys
themselves, plus some hints at the implementations from various Go
packages that did not know why they were so complicated.

Had to grant select on table country to guest in order to show the
select with the country options.

I have changed the “Postal code” input in taxDetails for “Postcode”
because this is the spell that it is used in the current web, i did not
see a reason to change it—it is an accepted form—, and i did not want to
have inconsistencies between forms.
2023-10-19 21:37:34 +02:00
jordi fita mas 96fb253354 Show the campsite type’s calendar in an “infinite scroll” carousel
Oriol does not want to waste so much vertical space for the calendar,
and wants it to show in a carousel, initially with only 6 months, and
loading the next three each time the user scrolls past the last.

I now use HTMx in the public page too for this auto-loading behavior,
based on their “infinite scroll” example[0].

Had to put the /calendar URI inside campsites because in the
calendar.gohtml i do not know the current type’s UUID, and can not use
a relative URL to “add subdirectories”, because the type does not end
with a slash.

Had to change season.CollectCalendar to expect the first month and a
number of months to show, to be able to load only 6 or 3 months after
the current, for the initial carousel content, or after the last month
of the carousel.

[0]: https://htmx.org/examples/infinite-scroll/
2023-10-18 21:06:41 +02:00
jordi fita mas 6e7df4ca79 Do not accept “subdirectories” for public campsite types URL
For now, it ends with the UUID or 404.
2023-10-18 20:58:52 +02:00
jordi fita mas 852acaccc3 Add the calendar to the public campsite type page
I had to export the Calendar type from Season to use it from
campsite/types, and also renamed them because season.SeasonCalendar is
a bit redundant compared to just season.Calendar.

I still have not added the HTMx code to switch year because i am not
sure whether Oriol will want to show a whole year or just half a year.

The calculation for the text color taking into account the contrast with
the background is from [0].

[0]: https://www.smashingmagazine.com/2020/07/css-techniques-legibility/#foreground-contrast
2023-10-14 23:14:23 +02:00
jordi fita mas e1575c6edd Write the unset color as hex literal
Easier for me to grep for it when needed.
2023-10-14 22:09:37 +02:00
jordi fita mas 27af39b296 Add the Catalonia’s Tourism Registry number to company
It is required to be displayed on the website of tourism companies of
Catalonia.
2023-10-14 21:59:36 +02:00
jordi fita mas d1b43e5062 Show “Starting from” price with campsite types that have options
In the old website, the prices where show with all the options, but in
the new design only a single price is show, that in the case of
campsites with options is the price per night of the “base” plus the
minimum options selected.
2023-10-13 20:44:24 +02:00
jordi fita mas 2e10966ad7 Add the list of features for campsite type 2023-10-13 20:30:31 +02:00
jordi fita mas d784291a04 Create Go functions for PostgreSQL functions for campsite type option
I am going to base these to create the function for campsite type
feature, and since i intend to
2023-10-13 19:05:17 +02:00
jordi fita mas a174837aea Handle errors for Commit and Rollback in campsite/types/option 2023-10-13 18:57:46 +02:00
jordi fita mas 7fc87b5cb5 Add the info and facilities fields to campsite type
I wish CKEditor would have support for <dl>, but it is unlikely that
they will add any time soon[0], specially when in 2018 they already
“forgotten”[1] that this was requested back in 2007[2].

Therefore, in the demo i did it more or less like in the original
design, with “extra” <h4>, although i added them under a <h3>, to avoid
“gaps” in the outline.

[0]: https://github.com/ckeditor/ckeditor5/issues/775
[1]: https://github.com/ckeditor/ckeditor5/issues/775#issuecomment-358591747
[2]: https://dev.ckeditor.com/ticket/1333
2023-10-13 18:09:28 +02:00
jordi fita mas 59fe8dd131 Add Go functions for campsite_type PostgreSQL functions
I want these because when there are changes in the signature i then have
to find where it is used, and it is easier to do when the compiler tells
you.

For relations it is less necessary because GoLand knows how to validate
SQL strings for them, but it seems to not work with functions,
apparently due to the lack of the “FROM” keyword.

Besides, it tx.FunctionName(ctx, params...) is shorter than
tx.Exec("select functions_name($1, $2…)", params...).
2023-10-13 12:53:30 +02:00
jordi fita mas 0ebbf9613d Check errors for Commit and Rollback in package campsite/types 2023-10-13 12:42:05 +02:00
jordi fita mas ebf47b5d75 Add the “spiel” for campsite types
This is the text that introduces the carousel; it is not a spiel, but
this is what i call it.

It turns out that this text needs to have paragraphs and headings, much
like home’s slider, rather than the one in services page, thus no need
to change its font size or to align all items in the carousel in the
middle.
2023-10-12 18:47:08 +02:00
jordi fita mas 471ed9e870 Add the carousel for campsite types
I can not reuse the carousel package because these carousels need the
campsite site’s slug as a first parameters: i can not have a relation
per campsite type, as i do in home and services pages, because the
campsite types are added by administration types; even if i had a
single relation for slides of home and services pages, these would go
in a different relation due to the foreign key to campsite type.

What i could reuse, however, is the Slide and SlideEntry types from
that package, although i had to export carousel.Translation to be usable
from the types package.  I should change that to use locale.Translation,
but this was the easier option, or i would need to change the queries
and templates for carousel package too.

Besides that, they work exactly like the slides in home and services
pages.
2023-10-12 17:43:23 +02:00
jordi fita mas ad7126cc92 Fix allowed methods repost for carousel’s root address 2023-10-12 16:23:32 +02:00
jordi fita mas caab52a274 Add the campground page
For now, this page only shows the map, that i had to create a new
“files” template function to include it as an extra template file.
2023-10-06 22:14:11 +02:00
jordi fita mas ae29726fa2 Add the footer site map
I created a common template to show the company address in the footer
and the contact page, and then i realized Go did not like to output my
phone URL in the anchor without having the tel: schema in the template.
I then removed that variable and now the URL is created with tel: and
the phone number with its spaces removed.
2023-10-06 22:02:59 +02:00
jordi fita mas d5905a2277 Add the contact page, containing a map with the company location
I was not sure whether to use PostGIS to store the GPS location of the
company, as i am sure i will only use that point just to show the map.
However, just in case, it is not a big deal.

There is no way to change that from the administration pages for now,
because of time constraints, and it is very unlikely that they will
change the campgrounds’ location in the near future.

The location is in a separate table because i did not want to have to
change every test file, to be honest, but this also makes the map
“optional” without the need for NULL values.

I added the contact address to every public page because the new design
adds it to the footer, so i will be needing it everywhere, just like the
menu.
2023-10-06 21:21:00 +02:00
jordi fita mas 9293a341ef Add campsite type options, mainly for plots 2023-10-06 13:26:01 +02:00
jordi fita mas 5f38ab8fd3 Add internationalization and localization to seasons 2023-10-03 21:14:37 +02:00