1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

ability to configure until when the events are shown on the home page

This commit is contained in:
Sylvain 2020-09-29 09:39:32 +02:00
parent 30b3a794d3
commit 13bc5334cc
8 changed files with 42 additions and 4 deletions

View File

@ -1,6 +1,8 @@
# Changelog Fab-manager
- Ability to configure until when the events are shown on the home page
- Fix a bug: managers cannot see passed events
- [TODO DEPLOY] `rails db:seed`
## v4.5.8 2020 Septembre 28

View File

@ -1043,7 +1043,7 @@ angular.module('application.router', ['ui.router'])
'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', 'confirmation_required', \
'reminder_delay', 'visibility_yearly', 'visibility_others', 'wallet_module', \
'display_name_enable', 'machines_sort_by', 'fab_analytics', 'statistics_module', \
'link_name', 'home_content', 'home_css', 'phone_required']` }).$promise;
'link_name', 'home_content', 'home_css', 'phone_required', 'upcoming_events_shown']` }).$promise;
}],
privacyDraftsPromise: ['Setting', function (Setting) { return Setting.get({ name: 'privacy_draft', history: true }).$promise; }],
cguFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'cgu-file' }).$promise; }],

View File

@ -27,6 +27,18 @@
</text-setting>
</div>
</div>
<div class="row m-t-lg">
<div class="col-md-6">
<select-setting name="upcoming_events_shown"
settings="allSettings"
required="true"
label="app.admin.settings.home.show_upcoming_events"
option-1="['until_start', 'app.admin.settings.home.upcoming_events.until_start']"
option-2="['2h_before_end', 'app.admin.settings.home.upcoming_events.2h_before_end']"
option-3="['until_end', 'app.admin.settings.home.upcoming_events.until_end']">
</select-setting>
</div>
</div>
<div class="row m-t-lg home-page-style">
<uib-accordion>
<uib-accordion-group is-open="advancedSettings.open">

View File

@ -36,9 +36,17 @@ class API::EventsController < API::ApiController
limit = params[:limit]
@events = Event.includes(:event_image, :event_files, :availability, :category)
.where('events.nb_total_places != -1 OR events.nb_total_places IS NULL')
.where('availabilities.start_at >= ?', DateTime.current)
.order('availabilities.start_at ASC').references(:availabilities)
.limit(limit)
@events = case Setting.get('upcoming_events_shown')
when 'until_start'
@events.where('availabilities.start_at >= ?', DateTime.current)
when '2h_before_end'
@events.where('availabilities.end_at >= ?', DateTime.current + 2.hours)
else
@events.where('availabilities.end_at >= ?', DateTime.current)
end
end
def show; end

View File

@ -105,7 +105,8 @@ class Setting < ApplicationRecord
invoice_prefix
confirmation_required
wallet_module
statistics_module] }
statistics_module
upcoming_events_shown] }
# WARNING: when adding a new key, you may also want to add it in app/policies/setting_policy.rb#public_whitelist
def value

View File

@ -1112,6 +1112,7 @@ en:
confirmation_is_required: "Confirmation required"
wallet_module: "wallet module"
statistics_module: "statistics module"
upcoming_events_shown: "display limit for upcoming events"
general:
general: "General"
title: "Title"
@ -1151,6 +1152,12 @@ en:
statistics: "Statistics"
statistics_info_html: "<p>Enable or disable the statistics module.</p><p>If enabled, every nights, the data of the day just passed will be consolidated in the database of a powerful analysis engine. Then, every administrators will be able to browse statistical charts and tables in the corresponding section.</p>"
enable_statistics: "Enable statistics"
home:
show_upcoming_events: "Show upcoming events"
upcoming_events:
until_start: "Until they start"
2h_before_end: "Until 2 hours before they end"
until_end: "Until they end"
privacy:
title: "Privacy"
privacy_policy: "Privacy policy"

View File

@ -1112,6 +1112,7 @@ fr:
confirmation_is_required: "Confirmation requise"
wallet_module: "module porte-monnaie"
statistics_module: "module de statistiques"
upcoming_events_shown: "la limite d'affichage des événements à venir"
general:
general: "Général"
title: "Titre"
@ -1151,6 +1152,12 @@ fr:
statistics: "Statistiques"
statistics_info_html: "<p>Activer ou désactiver le module de statistiques.</p><p>Si activé, chaque nuit, les données de la journée qui vient de s'écouler seront consolidées dans la base de données d'un puissant moteur d'analyse. Ensuite, chaque administrateur pourra parcourir les tableaux et graphiques statistiques dans la section correspondante.</p>"
enable_statistics: "Activer les statistiques"
home:
show_upcoming_events: "Afficher les prochains événements"
upcoming_events:
until_start: "Jusqu'à ce qu'ils commencent"
2h_before_end: "Jusqu'à 2 heures avant la fin"
until_end: "Jusqu'à ce qu'ils finissent"
privacy:
title: "Confidentialité"
privacy_policy: "Politique de confidentialité"

View File

@ -1,4 +1,3 @@
# frozen_string_literal: true
if StatisticIndex.count.zero?
StatisticIndex.create!([
@ -892,6 +891,8 @@ Setting.set('wallet_module', true) unless Setting.find_by(name: 'wallet_module')
Setting.set('statistics_module', true) unless Setting.find_by(name: 'statistics_module').try(:value)
Setting.set('upcoming_events_shown', 'until_start') unless Setting.find_by(name: 'upcoming_events_shown').try(:value)
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2)