1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

configure wallet from UI

This commit is contained in:
Sylvain 2020-06-15 12:44:43 +02:00
parent f46c78a476
commit 42872ab107
20 changed files with 49 additions and 31 deletions

View File

@ -81,9 +81,6 @@ angular.module('application', ['ngCookies', 'ngResource', 'ngSanitize', 'ui.rout
$state.prevParams = fromParams;
});
// Global config: if true, wallet will be disabled
$rootScope.fablabWithoutWallet = Fablab.fablabWithoutWallet;
// 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
$rootScope.backPrevLocation = function (event) {

View File

@ -37,7 +37,7 @@ angular.module('application.router', ['ui.router'])
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; }],
modulesPromise: ['Setting', function (Setting) { return Setting.query({ names: "['spaces_module', 'plans_module', 'invoicing_module']" }).$promise; }]
modulesPromise: ['Setting', function (Setting) { return Setting.query({ names: "['spaces_module', 'plans_module', 'invoicing_module', 'wallet_module']" }).$promise; }]
},
onEnter: ['$rootScope', 'logoFile', 'logoBlackFile', 'modulesPromise', 'CSRF', function ($rootScope, logoFile, logoBlackFile, modulesPromise, CSRF) {
// Retrieve Anti-CSRF tokens from cookies
@ -49,6 +49,7 @@ angular.module('application.router', ['ui.router'])
spaces: (modulesPromise.spaces_module === 'true'),
plans: (modulesPromise.plans_module === 'true'),
invoicing: (modulesPromise.invoicing_module === 'true'),
wallet: (modulesPromise.wallet_module === 'true'),
};
}]
})
@ -205,6 +206,7 @@ angular.module('application.router', ['ui.router'])
})
.state('app.logged.dashboard.wallet', {
url: '/wallet',
abstract: !Fablab.walletModule,
views: {
'main@': {
templateUrl: '<%= asset_path "dashboard/wallet.html" %>',
@ -1033,7 +1035,7 @@ angular.module('application.router', ['ui.router'])
'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', 'feature_tour_display', \
'booking_cancel_delay', 'main_color', 'secondary_color', 'spaces_module', 'twitter_analytics', \
'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', 'confirmation_required', \
'reminder_delay', 'visibility_yearly', 'visibility_others', \
'reminder_delay', 'visibility_yearly', 'visibility_others', 'wallet_module', \
'display_name_enable', 'machines_sort_by', 'fab_analytics', \
'link_name', 'home_content', 'home_css', 'phone_required']` }).$promise;
}],

View File

@ -229,7 +229,7 @@
</div>
</uib-tab>
<uib-tab heading="{{ 'app.admin.members_edit.wallet' | translate }}" ng-hide="fablabWithoutWallet">
<uib-tab heading="{{ 'app.admin.members_edit.wallet' | translate }}" ng-show="modules.wallet">
<div class="col-md-12 m m-t-lg">
<ng-include src="'<%= asset_path "wallet/show.html" %>'"></ng-include>

View File

@ -475,5 +475,15 @@
yes-label="app.shared.buttons.yes"
no-label="app.shared.buttons.no"></boolean-setting>
</div>
<div class="row">
<h3 class="m-l" translate>{{ 'app.admin.settings.general.wallet' }}</h3>
<p class="alert alert-warning m-h-md" ng-bind-html="'app.admin.settings.general.wallet_info_html' | translate"></p>
<boolean-setting name="wallet_module"
settings="allSettings"
label="app.admin.settings.general.enable_wallet"
classes="m-l"
yes-label="app.shared.buttons.yes"
no-label="app.shared.buttons.no"></boolean-setting>
</div>
</div>
</div>

View File

@ -16,7 +16,7 @@
<li ui-sref-active="active"><a class="text-black" href="#" ui-sref="app.logged.dashboard.trainings" translate>{{ 'app.public.common.my_trainings' }}</a></li>
<li ui-sref-active="active"><a class="text-black" href="#" ui-sref="app.logged.dashboard.events" translate>{{ 'app.public.common.my_events' }}</a></li>
<li ui-sref-active="active" ng-show="modules.invoicing"><a class="text-black" href="#" ui-sref="app.logged.dashboard.invoices" translate>{{ 'app.public.common.my_invoices' }}</a></li>
<li ng-hide="fablabWithoutWallet" ui-sref-active="active"><a class="text-black" href="#" ui-sref="app.logged.dashboard.wallet" translate>{{ 'app.public.common.my_wallet' }}</a></li>
<li ng-show="modules.wallet" ui-sref-active="active"><a class="text-black" href="#" ui-sref="app.logged.dashboard.wallet" translate>{{ 'app.public.common.my_wallet' }}</a></li>
</ul>
</section>
</div>

View File

@ -39,7 +39,7 @@
<li><a ui-sref="app.logged.dashboard.trainings" translate>{{ 'app.public.common.my_trainings' }}</a></li>
<li><a ui-sref="app.logged.dashboard.events" translate>{{ 'app.public.common.my_events' }}</a></li>
<li><a ui-sref="app.logged.dashboard.invoices" ng-show="modules.invoicing" translate>{{ 'app.public.common.my_invoices' }}</a></li>
<li ng-hide="fablabWithoutWallet"><a ui-sref="app.logged.dashboard.wallet" translate>{{ 'app.public.common.my_wallet' }}</a></li>
<li ng-show="modules.wallet"><a ui-sref="app.logged.dashboard.wallet" translate>{{ 'app.public.common.my_wallet' }}</a></li>
<li class="divider" ng-if="isAuthorized(['admin', 'manager'])"></li>
<li><a class="text-black pointer" ng-click="help($event)" ng-if="isAuthorized(['admin', 'manager'])"><i class="fa fa-question-circle"></i> <span translate>{{ 'app.public.common.help' }}</span> </a></li>
<li class="divider"></li>

View File

@ -18,7 +18,7 @@ class API::WalletController < API::ApiController
end
def credit
return head 422 if Rails.application.secrets.fablab_without_wallet == 'true'
return head 422 unless Setting.get('wallet_module')
@wallet = Wallet.find(credit_params[:id])
authorize @wallet

View File

@ -101,7 +101,8 @@ class Setting < ApplicationRecord
stripe_secret_key
stripe_currency
invoice_prefix
confirmation_required] }
confirmation_required
wallet_module] }
# 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

@ -25,7 +25,7 @@
Fablab.plansModule = ('<%= Setting.get('plans_module') %>' === 'true');
Fablab.spacesModule = ('<%= Setting.get('spaces_module') %>' === 'true');
Fablab.fablabWithoutWallet = ('<%= Rails.application.secrets.fablab_without_wallet %>' === 'true');
Fablab.walletModule = ('<%= Setting.get('wallet_module') %>' === 'true');
Fablab.defaultHost = "<%= Rails.application.secrets.default_host %>";
Fablab.trackingId = "<%= Setting.get('tracking_id') %>";
Fablab.superadminId = parseInt("<%= User.superadmin&.id %>", 10);

View File

@ -1109,6 +1109,7 @@ en:
account_confirmation: "Account confirmation"
confirmation_required_info: "Optionally, you can force the users to confirm their email address before being able to access Fab-manager."
confirmation_is_required: "Confirmation required"
wallet_module: "wallet module"
general:
general: "General"
title: "Title"
@ -1142,6 +1143,9 @@ en:
email: "Email"
email_info: "The email address from which notifications will be sent. You can use a non-existing address (like noreply@...) or an existing address if you want to allow your members to reply to the notifications they receive."
email_from: "Expeditor's address"
wallet: "Wallet"
wallet_info_html: "<p>The virtual wallet allows you to allocate a sum of money to users. Then, can spend this money as they wish, in Fab-manager.</p><p>Members cannot credit their wallet themselves, it's a privilege of managers and administrators.</p>"
enable_wallet: "Enable wallet"
privacy:
title: "Privacy"
privacy_policy: "Privacy policy"

View File

@ -1109,6 +1109,7 @@ fr:
account_confirmation: "Confirmation de compte"
confirmation_required_info: "De manière optionnelle, vous pouvez forcer les utilisateurs à confirmer leur adresse électronique avant de pouvoir accéder à Fab-manager."
confirmation_is_required: "Confirmation requise"
wallet_module: "module porte-monnaie"
general:
general: "Général"
title: "Titre"
@ -1142,6 +1143,9 @@ fr:
email: "Courriel"
email_info: "L'adresse de courriel depuis laquelle les notifications seront envoyées. Vous pouvez utiliser une adresse qui n'existe pas (comme ne-pas-repondre@...) ou une adresse existante si vous voulez que vos membres puisse répondre aux notifications qu'ils reçoivent."
email_from: "Adresse de l'expéditeur"
wallet: "Porte-monnaie"
wallet_info_html: "<p>Le porte-monnaie virtuel vous permet d'allouer une certaine somme d'argent aux utilisateurs. Ils peuvent ensuite dépenser cet argent comment bon leur semble, dans Fab-manager.</p><p>Les membres ne peuvent pas créditer leur porte-monnaie eux-même, c'est un privilège des gestionnaires et des administrateurs.</p>"
enable_wallet: "Activer le porte-monnaie"
privacy:
title: "Confidentialité"
privacy_policy: "Politique de confidentialité"

View File

@ -12,7 +12,6 @@
development:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: <%= ENV["TIME_ZONE"] %>
@ -40,7 +39,6 @@ development:
test:
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
fablab_without_wallet: false
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: Paris
@ -68,7 +66,6 @@ test:
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %>
@ -107,7 +104,6 @@ staging:
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %>

View File

@ -886,6 +886,8 @@ Setting.set('invoice_prefix', 'FabManager_invoice') unless Setting.find_by(name:
Setting.set('confirmation_required', false) unless Setting.find_by(name: 'confirmation_required').try(:value)
Setting.set('wallet_module', true) unless Setting.find_by(name: 'wallet_module').try(:value)
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2)

View File

@ -51,12 +51,6 @@ When using docker-compose, you should provide the name of the service in your [d
Used by the authentication system to generate random tokens, eg. for resetting passwords.
Used by Rails to verify the integrity of signed cookies.
You can generate such a random key by running `rails secret`.
<a name="FABLAB_WITHOUT_WALLET"></a>
FABLAB_WITHOUT_WALLET
If set to 'true', the wallet will be disabled.
This is useful if you won't use wallet system.
<a name="DELIVERY_METHOD"></a>
DELIVERY_METHOD

View File

@ -8,9 +8,6 @@ ELASTICSEARCH_HOST=fabmanager-elastic
SECRET_KEY_BASE=83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
# FabLab optional modules=
FABLAB_WITHOUT_WALLET=false
# Configure carefully!
DEFAULT_HOST=localhost:5000
DEFAULT_PROTOCOL=http

View File

@ -131,7 +131,8 @@ namespace :fablab do
%w[_ STRIPE_API_KEY stripe_secret_key],
%w[_ STRIPE_CURRENCY stripe_currency],
%w[_ INVOICE_PREFIX invoice_prefix FabManager_invoice],
%w[_ USER_CONFIRMATION_NEEDED_TO_SIGN_IN confirmation_required false]
%w[_ USER_CONFIRMATION_NEEDED_TO_SIGN_IN confirmation_required false],
%w[! FABLAB_WITHOUT_WALLET wallet_module false]
]
mapping.each do |m|

View File

@ -4,8 +4,6 @@ ELASTICSEARCH_HOST=elasticsearch
SECRET_KEY_BASE=
FABLAB_WITHOUT_WALLET=false
SLOT_DURATION=60
FEATURE_TOUR_DISPLAY=once

View File

@ -234,10 +234,8 @@ configure_env_file()
local doc variables secret
doc=$(\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/doc/environment.md)
variables=(FABLAB_WITHOUT_WALLET \
DEFAULT_HOST DEFAULT_PROTOCOL DELIVERY_METHOD SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS \
LOG_LEVEL MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \
variables=(DEFAULT_HOST DEFAULT_PROTOCOL DELIVERY_METHOD SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS LOG_LEVEL MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \
SUPERADMIN_EMAIL APP_LOCALE RAILS_LOCALE MOMENT_LOCALE SUMMERNOTE_LOCALE ANGULAR_LOCALE FULLCALENDAR_LOCALE ELASTICSEARCH_LANGUAGE_ANALYZER TIME_ZONE \
WEEK_STARTING_DAY D3_DATE_FORMAT UIB_DATE_FORMAT EXCEL_DATE_FORMAT)
for variable in "${variables[@]}"; do

View File

@ -677,3 +677,11 @@ history_value_71:
name: false
created_at: 2020-06-15 10:04:06.216541000 Z
updated_at: 2020-06-15 10:04:06.216541000 Z
history_value_72:
id: 72
setting_id: 72
value: 1
name: true
created_at: 2020-06-15 10:04:06.216541000 Z
updated_at: 2020-06-15 10:04:06.216541000 Z

View File

@ -419,3 +419,9 @@ setting_71:
created_at: 2020-06-15 10:04:06.216541000 Z
updated_at: 2020-06-15 10:04:06.216541000 Z
setting_72:
id: 72
name: wallet_module
created_at: 2020-06-15 10:04:06.216541000 Z
updated_at: 2020-06-15 10:04:06.216541000 Z