From 5658e0aeeda1ce87aa3f7af310655769251d8815 Mon Sep 17 00:00:00 2001 From: Karen Date: Mon, 23 Jan 2023 12:11:25 +0100 Subject: [PATCH] (feat) create settings for machines banner backend --- app/frontend/src/javascript/models/setting.ts | 8 +++++++- app/models/setting.rb | 6 ++++++ app/policies/setting_policy.rb | 2 +- test/frontend/__fixtures__/settings.ts | 12 ++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/frontend/src/javascript/models/setting.ts b/app/frontend/src/javascript/models/setting.ts index ef96aefbb..c7eee6f13 100644 --- a/app/frontend/src/javascript/models/setting.ts +++ b/app/frontend/src/javascript/models/setting.ts @@ -243,6 +243,11 @@ export const trainingSettings = [ 'trainings_invalidation_rule_period' ] as const; +export const bannersSettings = [ + 'machines_banner_text', + 'machines_banner_button' +] as const; + export const allSettings = [ ...homePageSettings, ...privacyPolicySettings, @@ -269,7 +274,8 @@ export const allSettings = [ ...poymentSettings, ...displaySettings, ...storeSettings, - ...trainingSettings + ...trainingSettings, + ...bannersSettings ] as const; export type SettingName = typeof allSettings[number]; diff --git a/app/models/setting.rb b/app/models/setting.rb index 37aa1a46d..209b2a336 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -173,6 +173,12 @@ class Setting < ApplicationRecord trainings_authorization_validity_duration trainings_invalidation_rule trainings_invalidation_rule_period] } + trainings_auto_cancel_deadline + machines_banner_active + machines_banner_text + machines_banner_cta_active + machines_banner_cta_label + machines_banner_cta_url] } # WARNING: when adding a new key, you may also want to add it in: # - config/locales/en.yml#settings # - app/frontend/src/javascript/models/setting.ts#SettingName diff --git a/app/policies/setting_policy.rb b/app/policies/setting_policy.rb index 315262047..4e9ec31e2 100644 --- a/app/policies/setting_policy.rb +++ b/app/policies/setting_policy.rb @@ -43,7 +43,7 @@ class SettingPolicy < ApplicationPolicy pack_only_for_subscription overlapping_categories public_registrations facebook twitter viadeo linkedin instagram youtube vimeo dailymotion github echosciences pinterest lastfm flickr machines_module user_change_group user_validation_required user_validation_required_list store_module store_withdrawal_instructions store_hidden - external_id] + external_id machines_banner_active machines_banner_text machines_banner_cta_active machines_banner_cta_label machines_banner_cta_url] end ## diff --git a/test/frontend/__fixtures__/settings.ts b/test/frontend/__fixtures__/settings.ts index bfe6a1e64..ae03123c2 100644 --- a/test/frontend/__fixtures__/settings.ts +++ b/test/frontend/__fixtures__/settings.ts @@ -747,6 +747,18 @@ export const settings: Array = [ value: 'TVA', last_update: '2022-12-23T14:39:12+0100', localized: 'Nom de la TVA' + }, + { + name: 'machines_banner_text', + value: 'false', + last_update: '2022-12-23T14:39:12+0100', + localized: 'Text of the banner in Machines List' + }, + { + name: 'machines_banner_button', + value: 'false', + last_update: '2022-12-23T14:39:12+0100', + localized: 'Button of the banner in Machines List' } ];