From f56b8eae75c896ae857a65c654a829d7aac835cd Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 29 Jun 2021 09:07:11 +0200 Subject: [PATCH] admin can configure renew threshold --- .../javascript/directives/settings/number-setting.js | 3 ++- app/frontend/src/javascript/router.js | 3 ++- app/frontend/templates/admin/settings/number.html | 2 +- .../templates/admin/settings/reservations.html | 12 ++++++++++++ app/services/prepaid_pack_service.rb | 2 +- config/locales/app.admin.en.yml | 3 +++ config/locales/app.admin.fr.yml | 3 +++ 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/frontend/src/javascript/directives/settings/number-setting.js b/app/frontend/src/javascript/directives/settings/number-setting.js index 4f9d3e030..76e08edd7 100644 --- a/app/frontend/src/javascript/directives/settings/number-setting.js +++ b/app/frontend/src/javascript/directives/settings/number-setting.js @@ -10,6 +10,7 @@ Application.Directives.directive('numberSetting', ['Setting', 'growl', '_t', faIcon: '@', helperText: '@', min: '@', + step: '@', required: '<' }, templateUrl: '/admin/settings/number.html', @@ -17,7 +18,7 @@ Application.Directives.directive('numberSetting', ['Setting', 'growl', '_t', // The setting $scope.setting = { name: $scope.name, - value: parseInt($scope.settings[$scope.name], 10) + value: parseFloat($scope.settings[$scope.name]) }; /** diff --git a/app/frontend/src/javascript/router.js b/app/frontend/src/javascript/router.js index 2cccf050e..711b11295 100644 --- a/app/frontend/src/javascript/router.js +++ b/app/frontend/src/javascript/router.js @@ -1078,7 +1078,8 @@ angular.module('application.router', ['ui.router']) "'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', 'confirmation_required', " + "'reminder_delay', 'visibility_yearly', 'visibility_others', 'wallet_module', 'trainings_module', " + "'display_name_enable', 'machines_sort_by', 'fab_analytics', 'statistics_module', 'address_required', " + - "'link_name', 'home_content', 'home_css', 'phone_required', 'upcoming_events_shown', 'public_agenda_module']" + "'link_name', 'home_content', 'home_css', 'phone_required', 'upcoming_events_shown', 'public_agenda_module'," + + "'renew_pack_threshold']" }).$promise; }], privacyDraftsPromise: ['Setting', function (Setting) { return Setting.get({ name: 'privacy_draft', history: true }).$promise; }], diff --git a/app/frontend/templates/admin/settings/number.html b/app/frontend/templates/admin/settings/number.html index 46b1474d3..833b8dbf1 100644 --- a/app/frontend/templates/admin/settings/number.html +++ b/app/frontend/templates/admin/settings/number.html @@ -5,7 +5,7 @@
- + {{ helperText | translate }} diff --git a/app/frontend/templates/admin/settings/reservations.html b/app/frontend/templates/admin/settings/reservations.html index 70597a1b8..ad2a10ec1 100644 --- a/app/frontend/templates/admin/settings/reservations.html +++ b/app/frontend/templates/admin/settings/reservations.html @@ -157,5 +157,17 @@ label="app.admin.settings.show_event" classes="m-l"> +
+

{{ 'app.admin.settings.display_invite_to_renew_pack' }}

+

+ + +
diff --git a/app/services/prepaid_pack_service.rb b/app/services/prepaid_pack_service.rb index 44f3b2e07..29efbc1b3 100644 --- a/app/services/prepaid_pack_service.rb +++ b/app/services/prepaid_pack_service.rb @@ -23,7 +23,7 @@ class PrepaidPackService .includes(:prepaid_pack) .references(:prepaid_packs) .where('statistic_profile_id = ?', user.statistic_profile.id) - .where('expires_at < ?', DateTime.current) + .where('expires_at > ?', DateTime.current) .where('prepaid_packs.priceable_id = ?', priceable.id) .where('prepaid_packs.priceable_type = ?', priceable.class.name) diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index b5cfdfa33..76639b349 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -1205,6 +1205,9 @@ en: public_agenda_module: "public agenda module" statistics_module: "statistics module" upcoming_events_shown: "display limit for upcoming events" + display_invite_to_renew_pack: "Display the invite to renew prepaid-packs" + packs_threshold_info_html: "You can define under how many hours the user will be invited to buy a prepaid-pack, if his stock of prepaid hours in under this threshold.
You can set a number of hours (eg. 5) or a percentage of his current pack pack (eg. 0.05 means 5%)." + renew_pack_threshold: "threshold for packs renewal" general: general: "General" title: "Title" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index a47752f66..cad85b338 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -1170,6 +1170,9 @@ fr: public_agenda_module: "module d'agenda public" statistics_module: "module de statistiques" upcoming_events_shown: "la limite d'affichage des événements à venir" + display_invite_to_renew_pack: "Display the invite to renew prepaid-packs" + packs_threshold_info_html: "You can define under how many hours the user will be invited to buy a prepaid-pack, if his stock of prepaid hours in under this threshold.
You can set a number of hours (eg. 5) or a percentage of his current pack pack (eg. 0.05 means 5%)." + renew_pack_threshold: "Threshold for packs renewal" general: general: "Général" title: "Titre"