Add the services page
This page is more or less similar to home, in terms of database: it
has a carousel and a list of items; in this case, the definition of
campsite services.
As i said early, when adding the home carousel, this carousel has its
own relation and set of functions to manage slides. They are also
duplicated in Go code, but i think i will need to refactor it later to
a carousel package or something like that, because both relations have
the exact same fields and types, so it makes no sense to have twice the
same code.
I already did it with the CSS and JavaScript code, mostly because it was
easier to replace the `.surroundings div` selector with `.carousel`, and
because that way i can have a single template that loads and initializes
Slick.
There is no UI to create or edit service definitions, although there are
the SQL functions, because i have no more time now, and Oriol needs to
check that the style is correct for that page.
2023-09-17 01:42:16 +00:00
|
|
|
-- Test translate_service
|
|
|
|
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', 'translate_service', array['integer', 'text', 'text', 'text']);
|
|
|
|
select function_lang_is('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'sql');
|
|
|
|
select function_returns('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'void');
|
|
|
|
select isnt_definer('camper', 'translate_service', array['integer', 'text', 'text', 'text']);
|
|
|
|
select volatility_is('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'volatile');
|
|
|
|
select function_privs_are('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'guest', array[]::text[]);
|
|
|
|
select function_privs_are('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'employee', array[]::text[]);
|
|
|
|
select function_privs_are('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'admin', array['EXECUTE']);
|
|
|
|
select function_privs_are('camper', 'translate_service', array['integer', 'text', 'text', 'text'], 'authenticator', array[]::text[]);
|
|
|
|
|
|
|
|
|
|
|
|
set client_min_messages to warning;
|
|
|
|
truncate service cascade;
|
|
|
|
truncate company cascade;
|
|
|
|
reset client_min_messages;
|
|
|
|
|
2024-01-14 01:09:17 +00:00
|
|
|
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')
|
Add the services page
This page is more or less similar to home, in terms of database: it
has a carousel and a list of items; in this case, the definition of
campsite services.
As i said early, when adding the home carousel, this carousel has its
own relation and set of functions to manage slides. They are also
duplicated in Go code, but i think i will need to refactor it later to
a carousel package or something like that, because both relations have
the exact same fields and types, so it makes no sense to have twice the
same code.
I already did it with the CSS and JavaScript code, mostly because it was
easier to replace the `.surroundings div` selector with `.carousel`, and
because that way i can have a single template that loads and initializes
Slick.
There is no UI to create or edit service definitions, although there are
the SQL functions, because i have no more time now, and Oriol needs to
check that the style is correct for that page.
2023-09-17 01:42:16 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
insert into service (service_id, company_id, icon_name, name, description)
|
|
|
|
values (5, 1, 'information', 'Service A', '<p>A</p>')
|
|
|
|
, (6, 1, 'toilet', 'Service B', '<p>B</p>')
|
|
|
|
;
|
|
|
|
|
|
|
|
insert into service_i18n (service_id, lang_tag, name, description)
|
|
|
|
values (6, 'ca', 'serveib', '<p>B</p>')
|
|
|
|
;
|
|
|
|
|
|
|
|
select lives_ok(
|
|
|
|
$$ select translate_service(5, 'ca', 'Servei A', '<p>a</p>') $$,
|
|
|
|
'Should be able to translate the first service'
|
|
|
|
);
|
|
|
|
|
|
|
|
select lives_ok(
|
|
|
|
$$ select translate_service(6, 'es', 'Servicio B', '<p>b</p>') $$,
|
|
|
|
'Should be able to translate the second service'
|
|
|
|
);
|
|
|
|
|
|
|
|
select lives_ok(
|
|
|
|
$$ select translate_service(6, 'ca', 'Servei B', null) $$,
|
|
|
|
'Should be able to overwrite the catalan translation of the second service, with no description'
|
|
|
|
);
|
|
|
|
|
|
|
|
select bag_eq(
|
|
|
|
$$ select service_id, lang_tag, name, description::text from service_i18n $$,
|
|
|
|
$$ values (5, 'ca', 'Servei A', '<p>a</p>')
|
|
|
|
, (6, 'ca', 'Servei B', '')
|
|
|
|
, (6, 'es', 'Servicio B', '<p>b</p>')
|
|
|
|
$$,
|
|
|
|
'Should have added and updated all translations.'
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
select *
|
|
|
|
from finish();
|
|
|
|
|
|
|
|
rollback;
|