1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

refactored app to gather spaces module status from the settings

This commit is contained in:
Sylvain 2020-05-26 13:59:40 +02:00
parent fd93093f0d
commit 6cc6bba7ce
31 changed files with 88 additions and 193 deletions

View File

@ -83,8 +83,6 @@ angular.module('application', ['ngCookies', 'ngResource', 'ngSanitize', 'ui.rout
// Global config: if true, the whole 'Plans & Subscriptions' feature will be disabled in the application
$rootScope.fablabWithoutPlans = Fablab.withoutPlans;
// Global config: it true, the whole 'Spaces' features will be disabled in the application
$rootScope.fablabWithoutSpaces = Fablab.withoutSpaces;
// Global config: if true, all payments will be disabled in the application for the members (only admins will be able to proceed reservations)
$rootScope.fablabWithoutOnlinePayment = Fablab.withoutOnlinePayment;
// Global config: if true, no invoices will be generated

View File

@ -676,7 +676,7 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state',
content: _t('app.admin.tour.pricing.machines.content'),
placement: 'bottom'
});
if (!Fablab.withoutSpaces) {
if ($scope.spacesModule) {
uitour.createStep({
selector: '.plans-pricing .spaces-tab',
stepId: 'spaces',

View File

@ -181,7 +181,7 @@ Application.Controllers.controller('StatisticsController', ['$scope', '$state',
if (tab.table) {
if ((tab.es_type_key === 'subscription') && $rootScope.fablabWithoutPlans) {
return true;
} else return (tab.es_type_key === 'space') && $rootScope.fablabWithoutSpaces;
} else return (tab.es_type_key === 'space') && !$rootScope.spacesModule;
} else {
return true;
}

View File

@ -1,7 +1,7 @@
'use strict';
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', '$translatePartialLoader', 'AuthService', 'settingsPromise', 'Member', 'uiTourService', '_t', 'Help',
function ($scope, $stateParams, $translatePartialLoader, AuthService, settingsPromise, Member, uiTourService, _t, Help) {
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', '$translatePartialLoader', 'AuthService', 'settingsPromise', 'Member', 'uiTourService', '_t',
function ($scope, $stateParams, $translatePartialLoader, AuthService, settingsPromise, Member, uiTourService, _t) {
/* PUBLIC SCOPE */
// Home page HTML content
@ -140,7 +140,7 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
content: _t('app.public.tour.welcome.machines.content'),
placement: 'right'
});
if (!Fablab.withoutSpaces) {
if ($scope.spacesModule) {
uitour.createStep({
selector: '.nav-primary li.reserve-space-link',
stepId: 'spaces',

View File

@ -67,7 +67,7 @@ Application.Controllers.controller('MainNavController', ['$scope', function ($sc
});
}
if (!Fablab.withoutSpaces) {
if ($scope.spacesModule) {
$scope.navLinks.splice(4, 0, {
state: 'app.public.spaces_list',
linkText: 'app.public.common.reserve_a_space',
@ -153,7 +153,7 @@ Application.Controllers.controller('MainNavController', ['$scope', function ($sc
$scope.adminNavLinks = adminNavLinks;
if (!Fablab.withoutSpaces) {
if ($scope.spacesModule) {
return $scope.adminNavLinks.splice(3, 0, {
state: 'app.public.spaces_list',
linkText: 'app.public.common.manage_the_spaces',

View File

@ -16,7 +16,7 @@ angular.module('application.router', ['ui.router'])
// abstract root parents states
// these states controls the access rights to the various routes inherited from them
return $stateProvider
$stateProvider
.state('app', {
abstract: true,
views: {
@ -36,14 +36,16 @@ angular.module('application.router', ['ui.router'])
resolve: {
logoFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'logo-file' }).$promise; }],
logoBlackFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'logo-black-file' }).$promise; }],
sharedTranslations: ['Translations', function (Translations) { return Translations.query(['app.shared', 'app.public.common']).$promise; }]
sharedTranslations: ['Translations', function (Translations) { return Translations.query(['app.shared', 'app.public.common']).$promise; }],
spacesModulePromise: ['Setting', function (Setting) { return Setting.get({ name: 'spaces_module' }).$promise; }]
},
onEnter: ['$rootScope', 'logoFile', 'logoBlackFile', 'CSRF', function ($rootScope, logoFile, logoBlackFile, CSRF) {
onEnter: ['$rootScope', 'logoFile', 'logoBlackFile', 'spacesModulePromise', 'CSRF', function ($rootScope, logoFile, logoBlackFile, spacesModulePromise, CSRF) {
// Retrieve Anti-CSRF tokens from cookies
CSRF.setMetaTags();
// Application logo
$rootScope.logo = logoFile.custom_asset;
$rootScope.logoBlack = logoBlackFile.custom_asset;
$rootScope.spacesModule = (spacesModulePromise.setting.value === 'true');
}]
})
.state('app.public', {
@ -98,7 +100,7 @@ angular.module('application.router', ['ui.router'])
}
},
resolve: {
settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['home_content', 'home_blogpost']" }).$promise; }]
settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['home_content', 'home_blogpost', 'spaces_module']" }).$promise; }]
}
})
.state('app.public.privacy', {
@ -366,7 +368,7 @@ angular.module('application.router', ['ui.router'])
// spaces
.state('app.public.spaces_list', {
url: '/spaces',
abstract: Fablab.withoutSpaces,
abstract: !Fablab.spacesModule,
views: {
'main@': {
templateUrl: '<%= asset_path "spaces/index.html" %>',
@ -379,7 +381,7 @@ angular.module('application.router', ['ui.router'])
})
.state('app.admin.space_new', {
url: '/spaces/new',
abstract: Fablab.withoutSpaces,
abstract: !Fablab.spacesModule,
views: {
'main@': {
templateUrl: '<%= asset_path "spaces/new.html" %>',
@ -389,7 +391,7 @@ angular.module('application.router', ['ui.router'])
})
.state('app.public.space_show', {
url: '/spaces/:id',
abstract: Fablab.withoutSpaces,
abstract: !Fablab.spacesModule,
views: {
'main@': {
templateUrl: '<%= asset_path "spaces/show.html" %>',
@ -402,7 +404,7 @@ angular.module('application.router', ['ui.router'])
})
.state('app.admin.space_edit', {
url: '/spaces/:id/edit',
abstract: Fablab.withoutSpaces,
abstract: !Fablab.spacesModule,
views: {
'main@': {
templateUrl: '<%= asset_path "spaces/edit.html" %>',
@ -415,7 +417,7 @@ angular.module('application.router', ['ui.router'])
})
.state('app.logged.space_reserve', {
url: '/spaces/:id/reserve',
abstract: Fablab.withoutSpaces,
abstract: !Fablab.spacesModule,
views: {
'main@': {
templateUrl: '<%= asset_path "spaces/reserve.html" %>',
@ -757,7 +759,8 @@ angular.module('application.router', ['ui.router'])
spacesPromise: ['Space', function (Space) { return Space.query().$promise; }],
spacesPricesPromise: ['Price', function (Price) { return Price.query({ priceable_type: 'Space', plan_id: 'null' }).$promise; }],
spacesCreditsPromise: ['Credit', function (Credit) { return Credit.query({ creditable_type: 'Space' }).$promise; }],
slotDurationPromise: ['Setting', function (Setting) { return Setting.get({ name: 'slot_duration' }).$promise; }]
slotDurationPromise: ['Setting', function (Setting) { return Setting.get({ name: 'slot_duration' }).$promise; }],
spacesModulePromise: ['Setting', function (Setting) { return Setting.get({ name: 'spaces_module' }).$promise; }]
}
})

View File

@ -38,7 +38,7 @@
<div class="legends">
<span class="calendar-legend text-sm border-formation" translate>{{ 'app.admin.calendar.trainings' }}</span><br>
<span class="calendar-legend text-sm border-machine" translate>{{ 'app.admin.calendar.machines' }}</span><br>
<span class="calendar-legend text-sm border-space" ng-hide="fablabWithoutSpaces" translate>{{ 'app.admin.calendar.spaces' }}</span>
<span class="calendar-legend text-sm border-space" ng-show="spacesModule" translate>{{ 'app.admin.calendar.spaces' }}</span>
<span class="calendar-legend text-sm border-event" ng-show="eventsInCalendar" translate>{{ 'app.admin.calendar.events' }}</span>
</div>
</div>

View File

@ -18,7 +18,7 @@
<span translate>{{ 'app.admin.calendar.machine' }}</span>
</label>
</div>
<div class="radio" ng-hide="fablabWithoutSpaces">
<div class="radio" ng-show="spacesModule">
<label>
<input type="radio" id="space" name="available_type" value="space" ng-model="availability.available_type" ng-disabled="spaces.length === 0">
<span translate>{{ 'app.admin.calendar.space' }}</span>

View File

@ -73,8 +73,8 @@
</tbody>
</table>
<h3 ng-hide="fablabWithoutSpaces" translate>{{ 'app.admin.plans.edit.spaces' }}</h3>
<table class="table" ng-hide="fablabWithoutSpaces">
<h3 ng-show="spacesModule" translate>{{ 'app.admin.plans.edit.spaces' }}</h3>
<table class="table" ng-show="spacesModule">
<thead>
<th translate>{{ 'app.admin.plans.edit.space' }}</th>
<th translate>{{ 'app.admin.plans.edit.hourly_rate' }}</th>

View File

@ -96,11 +96,11 @@
</tbody>
</table>
<h2 ng-hide="fablabWithoutSpaces" class="m-t-lg" translate>{{ 'app.admin.pricing.spaces' }}</h2>
<div ng-hide="fablabWithoutSpaces" class="btn-group m-t-md m-b-md">
<h2 ng-show="spacesModule" class="m-t-lg" translate>{{ 'app.admin.pricing.spaces' }}</h2>
<div ng-show="spacesModule" class="btn-group m-t-md m-b-md">
<button type="button" class="btn btn-warning" ng-click="addSpaceCredit($event)" translate>{{ 'app.admin.pricing.add_a_space_credit' }}</button>
</div>
<table ng-hide="fablabWithoutSpaces" class="table">
<table ng-show="spacesModule" class="table">
<thead>
<tr>
<th style="width:20%" translate>{{ 'app.admin.pricing.space' }}</th>

View File

@ -39,7 +39,7 @@
<ng-include src="'<%= asset_path "admin/pricing/machine_hours.html" %>'"></ng-include>
</uib-tab>
<uib-tab heading="{{ 'app.admin.pricing.spaces' | translate }}" ng-hide="fablabWithoutSpaces" index="3" class="spaces-tab">
<uib-tab heading="{{ 'app.admin.pricing.spaces' | translate }}" ng-show="spacesModule" index="3" class="spaces-tab">
<ng-include src="'<%= asset_path "admin/pricing/spaces.html" %>'"></ng-include>
</uib-tab>

View File

@ -94,7 +94,7 @@
</div>
<button name="button" class="btn btn-warning" ng-click="save(eventExplicationsAlert)" translate>{{ 'app.shared.buttons.save' }}</button>
</div>
<div class="col-md-3" ng-hide="fablabWithoutSpaces">
<div class="col-md-3" ng-show="spacesModule">
<h4 translate>{{ 'app.admin.settings.message_of_the_spaces_page' }}</h4>
<div ng-model="spaceExplicationsAlert.value" medium-editor options='{"placeholder": "{{ "app.admin.settings.type_the_message_content" | translate }}",
"buttons": ["bold", "italic", "unorderedlist", "header2" ]
@ -353,6 +353,7 @@
<span class="font-sbold" translate>{{ 'app.admin.settings.modules' }}</span>
</div>
<div class="panel-body">
<p class="alert alert-info"><i class="fa fa-info-circle m-r"></i><span translate>{{ 'app.admin.settings.remember_to_refresh_the_page_for_the_changes_to_take_effect' }}</span> </p>
<div class="row">
<h3 class="m-l" translate>{{ 'app.admin.settings.spaces' }}</h3>
<p class="alert alert-warning m-h-md" ng-bind-html="'app.admin.settings.spaces_info_html' | translate"></p>

View File

@ -18,7 +18,7 @@
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="m.checked" ng-change="filterAvailabilities(filter)">
</div>
</div>
<div class="m-t" ng-hide="fablabWithoutSpaces">
<div class="m-t" ng-show="spacesModule">
<div class="row">
<h3 class="col-md-11 col-sm-11 col-xs-11 text-cyan" translate>{{ 'app.public.calendar.spaces' }}</h3>
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="filter.spaces" ng-change="toggleFilter('spaces', filter)">

View File

@ -18,7 +18,7 @@ class API::AvailabilitiesController < API::ApiController
@availabilities = @availabilities.where.not(available_type: 'event') unless Setting.get('events_in_calendar')
@availabilities = @availabilities.where.not(available_type: 'space') if fablab_spaces_deactivated?
@availabilities = @availabilities.where.not(available_type: 'space') unless Setting.get('spaces_module')
end
def public

View File

@ -1,9 +1,5 @@
module FablabConfiguration
def fablab_plans_deactivated?
Rails.application.secrets.fablab_without_plans
end
def fablab_spaces_deactivated?
Rails.application.secrets.fablab_without_spaces
end
def fablab_plans_deactivated?
Rails.application.secrets.fablab_without_plans
end
end

View File

@ -111,4 +111,15 @@ class Setting < ApplicationRecord
res
end
##
# Create or update the provided setting with the given value
# Usage: Setting.set('my_setting', true)
# Optionally (but recommended when possible), the user updating the value can be provided as the third parameter
# Eg.: Setting.set('my_setting', true, User.find_by(slug: 'admin'))
##
def self.set(name, value, user = User.admins.first)
setting = find_or_initialize_by(name: name)
setting.save && setting.history_values.create(invoicing_profile: user.invoicing_profile, value: value.to_s)
end
end

View File

@ -40,7 +40,7 @@ class HealthService
availabilities: last_week_availabilities,
reservations: last_week_new_reservations,
plans: !Rails.application.secrets.fablab_without_plans,
spaces: !Rails.application.secrets.fablab_without_spaces,
spaces: Setting.get('spaces_module'),
online_payment: !Rails.application.secrets.fablab_without_online_payments,
invoices: !Rails.application.secrets.fablab_without_invoices,
openlab: Rails.application.secrets.openlab_app_secret.present?

View File

@ -24,7 +24,7 @@
var Fablab = Fablab || {};
Fablab.withoutPlans = ('<%= Rails.application.secrets.fablab_without_plans %>' === 'true');
Fablab.withoutSpaces = ('<%= Rails.application.secrets.fablab_without_spaces %>' !== 'false');
Fablab.spacesModule = ('<%= Setting.get('spaces_module') %>' === 'true');
Fablab.withoutOnlinePayment = ('<%= Rails.application.secrets.fablab_without_online_payments %>' === 'true');
Fablab.withoutInvoices = ('<%= Rails.application.secrets.fablab_without_invoices %>' === 'true');
Fablab.fablabWithoutWallet = ('<%= Rails.application.secrets.fablab_without_wallet %>' === 'true');

View File

@ -72,7 +72,7 @@ wb.add_worksheet(name: t('export_availabilities.trainings')) do |sheet|
end
## Spaces slots
if Rails.application.secrets.fablab_without_spaces != 'false'
if Setting.get('spaces_module')
wb.add_worksheet(name: t('export_availabilities.spaces')) do |sheet|
## data table

View File

@ -1044,6 +1044,7 @@ en:
spaces: "Spaces"
spaces_info_html: "<p>A space can be, for example, a woodshop or a meeting room. Their particularity is that they can be booked by several people at the same time.</p><p><strong>Warning:</strong> It is not recommended to disable spaces if at least one space reservation was made on the system.</p>"
enable_spaces: "Enable the spaces"
spaces_module: "spaces module"
sort_by:
default: "Default"
name: "Name"

View File

@ -1042,8 +1042,9 @@ fr:
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é."
modules: "Modules"
spaces: "Espaces"
spaces_info_html: "<p>Un espace peut-être, par exemple, un atelier bois ou une salle de réunion. Leur particularité est qu'ils peuvent être réservés par plusieurs personnes en même temps.</p><p><strong>Attention :</strong> Il n'est pas recommandé de désactiver les espaces is au moins une réservation est en cours sur un espace.</p>"
spaces_info_html: "<p>Un espace peut-être, par exemple, un atelier bois ou une salle de réunion. Leur particularité est qu'ils peuvent être réservés par plusieurs personnes en même temps.</p><p><strong>Attention :</strong> Il n'est pas recommandé de désactiver les espaces si au moins une réservation est en cours sur un espace.</p>"
enable_spaces: "Activer les espaces"
spaces_module: "module espace"
sort_by:
default: "Défaut"
name: "Nom"

View File

@ -110,6 +110,7 @@ en:
subscription_of_NAME_for_DURATION_starting_from_DATE: "Subscription of %{NAME} for %{DURATION} starting from %{DATE}"
subscription_of_NAME_extended_starting_from_STARTDATE_until_ENDDATE: "Subscription of %{NAME} extended (Free days) starting from %{STARTDATE} until %{ENDDATE}"
and: 'and'
invoice_text_example: "Our association is not subject to VAT"
# CVS accounting export (columns headers)
accounting_export:
journal_code: "Journal code"

View File

@ -110,6 +110,7 @@ fr:
subscription_of_NAME_for_DURATION_starting_from_DATE: "Abonnement de %{NAME} pour %{DURATION} à compter du %{DATE}"
subscription_of_NAME_extended_starting_from_STARTDATE_until_ENDDATE: "Prolongement Abonnement (Jours gratuits) de %{NAME} à compter du %{STARTDATE} jusqu'au %{ENDDATE}"
and: 'et'
invoice_text_example: "Notre association n'est pas assujettie à la TVA"
#CVS accounting export (columns headers)
accounting_export:
journal_code: "Code journal"

View File

@ -17,7 +17,6 @@ development:
stripe_currency: <%= ENV["STRIPE_CURRENCY"] %>
disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %>
fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %>
fablab_without_spaces: <%= ENV["FABLAB_WITHOUT_SPACES"] %>
fablab_without_online_payments: <%= ENV["FABLAB_WITHOUT_ONLINE_PAYMENT"] %>
fablab_without_invoices: <%= ENV["FABLAB_WITHOUT_INVOICES"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
@ -61,7 +60,6 @@ test:
stripe_currency: usd
disqus_shortname: fablab-sleede
fablab_without_plans: false
fablab_without_spaces: false
fablab_without_online_payments: false
fablab_without_invoices: false
fablab_without_wallet: false
@ -105,7 +103,6 @@ staging:
stripe_currency: <%= ENV["STRIPE_CURRENCY"] %>
disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %>
fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %>
fablab_without_spaces: <%= ENV["FABLAB_WITHOUT_SPACES"] %>
fablab_without_online_payments: <%= ENV["FABLAB_WITHOUT_ONLINE_PAYMENT"] %>
fablab_without_invoices: <%= ENV["FABLAB_WITHOUT_INVOICES"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
@ -160,7 +157,6 @@ production:
stripe_currency: <%= ENV["STRIPE_CURRENCY"] %>
disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %>
fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %>
fablab_without_spaces: <%= ENV["FABLAB_WITHOUT_SPACES"] %>
fablab_without_online_payments: <%= ENV["FABLAB_WITHOUT_ONLINE_PAYMENT"] %>
fablab_without_invoices: <%= ENV["FABLAB_WITHOUT_INVOICES"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>

View File

@ -253,11 +253,7 @@ unless Setting.find_by(name: 'about_body').try(:value)
setting.save
end
unless Setting.find_by(name: 'about_title').try(:value)
setting = Setting.find_or_initialize_by(name: 'about_title')
setting.value = 'Imaginer, Fabriquer, <br>Partager avec Fab-manager'
setting.save
end
Setting.set('about_title', 'Imaginer, Fabriquer, <br>Partager avec Fab-manager') unless Setting.find_by(name: 'about_title').try(:value)
unless Setting.find_by(name: 'about_contacts').try(:value)
setting = Setting.find_or_initialize_by(name: 'about_contacts')
@ -276,11 +272,7 @@ unless Setting.find_by(name: 'about_contacts').try(:value)
setting.save
end
unless Setting.find_by(name: 'twitter_name').try(:value)
setting = Setting.find_or_initialize_by(name: 'twitter_name')
setting.value = 'Fab_Manager'
setting.save
end
Setting.set('twitter_name', 'Fab_Manager') unless Setting.find_by(name: 'twitter_name').try(:value)
unless Setting.find_by(name: 'machine_explications_alert').try(:value)
setting = Setting.find_or_initialize_by(name: 'machine_explications_alert')
@ -599,47 +591,19 @@ unless Setting.find_by(name: 'invoice_logo').try(:value)
setting.save
end
unless Setting.find_by(name: 'invoice_reference').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_reference')
setting.value = 'YYMMmmmX[/VL]R[/A]'
setting.save
end
Setting.set('invoice_reference', 'YYMMmmmX[/VL]R[/A]') unless Setting.find_by(name: 'invoice_reference').try(:value)
unless Setting.find_by(name: 'invoice_code-active').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_code-active')
setting.value = 'true'
setting.save
end
Setting.set('invoice_code-active', true) unless Setting.find_by(name: 'invoice_code-active').try(:value)
unless Setting.find_by(name: 'invoice_code-value').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_code-value')
setting.value = 'INMEDFABLAB'
setting.save
end
Setting.set('invoice_code-value', 'FABMGRFABLAB') unless Setting.find_by(name: 'invoice_code-value').try(:value)
unless Setting.find_by(name: 'invoice_order-nb').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_order-nb')
setting.value = 'nnnnnn-MM-YY'
setting.save
end
Setting.set('invoice_order-nb', 'nnnnnn-MM-YY') unless Setting.find_by(name: 'invoice_order-nb').try(:value)
unless Setting.find_by(name: 'invoice_VAT-active').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_VAT-active')
setting.value = 'false'
setting.save
end
Setting.set('invoice_VAT-active', false) unless Setting.find_by(name: 'invoice_VAT-active').try(:value)
unless Setting.find_by(name: 'invoice_VAT-rate').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_VAT-rate')
setting.value = '20.0'
setting.save
end
Setting.set('invoice_VAT-rate', 20.0) unless Setting.find_by(name: 'invoice_VAT-rate').try(:value)
unless Setting.find_by(name: 'invoice_text').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_text')
setting.value = "Notre association n'est pas assujettie à la TVA"
setting.save
end
Setting.set('invoice_text', t('invoices.invoice_text_example')) unless Setting.find_by(name: 'invoice_text').try(:value)
unless Setting.find_by(name: 'invoice_legals').try(:value)
setting = Setting.find_or_initialize_by(name: 'invoice_legals')
@ -651,53 +615,21 @@ unless Setting.find_by(name: 'invoice_legals').try(:value)
setting.save
end
unless Setting.find_by(name: 'booking_window_start').try(:value)
setting = Setting.find_or_initialize_by(name: 'booking_window_start')
setting.value = '1970-01-01 08:00:00'
setting.save
end
Setting.set('booking_window_start', '1970-01-01 08:00:00') unless Setting.find_by(name: 'booking_window_start').try(:value)
unless Setting.find_by(name: 'booking_window_end').try(:value)
setting = Setting.find_or_initialize_by(name: 'booking_window_end')
setting.value = '1970-01-01 23:59:59'
setting.save
end
Setting.set('booking_window_end', '1970-01-01 23:59:59') unless Setting.find_by(name: 'booking_window_end').try(:value)
unless Setting.find_by(name: 'booking_move_enable').try(:value)
setting = Setting.find_or_initialize_by(name: 'booking_move_enable')
setting.value = 'true'
setting.save
end
Setting.set('booking_move_enable', true) unless Setting.find_by(name: 'booking_move_enable').try(:value)
unless Setting.find_by(name: 'booking_move_delay').try(:value)
setting = Setting.find_or_initialize_by(name: 'booking_move_delay')
setting.value = '24'
setting.save
end
Setting.set('booking_move_delay', 24) unless Setting.find_by(name: 'booking_move_delay').try(:value)
unless Setting.find_by(name: 'booking_cancel_enable').try(:value)
setting = Setting.find_or_initialize_by(name: 'booking_cancel_enable')
setting.value = 'false'
setting.save
end
Setting.set('booking_cancel_enable', false) unless Setting.find_by(name: 'booking_cancel_enable').try(:value)
unless Setting.find_by(name: 'booking_cancel_delay').try(:value)
setting = Setting.find_or_initialize_by(name: 'booking_cancel_delay')
setting.value = '24'
setting.save
end
Setting.set('booking_cancel_delay', 24) unless Setting.find_by(name: 'booking_cancel_delay').try(:value)
unless Setting.find_by(name: 'main_color').try(:value)
setting = Setting.find_or_initialize_by(name: 'main_color')
setting.value = '#cb1117'
setting.save
end
Setting.set('main_color', '#cb1117') unless Setting.find_by(name: 'main_color').try(:value)
unless Setting.find_by(name: 'secondary_color').try(:value)
setting = Setting.find_or_initialize_by(name: 'secondary_color')
setting.value = '#ffdd00'
setting.save
end
Setting.set('secondary_color', '#ffdd00') unless Setting.find_by(name: 'secondary_color').try(:value)
Stylesheet.build_theme!
Stylesheet.build_home!
@ -709,17 +641,9 @@ unless Setting.find_by(name: 'training_information_message').try(:value)
setting.save
end
unless Setting.find_by(name: 'fablab_name').try(:value)
setting = Setting.find_or_initialize_by(name: 'fablab_name')
setting.value = 'Fab-manager'
setting.save
end
Setting.set('fablab_name', 'Fab-manager') unless Setting.find_by(name: 'fablab_name').try(:value)
unless Setting.find_by(name: 'name_genre').try(:value)
setting = Setting.find_or_initialize_by(name: 'name_genre')
setting.value = 'male'
setting.save
end
Setting.set('name_genre', 'male') unless Setting.find_by(name: 'name_genre').try(:value)
unless DatabaseProvider.count.positive?
db_provider = DatabaseProvider.new
@ -734,41 +658,17 @@ unless DatabaseProvider.count.positive?
end
end
unless Setting.find_by(name: 'reminder_enable').try(:value)
setting = Setting.find_or_initialize_by(name: 'reminder_enable')
setting.value = 'true'
setting.save
end
Setting.set('reminder_enable', true) unless Setting.find_by(name: 'reminder_enable').try(:value)
unless Setting.find_by(name: 'reminder_delay').try(:value)
setting = Setting.find_or_initialize_by(name: 'reminder_delay')
setting.value = '24'
setting.save
end
Setting.set('reminder_delay', 24) unless Setting.find_by(name: 'reminder_delay').try(:value)
unless Setting.find_by(name: 'visibility_yearly').try(:value)
setting = Setting.find_or_initialize_by(name: 'visibility_yearly')
setting.value = '3'
setting.save
end
Setting.set('visibility_yearly', 3) unless Setting.find_by(name: 'visibility_yearly').try(:value)
unless Setting.find_by(name: 'visibility_others').try(:value)
setting = Setting.find_or_initialize_by(name: 'visibility_others')
setting.value = '1'
setting.save
end
Setting.set('visibility_others', 1) unless Setting.find_by(name: 'visibility_others').try(:value)
unless Setting.find_by(name: 'display_name_enable').try(:value)
setting = Setting.find_or_initialize_by(name: 'display_name_enable')
setting.value = 'false'
setting.save
end
Setting.set('display_name_enable', false) unless Setting.find_by(name: 'display_name_enable').try(:value)
unless Setting.find_by(name: 'machines_sort_by').try(:value)
setting = Setting.find_or_initialize_by(name: 'machines_sort_by')
setting.value = 'default'
setting.save
end
Setting.set('machines_sort_by', 'default') unless Setting.find_by(name: 'machines_sort_by').try(:value)
unless Setting.find_by(name: 'privacy_draft').try(:value)
setting = Setting.find_or_initialize_by(name: 'privacy_draft')
@ -909,11 +809,7 @@ unless Setting.find_by(name: 'privacy_draft').try(:value)
setting.save
end
unless Setting.find_by(name: 'fab_analytics').try(:value)
setting = Setting.find_or_initialize_by(name: 'fab_analytics')
setting.value = 'true'
setting.save
end
Setting.set('fab_analytics', true) unless Setting.find_by(name: 'fab_analytics').try(:value)
unless Setting.find_by(name: 'link_name').try(:value)
include ApplicationHelper # rubocop:disable Style/MixinUsage
@ -951,11 +847,9 @@ 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
Setting.set('slot_duration', 60) unless Setting.find_by(name: 'slot_duration').try(:value)
Setting.set('spaces_module', false) unless Setting.find_by(name: 'spaces_module').try(:value)
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines

View File

@ -87,12 +87,6 @@ The PDF file name will be of the form "(INVOICE_PREFIX) - (invoice ID) _ (invoic
If set to 'true', the subscription plans will be fully disabled and invisible in the application.
It is not recommended to disable plans if at least one subscription was took on the platform.
<a name="FABLAB_WITHOUT_SPACES"></a>
FABLAB_WITHOUT_SPACES
If set to 'false', enable the spaces management and reservation in the application.
It is not recommended to disable spaces if at least one space reservation was made on the system.
<a name="FABLAB_WITHOUT_ONLINE_PAYMENT"></a>
FABLAB_WITHOUT_ONLINE_PAYMENT

View File

@ -17,7 +17,6 @@ INVOICE_PREFIX=Demo-FabLab_facture
# FabLab optional modules
FABLAB_WITHOUT_PLANS=false
FABLAB_WITHOUT_SPACES=true
FABLAB_WITHOUT_ONLINE_PAYMENT=false
FABLAB_WITHOUT_INVOICES=false
PHONE_REQUIRED=true

View File

@ -111,7 +111,7 @@ namespace :fablab do
%w[_ BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true],
%w[_ SLOT_DURATION slot_duration 60],
%w[_ EVENTS_IN_CALENDAR events_in_calendar false],
%w[! FABLAB_WITHOUT_SPACES spaces_module]
%w[! FABLAB_WITHOUT_SPACES spaces_module true]
]
mapping.each do |m|

View File

@ -10,7 +10,6 @@ STRIPE_CURRENCY=eur
INVOICE_PREFIX=Demo-FabLab_facture
FABLAB_WITHOUT_PLANS=false
FABLAB_WITHOUT_SPACES=false
FABLAB_WITHOUT_ONLINE_PAYMENT=false
FABLAB_WITHOUT_INVOICES=false
PHONE_REQUIRED=false

View File

@ -234,7 +234,7 @@ configure_env_file()
local doc variables secret
doc=$(\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/doc/environment.md)
variables=(STRIPE_API_KEY STRIPE_PUBLISHABLE_KEY STRIPE_CURRENCY INVOICE_PREFIX FABLAB_WITHOUT_PLANS FABLAB_WITHOUT_SPACES FABLAB_WITHOUT_ONLINE_PAYMENT FABLAB_WITHOUT_INVOICES FABLAB_WITHOUT_WALLET \
variables=(STRIPE_API_KEY STRIPE_PUBLISHABLE_KEY STRIPE_CURRENCY INVOICE_PREFIX FABLAB_WITHOUT_PLANS FABLAB_WITHOUT_ONLINE_PAYMENT FABLAB_WITHOUT_INVOICES FABLAB_WITHOUT_WALLET \
USER_CONFIRMATION_NEEDED_TO_SIGN_IN DEFAULT_MAIL_FROM DELIVERY_METHOD DEFAULT_HOST DEFAULT_PROTOCOL SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS RECAPTCHA_SITE_KEY RECAPTCHA_SECRET_KEY DISQUS_SHORTNAME TWITTER_NAME \
FACEBOOK_APP_ID LOG_LEVEL ALLOWED_EXTENSIONS ALLOWED_MIME_TYPES MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT FEATURE_TOUR_DISPLAY \

View File

@ -44,7 +44,7 @@ module Availabilities
test 'get calendar availabilities without spaces' do
# disable spaces in application
Rails.application.secrets.fablab_without_spaces = true
Setting.set('spaces_module', false)
# this simulates a fullCalendar (v2) call
start_date = DateTime.current.utc.strftime('%Y-%m-%d')
@ -63,8 +63,8 @@ module Availabilities
assert_not availabilities.map { |a| a[:available_type] }.include?('space'), 'unexpected space availability instead that it was disabled'
# re-enable spaces to keep tests ENV-safe
Rails.application.secrets.fablab_without_spaces = false
# re-enable spaces
Setting.set('spaces_module', true)
end
test 'get calendar availabilities with spaces' do