1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-21 15:54:22 +01:00

allow enable/disable spaces -> disabled by default

This commit is contained in:
Sylvain 2017-02-15 15:41:25 +01:00
parent 69130a1309
commit 23b9851218
15 changed files with 76 additions and 25 deletions

View File

@ -6,6 +6,7 @@
- TODO bug: delete event (github#61) - TODO bug: delete event (github#61)
- ONGOING spaces reservation - ONGOING spaces reservation
- [TODO DEPLOY] `rake db:migrate`, then `rake db:seed` - [TODO DEPLOY] `rake db:migrate`, then `rake db:seed`
- [TODO DEPLOY] add the `FABLAB_WITHOUT_SPACES` environment variable
## v2.4.10 2017 January 9 ## v2.4.10 2017 January 9

View File

@ -198,6 +198,12 @@ The PDF file name will be of the form "(INVOICE_PREFIX) - (invoice ID) _ (invoic
FABLAB_WITHOUT_PLANS FABLAB_WITHOUT_PLANS
If set to 'true', the subscription plans will be fully disabled and invisible in the application. 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 DEFAULT_MAIL_FROM

View File

@ -80,6 +80,8 @@ config(['$httpProvider', 'AuthProvider', "growlProvider", "unsavedWarningsConfig
// Global config: if true, the whole 'Plans & Subscriptions' feature will be disabled in the application // Global config: if true, the whole 'Plans & Subscriptions' feature will be disabled in the application
$rootScope.fablabWithoutPlans = Fablab.withoutPlans; $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). // 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 // If no previous $state were recorded, navigate to the home page

View File

@ -144,7 +144,7 @@ Application.Controllers.controller "StatisticsController", ["$scope", "$state",
## ##
# Callback called when the active tab is changed. # Callback called when the active tab is changed.
# recover the current tab and store its value in $scope.selectedIndex # 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.setActiveTab = (tab) ->
$scope.selectedIndex = 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 # Callback to validate the filters and send a new request to elastic
## ##

View File

@ -28,11 +28,6 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location",
linkText: 'events_registrations' linkText: 'events_registrations'
linkIcon: 'tags' linkIcon: 'tags'
} }
{
state: 'app.public.spaces_list'
linkText: 'reserve_a_space'
linkIcon: 'rocket'
}
{ {
state: 'app.public.calendar' state: 'app.public.calendar'
linkText: 'public_calendar' linkText: 'public_calendar'
@ -53,6 +48,13 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location",
linkIcon: 'credit-card' 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 || [] Fablab.adminNavLinks = Fablab.adminNavLinks || []
adminNavLinks = [ adminNavLinks = [
@ -91,11 +93,6 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location",
linkText: 'manage_the_machines' linkText: 'manage_the_machines'
linkIcon: 'cogs' linkIcon: 'cogs'
} }
{
state: 'app.public.spaces_list'
linkText: 'manage_the_spaces'
linkIcon: 'rocket'
}
{ {
state: 'app.admin.project_elements' state: 'app.admin.project_elements'
linkText: 'manage_the_projects_elements' linkText: 'manage_the_projects_elements'
@ -119,4 +116,11 @@ Application.Controllers.controller "MainNavController", ["$scope", "$location",
].concat(Fablab.adminNavLinks) ].concat(Fablab.adminNavLinks)
$scope.adminNavLinks = adminNavLinks $scope.adminNavLinks = adminNavLinks
unless Fablab.withoutSpaces
$scope.adminNavLinks.splice(8, 0, {
state: 'app.public.spaces_list'
linkText: 'manage_the_spaces'
linkIcon: 'rocket'
})
] ]

View File

@ -392,6 +392,7 @@ angular.module('application.router', ['ui.router']).
# spaces # spaces
.state 'app.public.spaces_list', .state 'app.public.spaces_list',
url: '/spaces' url: '/spaces'
abstract: Fablab.withoutSpaces
views: views:
'main@': 'main@':
templateUrl: '<%= asset_path "spaces/index.html" %>' templateUrl: '<%= asset_path "spaces/index.html" %>'
@ -405,6 +406,7 @@ angular.module('application.router', ['ui.router']).
] ]
.state 'app.admin.space_new', .state 'app.admin.space_new',
url: '/spaces/new' url: '/spaces/new'
abstract: Fablab.withoutSpaces
views: views:
'main@': 'main@':
templateUrl: '<%= asset_path "spaces/new.html" %>' templateUrl: '<%= asset_path "spaces/new.html" %>'
@ -415,6 +417,7 @@ angular.module('application.router', ['ui.router']).
] ]
.state 'app.public.space_show', .state 'app.public.space_show',
url: '/spaces/:id' url: '/spaces/:id'
abstract: Fablab.withoutSpaces
views: views:
'main@': 'main@':
templateUrl: '<%= asset_path "spaces/show.html" %>' templateUrl: '<%= asset_path "spaces/show.html" %>'
@ -428,6 +431,7 @@ angular.module('application.router', ['ui.router']).
] ]
.state 'app.admin.space_edit', .state 'app.admin.space_edit',
url: '/spaces/:id/edit' url: '/spaces/:id/edit'
abstract: Fablab.withoutSpaces
views: views:
'main@': 'main@':
templateUrl: '<%= asset_path "spaces/edit.html" %>' templateUrl: '<%= asset_path "spaces/edit.html" %>'

