diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4513e0d63..55735c7d2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -5,7 +5,7 @@ module ApplicationHelper
require 'message_format'
## machine/spaces availabilities are divided in multiple slots of 60 minutes
- SLOT_DURATION ||= Rails.application.secrets.slot_duration || 60
+ SLOT_DURATION ||= Setting.get('slot_duration') || 60
##
# Verify if the provided attribute is in the provided attributes array, whatever it exists or not
diff --git a/app/models/setting.rb b/app/models/setting.rb
index c9389afc5..aa24093bd 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -78,7 +78,8 @@ class Setting < ApplicationRecord
uuid
phone_required
tracking_id
- book_overlapping_slots] }
+ book_overlapping_slots
+ slot_duration] }
def value
last_value = history_values.order(HistoryValue.arel_table['created_at'].desc).first
last_value&.value
diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml
index 401a37da5..12ce02fb2 100644
--- a/config/locales/app.admin.en.yml
+++ b/config/locales/app.admin.en.yml
@@ -1022,6 +1022,7 @@ en:
phone_required: "phone required"
tracking_id: "tracking ID"
book_overlapping_slots: "book overlapping slots"
+ slot_duration: "slots duration"
elements_ordering: "Elements ordering"
machines_order: "Machines order"
display_machines_sorted_by: "Display machines sorted by"
@@ -1031,6 +1032,9 @@ en:
an_error_occurred_saving_the_setting: "An error occurred while saving the setting. Please try again later."
book_overlapping_slots_info: "Allow / prevent the reservation of overlapping slots"
allow_booking: "Allow booking"
+ default_slot_duration: "Default duration for slots"
+ duration_minutes: "Duration (in minutes)"
+ default_slot_duration_info: "Machine and space availabilities are divided in multiple slots of this duration. This value can be overridden per availability."
sort_by:
default: "Default"
name: "Name"
diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml
index e1f60c8d5..05044fafe 100644
--- a/config/locales/app.admin.fr.yml
+++ b/config/locales/app.admin.fr.yml
@@ -1022,6 +1022,7 @@ fr:
phone_required: "téléphone requis"
tracking_id: "ID de suivi"
book_overlapping_slots: "réservation de créneaux simultanés"
+ slot_duration: "durée des créneaux"
elements_ordering: "Ordre d'affichage des éléments"
machines_order: "Ordre des machines"
display_machines_sorted_by: "Afficher les machines triées par"
@@ -1031,6 +1032,9 @@ fr:
an_error_occurred_saving_the_setting: "Une erreur est survenue pendant l'enregistrement du paramètre. Veuillez réessayer plus tard."
book_overlapping_slots_info: "Autoriser / empêcher la réservation de créneaux qui se chevauchent"
allow_booking: "Autoriser la réservation"
+ default_slot_duration: "Durée par défaut pour les créneaux"
+ duration_minutes: "Durée (en minutes)"
+ default_slot_duration_info: "Les disponibilités des machines et des espaces sont divisées en plusieurs créneaux de cette durée. Cette valeur peur être changée pour chaque disponibilité."
sort_by:
default: "Défaut"
name: "Nom"
diff --git a/db/seeds.rb b/db/seeds.rb
index e9413f7fb..cc5a7ea8f 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -951,6 +951,12 @@ unless Setting.find_by(name: 'home_content').try(:value)
setting.save
end
+unless Setting.find_by(name: 'slot_duration').try(:value)
+ setting = Setting.find_or_initialize_by(name: 'slot_duration')
+ setting.value = '60'
+ setting.save
+end
+
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2)
diff --git a/doc/environment.md b/doc/environment.md
index 943e9fc98..5786a0418 100644
--- a/doc/environment.md
+++ b/doc/environment.md
@@ -123,15 +123,6 @@ Set to 'false' if you don't want this behaviour.
EVENTS_IN_CALENDAR
If set to 'true', the admin calendar will display the scheduled events in the current view, as read-only items.
-
-
- SLOT_DURATION
-
-Machine and space availabilities are divided in multiple slots of the duration set by this variable.
-Default value is 60 minutes (1 hour).
-
-⚠ Changing this value during the application life may cause serious issues.
-Please ensure there's no machine/space availabilities opened to reservation or already reserved **in the future** when you change this value.
DEFAULT_MAIL_FROM
diff --git a/lib/tasks/fablab/setup.rake b/lib/tasks/fablab/setup.rake
index 21d4882df..d7d96dcad 100644
--- a/lib/tasks/fablab/setup.rake
+++ b/lib/tasks/fablab/setup.rake
@@ -106,7 +106,8 @@ namespace :fablab do
mapping = [
%w[PHONE_REQUIRED phone_required true],
%w[GA_ID tracking_id],
- %w[BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true]
+ %w[BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true],
+ %w[SLOT_DURATION slot_duration 60]
]
mapping.each do |m|