diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 1772fe61a..0d638ab5e 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -1011,7 +1011,7 @@ angular.module('application.router', ['ui.router']) return Setting.query({ names: `['twitter_name', 'about_title', 'about_body', 'tracking_id',\ 'privacy_body', 'privacy_dpo', 'about_contacts', 'book_overlapping_slots', \ - 'home_blogpost', 'machine_explications_alert', 'training_explications_alert', \ + 'home_blogpost', 'machine_explications_alert', 'training_explications_alert', 'slot_duration', \ 'training_information_message', 'subscription_explications_alert', 'event_explications_alert', \ 'space_explications_alert', 'booking_window_start', 'booking_window_end', \ 'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', \ diff --git a/app/assets/stylesheets/modules/settings.scss b/app/assets/stylesheets/modules/settings.scss index 7414033a5..3e5889803 100644 --- a/app/assets/stylesheets/modules/settings.scss +++ b/app/assets/stylesheets/modules/settings.scss @@ -67,4 +67,10 @@ } } } + + .section-separator { + background: radial-gradient(#dddddd, transparent); + height: 1px; + margin: 24px 33% 12px 33%; + } } diff --git a/app/assets/templates/admin/settings/reservations.html b/app/assets/templates/admin/settings/reservations.html index d4bc1693c..b1d8c885d 100644 --- a/app/assets/templates/admin/settings/reservations.html +++ b/app/assets/templates/admin/settings/reservations.html @@ -21,6 +21,7 @@ +

{{ 'app.admin.settings.max_visibility' }}

+

{{ 'app.admin.settings.ability_for_the_users_to_move_their_reservations' }}

@@ -68,10 +70,24 @@ required="allSettings.booking_cancel_enable === 'true'">
+

{{ 'app.admin.settings.book_overlapping_slots_info' }}

+
+
+

{{ 'app.admin.settings.default_slot_duration' }}

+

{{ 'app.admin.settings.default_slot_duration_info' }}

+ + +
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|