View File

@ -12,10 +12,10 @@
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-3 b-t hide-b-md"> <div class="col-xs-12 col-sm-12 col-md-3 b-t hide-b-md">
<section class="heading-actions wrapper p-s"> <section class="heading-actions wrapper" ng-class="{'p-s': !fablabWithoutSpaces}">
<span class="badge text-sm bg-formation" translate>{{ 'admin_calendar.trainings' }}</span><br> <span class="badge text-sm bg-formation" ng-class="{'m-t-sm': fablabWithoutSpaces}" translate>{{ 'admin_calendar.trainings' }}</span><br>
<span class="badge text-sm bg-machine" translate>{{ 'admin_calendar.machines' }}</span><br> <span class="badge text-sm bg-machine" translate>{{ 'admin_calendar.machines' }}</span><br>
<span class="badge text-sm bg-space" translate>{{ 'admin_calendar.spaces' }}</span> <span class="badge text-sm bg-space" ng-hide="fablabWithoutSpaces" translate>{{ 'admin_calendar.spaces' }}</span>
</section> </section>
</div> </div>

View File

@ -85,7 +85,7 @@
</div> </div>
<button name="button" class="btn btn-warning" ng-click="save(eventExplicationsAlert)" translate>{{ 'save' }}</button> <button name="button" class="btn btn-warning" ng-click="save(eventExplicationsAlert)" translate>{{ 'save' }}</button>
</div> </div>
<div class="col-md-3"> <div class="col-md-3" ng-hide="fablabWithoutSpaces">
<h4 translate>{{ 'settings.message_of_the_spaces_page' }}</h4> <h4 translate>{{ 'settings.message_of_the_spaces_page' }}</h4>
<div ng-model="spaceExplicationsAlert.value" medium-editor options='{"placeholder": "{{ "settings.type_the_message_content" | translate }}", <div ng-model="spaceExplicationsAlert.value" medium-editor options='{"placeholder": "{{ "settings.type_the_message_content" | translate }}",
"buttons": ["bold", "italic", "unorderedlist", "header2" ] "buttons": ["bold", "italic", "unorderedlist", "header2" ]

View File

@ -26,7 +26,7 @@
<div class="col-md-12"> <div class="col-md-12">
<uib-tabset justified="true"> <uib-tabset justified="true">
<uib-tab ng-repeat="stat in statistics" heading="{{stat.label}}" select="setActiveTab(stat)" ng-if="stat.table && !(stat.es_type_key == 'subscription' && fablabWithoutPlans)"> <uib-tab ng-repeat="stat in statistics" heading="{{stat.label}}" select="setActiveTab(stat)" ng-hide="hiddenTab(stat)">
<form id="filters_form" name="filters_form" class="form-inline m-t-md m-b-lg" novalidate="novalidate"> <form id="filters_form" name="filters_form" class="form-inline m-t-md m-b-lg" novalidate="novalidate">
<div id="agePickerPane" class="form-group datepicker-container" style="z-index:102;"> <div id="agePickerPane" class="form-group datepicker-container" style="z-index:102;">
<button id="agePickerExpand" class="btn btn-default" type="button" ng-click="agePicker.show = !agePicker.show"> <button id="agePickerExpand" class="btn btn-default" type="button" ng-click="agePicker.show = !agePicker.show">

View File

@ -1,4 +1,6 @@
class API::AvailabilitiesController < API::ApiController class API::AvailabilitiesController < API::ApiController
include FablabConfiguration
before_action :authenticate_user!, except: [:public] before_action :authenticate_user!, except: [:public]
before_action :set_availability, only: [:show, :update, :destroy, :reservations] before_action :set_availability, only: [:show, :update, :destroy, :reservations]
respond_to :json respond_to :json
@ -12,6 +14,10 @@ class API::AvailabilitiesController < API::ApiController
end_date = ActiveSupport::TimeZone[params[:timezone]].parse(params[:end]).end_of_day end_date = ActiveSupport::TimeZone[params[:timezone]].parse(params[:end]).end_of_day
@availabilities = Availability.includes(:machines, :tags, :trainings, :spaces).where.not(available_type: 'event') @availabilities = Availability.includes(:machines, :tags, :trainings, :spaces).where.not(available_type: 'event')
.where('start_at >= ? AND end_at <= ?', start_date, end_date) .where('start_at >= ? AND end_at <= ?', start_date, end_date)
if fablab_spaces_deactivated?
@availabilities = @availabilities.where.not(available_type: 'space')
end
end end
def public def public

View File

@ -2,4 +2,8 @@ module FablabConfiguration
def fablab_plans_deactivated? def fablab_plans_deactivated?
Rails.application.secrets.fablab_without_plans Rails.application.secrets.fablab_without_plans
end end
def fablab_spaces_deactivated?
Rails.application.secrets.fablab_without_spaces
end
end end

View File

@ -24,6 +24,7 @@
var Fablab = Fablab || {}; var Fablab = Fablab || {};
Fablab.withoutPlans = ('<%= Rails.application.secrets.fablab_without_plans %>' == 'true'); Fablab.withoutPlans = ('<%= Rails.application.secrets.fablab_without_plans %>' == 'true');
Fablab.withoutSpaces = ('<%= Rails.application.secrets.fablab_without_spaces %>' == 'true');
Fablab.disqusShortname = "<%= Rails.application.secrets.disqus_shortname %>"; Fablab.disqusShortname = "<%= Rails.application.secrets.disqus_shortname %>";
Fablab.defaultHost = "<%= Rails.application.secrets.default_host %>"; Fablab.defaultHost = "<%= Rails.application.secrets.default_host %>";
Fablab.gaId = "<%= Rails.application.secrets.google_analytics_id %>"; Fablab.gaId = "<%= Rails.application.secrets.google_analytics_id %>";

View File

@ -12,6 +12,7 @@ STRIPE_CURRENCY: 'eur'
INVOICE_PREFIX: Demo-FabLab-facture INVOICE_PREFIX: Demo-FabLab-facture
FABLAB_WITHOUT_PLANS: 'false' FABLAB_WITHOUT_PLANS: 'false'
FABLAB_WITHOUT_SPACES: 'true'
DEFAULT_MAIL_FROM: Fab Manager Demo <noreply@fab-manager.com> DEFAULT_MAIL_FROM: Fab Manager Demo <noreply@fab-manager.com>

View File

@ -17,6 +17,7 @@ development:
stripe_currency: <%= ENV["STRIPE_CURRENCY"] %> stripe_currency: <%= ENV["STRIPE_CURRENCY"] %>
disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %> disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %>
fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %> fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %>
fablab_without_spaces: <%= ENV["FABLAB_WITHOUT_SPACES"] %>
default_host: <%= ENV["DEFAULT_HOST"] %> default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: <%= ENV["TIME_ZONE"] %> time_zone: <%= ENV["TIME_ZONE"] %>
@ -48,6 +49,7 @@ test:
stripe_currency: usd stripe_currency: usd
disqus_shortname: fablab-sleede disqus_shortname: fablab-sleede
fablab_without_plans: false fablab_without_plans: false
fablab_without_spaces: false
default_host: <%= ENV["DEFAULT_HOST"] %> default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: Paris time_zone: Paris
@ -79,6 +81,7 @@ staging:
stripe_currency: <%= ENV["STRIPE_CURRENCY"] %> stripe_currency: <%= ENV["STRIPE_CURRENCY"] %>
disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %> disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %>
fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %> fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %>
fablab_without_spaces: <%= ENV["FABLAB_WITHOUT_SPACES"] %>
default_host: <%= ENV["DEFAULT_HOST"] %> default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %> delivery_method: <%= ENV['DELIVERY_METHOD'] %>
@ -117,6 +120,7 @@ production:
stripe_currency: <%= ENV["STRIPE_CURRENCY"] %> stripe_currency: <%= ENV["STRIPE_CURRENCY"] %>
disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %> disqus_shortname: <%= ENV["DISQUS_SHORTNAME"] %>
fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %> fablab_without_plans: <%= ENV["FABLAB_WITHOUT_PLANS"] %>
fablab_without_spaces: <%= ENV["FABLAB_WITHOUT_SPACES"] %>
default_host: <%= ENV["DEFAULT_HOST"] %> default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %> default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %> delivery_method: <%= ENV['DELIVERY_METHOD'] %>

View File

@ -10,6 +10,7 @@ STRIPE_CURRENCY=eur
INVOICE_PREFIX=Demo-FabLab-facture INVOICE_PREFIX=Demo-FabLab-facture
FABLAB_WITHOUT_PLANS=false FABLAB_WITHOUT_PLANS=false
FABLAB_WITHOUT_SPACES=true
DEFAULT_MAIL_FROM=Fab Manager Demo <noreply@fab-manager.com> DEFAULT_MAIL_FROM=Fab Manager Demo <noreply@fab-manager.com>
DEFAULT_HOST=demo.fab-manager.com DEFAULT_HOST=demo.fab-manager.com