From 23b98512186607ae5aa020b633c3e1592db59bb4 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 15 Feb 2017 15:41:25 +0100 Subject: [PATCH] allow enable/disable spaces -> disabled by default --- CHANGELOG.md | 1 + README.md | 22 ++++++++++------- app/assets/javascripts/app.js.erb | 2 ++ .../controllers/admin/statistics.coffee.erb | 19 ++++++++++++++- .../controllers/main_nav.coffee.erb | 24 +++++++++++-------- app/assets/javascripts/router.coffee.erb | 4 ++++ .../admin/calendar/calendar.html.erb | 8 +++---- .../templates/admin/settings/general.html | 2 +- .../templates/admin/statistics/index.html.erb | 2 +- .../api/availabilities_controller.rb | 6 +++++ .../concerns/fablab_configuration.rb | 4 ++++ app/views/application/index.html.erb | 1 + config/application.yml.default | 1 + config/secrets.yml | 4 ++++ docker/env.example | 1 + 15 files changed, 76 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 236be1221..ca033f3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - TODO bug: delete event (github#61) - ONGOING spaces reservation - [TODO DEPLOY] `rake db:migrate`, then `rake db:seed` +- [TODO DEPLOY] add the `FABLAB_WITHOUT_SPACES` environment variable ## v2.4.10 2017 January 9 diff --git a/README.md b/README.md index 2a08d7572..a45bb2c2c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ FabManager is the FabLab management solution. It is web-based, open-source and totally free. -##### Table of Contents +##### Table of Contents 1. [Software stack](#software-stack) 2. [Contributing](#contributing) 3. [Setup a production environment](#setup-a-production-environment) @@ -198,6 +198,12 @@ The PDF file name will be of the form "(INVOICE_PREFIX) - (invoice ID) _ (invoic FABLAB_WITHOUT_PLANS 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. + + 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. DEFAULT_MAIL_FROM @@ -261,7 +267,7 @@ Please consider that allowing file archives (eg. application/zip) or binary exec MAX_IMAGE_SIZE -Maximum size (in bytes) allowed for image uploaded on the platform. +Maximum size (in bytes) allowed for image uploaded on the platform. This parameter concerns events, plans, user's avatars, projects and steps of projects. If this parameter is not specified the maximum size allowed will be 2MB. @@ -683,12 +689,12 @@ Developers may find information on how to implement their own authentication pro - When running the tests suite with `rake test`, all tests may fail with errors similar to the following: Error: - ... - ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "..." violates foreign key constraint "fk_rails_..." - DETAIL: Key (group_id)=(1) is not present in table "groups". - : ... - test_after_commit (1.0.0) lib/test_after_commit/database_statements.rb:11:in `block in transaction' - test_after_commit (1.0.0) lib/test_after_commit/database_statements.rb:5:in `transaction' + ... + ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "..." violates foreign key constraint "fk_rails_..." + DETAIL: Key (group_id)=(1) is not present in table "groups". + : ... + test_after_commit (1.0.0) lib/test_after_commit/database_statements.rb:11:in `block in transaction' + test_after_commit (1.0.0) lib/test_after_commit/database_statements.rb:5:in `transaction' This is due to an ActiveRecord behavior witch disable referential integrity in PostgreSQL to load the fixtures. PostgreSQL will prevent any users to disable referential integrity on the fly if they doesn't have the `SUPERUSER` role. diff --git a/app/assets/javascripts/app.js.erb b/app/assets/javascripts/app.js.erb index d363714d0..7049d79b8 100644 --- a/app/assets/javascripts/app.js.erb +++ b/app/assets/javascripts/app.js.erb @@ -80,6 +80,8 @@ config(['$httpProvider', 'AuthProvider', "growlProvider", "unsavedWarningsConfig // 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 function to allow the user to navigate to the previous screen (ie. $state). // If no previous $state were recorded, navigate to the home page diff --git a/app/assets/javascripts/controllers/admin/statistics.coffee.erb b/app/assets/javascripts/controllers/admin/statistics.coffee.erb index b99297b21..834cae4db 100644 --- a/app/assets/javascripts/controllers/admin/statistics.coffee.erb +++ b/app/assets/javascripts/controllers/admin/statistics.coffee.erb @@ -144,7 +144,7 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state", ## # Callback called when the active tab is changed. # recover the current tab and store its value in $scope.selectedIndex - # @param tab {Object} elasticsearch statistic structure + # @param tab {Object} elasticsearch statistic structure (from statistic_indices table) ## $scope.setActiveTab = (tab) -> $scope.selectedIndex = tab @@ -160,6 +160,23 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state", + ## + # Returns true if the provided tab must be hidden due to some global or local configuration + # @param tab {Object} elasticsearch statistic structure (from statistic_indices table) + ## + $scope.hiddenTab = (tab) -> + if tab.table + if tab.es_type_key == 'subscription' && $rootScope.fablabWithoutPlans + true + else if tab.es_type_key == 'space' && $rootScope.fablabWithoutSpaces + true + else + false + else + true + + + ## # Callback to validate the filters and send a new request to elastic ## diff --git a/app/assets/javascripts/controllers/main_nav.coffee.erb b/app/assets/javascripts/controllers/main_nav.coffee.erb index c0ff2415f..900da09c2 100644 --- a/app/assets/javascripts/controllers/main_nav.coffee.erb +++ b/app/assets/javascripts/controllers/main_nav.coffee.erb @@ -28,11 +28,6 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location", linkText: 'events_registrations' linkIcon: 'tags' } - { - state: 'app.public.spaces_list' - linkText: 'reserve_a_space' - linkIcon: 'rocket' - } { state: 'app.public.calendar' linkText: 'public_calendar' @@ -53,6 +48,13 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location", linkIcon: 'credit-card' }) + unless Fablab.withoutSpaces + $scope.navLinks.splice(5, 0, { + state: 'app.public.spaces_list' + linkText: 'reserve_a_space' + linkIcon: 'rocket' + }) + Fablab.adminNavLinks = Fablab.adminNavLinks || [] adminNavLinks = [ @@ -91,11 +93,6 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location", linkText: 'manage_the_machines' linkIcon: 'cogs' } - { - state: 'app.public.spaces_list' - linkText: 'manage_the_spaces' - linkIcon: 'rocket' - } { state: 'app.admin.project_elements' linkText: 'manage_the_projects_elements' @@ -119,4 +116,11 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location", ].concat(Fablab.adminNavLinks) $scope.adminNavLinks = adminNavLinks + + unless Fablab.withoutSpaces + $scope.adminNavLinks.splice(8, 0, { + state: 'app.public.spaces_list' + linkText: 'manage_the_spaces' + linkIcon: 'rocket' + }) ] diff --git a/app/assets/javascripts/router.coffee.erb b/app/assets/javascripts/router.coffee.erb index 9bd025dff..7179a1da2 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -392,6 +392,7 @@ angular.module('application.router', ['ui.router']). # spaces .state 'app.public.spaces_list', url: '/spaces' + abstract: Fablab.withoutSpaces views: 'main@': templateUrl: '<%= asset_path "spaces/index.html" %>' @@ -405,6 +406,7 @@ angular.module('application.router', ['ui.router']). ] .state 'app.admin.space_new', url: '/spaces/new' + abstract: Fablab.withoutSpaces views: 'main@': templateUrl: '<%= asset_path "spaces/new.html" %>' @@ -415,6 +417,7 @@ angular.module('application.router', ['ui.router']). ] .state 'app.public.space_show', url: '/spaces/:id' + abstract: Fablab.withoutSpaces views: 'main@': templateUrl: '<%= asset_path "spaces/show.html" %>' @@ -428,6 +431,7 @@ angular.module('application.router', ['ui.router']). ] .state 'app.admin.space_edit', url: '/spaces/:id/edit' + abstract: Fablab.withoutSpaces views: 'main@': templateUrl: '<%= asset_path "spaces/edit.html" %>' diff --git a/app/assets/templates/admin/calendar/calendar.html.erb b/app/assets/templates/admin/calendar/calendar.html.erb index 76ccce856..d0cd22ffc 100644 --- a/app/assets/templates/admin/calendar/calendar.html.erb +++ b/app/assets/templates/admin/calendar/calendar.html.erb @@ -12,10 +12,10 @@
-
- {{ 'admin_calendar.trainings' }}
- {{ 'admin_calendar.machines' }}
- {{ 'admin_calendar.spaces' }} +
+ {{ 'admin_calendar.trainings' }}
+ {{ 'admin_calendar.machines' }}
+ {{ 'admin_calendar.spaces' }}
diff --git a/app/assets/templates/admin/settings/general.html b/app/assets/templates/admin/settings/general.html index fc4aae90e..33b459eb7 100644 --- a/app/assets/templates/admin/settings/general.html +++ b/app/assets/templates/admin/settings/general.html @@ -85,7 +85,7 @@ -
+

{{ 'settings.message_of_the_spaces_page' }}

+