1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-17 11: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)
- 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

View File

@ -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.

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

View File

@ -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
##

View File

@ -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'
})
]

View File

@ -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" %>'

View File

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

View File

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

View File

@ -26,7 +26,7 @@
<div class="col-md-12">
<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">
<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">

View File

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

View File

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

View File

@ -24,6 +24,7 @@
var Fablab = Fablab || {};
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.defaultHost = "<%= Rails.application.secrets.default_host %>";
Fablab.gaId = "<%= Rails.application.secrets.google_analytics_id %>";

View File

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

View File

@ -17,6 +17,7 @@ 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"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: <%= ENV["TIME_ZONE"] %>
@ -48,6 +49,7 @@ test:
stripe_currency: usd
disqus_shortname: fablab-sleede
fablab_without_plans: false
fablab_without_spaces: false
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: Paris
@ -79,6 +81,7 @@ 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"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %>
@ -117,6 +120,7 @@ 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"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %>

View File

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