mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
ability for the admin to set custom settings for the reservation reminders + fix settings customization confirmation message
This commit is contained in:
parent
63e767bd18
commit
26aed7a1b5
@ -23,6 +23,8 @@
|
||||
- Excel exports are now asynchronously generated and cached on the server for future identical requests
|
||||
- Users have the ability to create an organizational profile when creating an account
|
||||
- Organization informations will be used in invoices generation, if present
|
||||
- Admins can create and enable/disable coupons. They can also notify an user about details of a coupon
|
||||
- Users and admins can apply coupons's discounts to their shopping cart
|
||||
- Fix a bug: project drafts are shown on public profiles
|
||||
- Fix a bug: event category disappear when editing the event
|
||||
- [TODO DEPLOY] `rake fablab:es_add_event_filters`
|
||||
|
@ -74,6 +74,14 @@ Application.Controllers.controller "SettingsController", ["$scope", 'Setting', '
|
||||
$scope.cancelDelay =
|
||||
name: 'booking_cancel_delay'
|
||||
value: parseInt(settingsPromise.booking_cancel_delay)
|
||||
|
||||
$scope.enableReminder =
|
||||
name: 'reminder_enable'
|
||||
value: (settingsPromise.reminder_enable == 'true')
|
||||
|
||||
$scope.reminderDelay =
|
||||
name: 'reminder_delay'
|
||||
value: parseInt(settingsPromise.reminder_delay)
|
||||
|
||||
|
||||
|
||||
@ -108,7 +116,7 @@ Application.Controllers.controller "SettingsController", ["$scope", 'Setting', '
|
||||
value = setting.value
|
||||
|
||||
Setting.update { name: setting.name }, { value: value }, (data)->
|
||||
growl.success(_t('customization_of_SETTING_successfully_saved', {SETTING:setting.name}))
|
||||
growl.success(_t('customization_of_SETTING_successfully_saved', {SETTING:_t(setting.name)}))
|
||||
, (error)->
|
||||
console.log(error)
|
||||
|
||||
|
@ -1029,7 +1029,9 @@ angular.module('application.router', ['ui.router']).
|
||||
'main_color',
|
||||
'secondary_color',
|
||||
'fablab_name',
|
||||
'name_genre'
|
||||
'name_genre',
|
||||
'reminder_enable',
|
||||
'reminder_delay'
|
||||
]").$promise
|
||||
]
|
||||
cguFile: ['CustomAsset', (CustomAsset) ->
|
||||
|
@ -67,7 +67,7 @@
|
||||
</div>
|
||||
<div class="row" ng-show="enableCancel.value">
|
||||
<div class="col-md-4">
|
||||
<label for="moveDelay" class="control-label m-r" translate>{{ 'prior_period_(hours)' }}</label>
|
||||
<label for="cancelDelay" class="control-label m-r" translate>{{ 'prior_period_(hours)' }}</label>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">
|
||||
@ -81,4 +81,41 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default m-t-lg">
|
||||
<div class="panel-heading">
|
||||
<span class="font-sbold" translate>{{ 'reservations_reminders' }}</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<h3 class="m-l" translate>{{ 'notification_sending_before_the_reservation_occurs' }}</h3>
|
||||
<div class="form-group m-l">
|
||||
<label for="enableReminder" class="control-label m-r" translate>{{ 'reservations_reminders' }}</label>
|
||||
<input bs-switch
|
||||
ng-model="enableReminder.value"
|
||||
id="enableReminder"
|
||||
type="checkbox"
|
||||
class="form-control"
|
||||
switch-on-text="{{ 'enabled' | translate }}"
|
||||
switch-off-text="{{ 'disabled' | translate }}"
|
||||
switch-animate="true"/>
|
||||
<button name="button" class="btn btn-warning m-l" ng-click="save(enableReminder)" translate>{{ 'save' }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" ng-show="enableReminder.value">
|
||||
<div class="col-md-4">
|
||||
<label for="reminderDelay" class="control-label m-r" translate>{{ 'prior_period_(hours)' }}</label>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">
|
||||
<i class="fa fa-clock-o"></i>
|
||||
</div>
|
||||
<input type="number" class="form-control" id="reminderDelay" ng-model="reminderDelay.value">
|
||||
</div>
|
||||
</div>
|
||||
<button name="button" class="btn btn-warning" ng-click="save(reminderDelay)" translate>{{ 'save' }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -7,7 +7,7 @@ class API::SettingsController < API::ApiController
|
||||
|
||||
def update
|
||||
authorize Setting
|
||||
@setting = Setting.find_by(name: params[:name])
|
||||
@setting = Setting.find_or_initialize_by(name: params[:name])
|
||||
if @setting.update(setting_params)
|
||||
render status: :ok
|
||||
else
|
||||
|
@ -29,7 +29,9 @@ class Setting < ActiveRecord::Base
|
||||
main_color
|
||||
secondary_color
|
||||
fablab_name
|
||||
name_genre)
|
||||
name_genre
|
||||
reminder_enable
|
||||
reminder_delay )
|
||||
}
|
||||
|
||||
after_update :update_stylesheet if :value_changed?
|
||||
|
@ -1,3 +1,3 @@
|
||||
client = Elasticsearch::Client.new host: "http://#{ENV["ELASTICSEARCH_HOST"]}:9200", log: true
|
||||
client = Elasticsearch::Client.new host: "http://#{Rails.application.secrets.elaticsearch_host}:9200", log: true
|
||||
Elasticsearch::Model.client = client
|
||||
Elasticsearch::Persistence.client = client
|
||||
|
@ -513,8 +513,31 @@ en:
|
||||
disabled: "Disabled"
|
||||
ability_for_the_users_to_cancel_their_reservations: "Ability for the users to cancel their reservations"
|
||||
reservations_cancelling: "Reservations cancelling"
|
||||
customization_of_SETTING_successfully_saved: "Customization of {{SETTING}} successfully saved." # angular interpolation
|
||||
reservations_reminders: "Reservations reminders"
|
||||
notification_sending_before_the_reservation_occurs: "Notification sending before the reservation occurs"
|
||||
customization_of_SETTING_successfully_saved: "Customization of the {{SETTING}} successfully saved." # angular interpolation
|
||||
file_successfully_updated: "File successfully updated."
|
||||
name_genre: "title concordance"
|
||||
machine_explications_alert: "explanation message on the machine reservation page"
|
||||
training_explications_alert: "explanation message on the training reservation page"
|
||||
training_information_message: "information message on the machine reservation page"
|
||||
subscription_explications_alert: "explanation message on the subscription page"
|
||||
event_reduced_amount_alert: "information message concerning the reduced prices of an event"
|
||||
main_color: "main colour"
|
||||
secondary_color: "secondary colour"
|
||||
home_blogpost: "homepage's brief"
|
||||
twitter_name: "Twitter feed name"
|
||||
about_title: "\"About\" page title"
|
||||
about_body: "\"About\" page content"
|
||||
about_contacts: "\"About\" page contacts"
|
||||
booking_window_start: "opening time"
|
||||
booking_window_end: "closing time"
|
||||
booking_move_enable: "reservation moving enabling"
|
||||
booking_move_delay: "preventive delay of moving"
|
||||
booking_cancel_enable: "reservation canceling enabling"
|
||||
booking_cancel_delay: "preventive delay of canceling"
|
||||
reminder_enable: "reservation reminding enabling"
|
||||
reminder_delay: "delay before sending the reminder"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Create new API client"
|
||||
|
@ -513,8 +513,31 @@ fr:
|
||||
disabled: "Désactivé"
|
||||
ability_for_the_users_to_cancel_their_reservations: "Possibilité pour l'utilisateur d'annuler ses réservations"
|
||||
reservations_cancelling: "Annulation des réservations"
|
||||
reservations_reminders: "Rappel des réservations"
|
||||
notification_sending_before_the_reservation_occurs: "Envoi de notification avant l'avènement de la réservation"
|
||||
customization_of_SETTING_successfully_saved: "La personnalisation de {{SETTING}} a bien été enregistrée." # angular interpolation
|
||||
file_successfully_updated: "Le fichier a bien été mis à jour."
|
||||
name_genre: "l'accord du nom"
|
||||
machine_explications_alert: "l'explication sur la page de réservation d'une machine"
|
||||
training_explications_alert: "l'explication sur la page de réservation d'une formation"
|
||||
training_information_message: "l'information sur la page de réservation d'une formation"
|
||||
subscription_explications_alert: "l'explication sur la page de souscription à un abonnement"
|
||||
event_reduced_amount_alert: "l'information relative aux tarifs réduits d'un évènement"
|
||||
main_color: "la couleur principale"
|
||||
secondary_color: "la couleur secondaire"
|
||||
home_blogpost: "la brève de la page d'accueil"
|
||||
twitter_name: "nom du flux Twitter"
|
||||
about_title: "titre de la page \"À propos\""
|
||||
about_body: "corps de la page \"À propos\""
|
||||
about_contacts: "contacts sur la page \"À propos\""
|
||||
booking_window_start: "l'heure d'ouverture"
|
||||
booking_window_end: "l'heure de fermeture"
|
||||
booking_move_enable: "l'activation du déplacement de réservation"
|
||||
booking_move_delay: "délai préventif de déplacement"
|
||||
booking_cancel_enable: "l'activation de l'annulation de réservation"
|
||||
booking_cancel_delay: "délai préventif d'annulation"
|
||||
reminder_enable: "l'activation du rappel de réservation"
|
||||
reminder_delay: "délai avant envoi de la notification de rappel"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Créer un compte client"
|
||||
|
@ -36,6 +36,7 @@ development:
|
||||
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
|
||||
log_level: <%= ENV["LOG_LEVEL"] %>
|
||||
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
|
||||
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
|
||||
|
||||
test:
|
||||
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
|
||||
@ -63,6 +64,7 @@ test:
|
||||
navinum_api_password:
|
||||
log_level: <%= ENV["LOG_LEVEL"] %>
|
||||
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
|
||||
elaticsearch_host: localhost
|
||||
|
||||
staging:
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
||||
@ -97,6 +99,7 @@ staging:
|
||||
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
|
||||
log_level: <%= ENV["LOG_LEVEL"] %>
|
||||
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
|
||||
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
|
||||
|
||||
# Do not keep production secrets in the repository,
|
||||
# instead read values from the environment.
|
||||
@ -134,3 +137,4 @@ production:
|
||||
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
|
||||
log_level: <%= ENV["LOG_LEVEL"] %>
|
||||
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
|
||||
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
|
||||
|
12
db/seeds.rb
12
db/seeds.rb
@ -392,3 +392,15 @@ unless DatabaseProvider.count > 0
|
||||
provider.save
|
||||
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
|
||||
|
||||
unless Setting.find_by(name: 'reminder_delay').try(:value)
|
||||
setting = Setting.find_or_initialize_by(name: 'reminder_delay')
|
||||
setting.value = '24'
|
||||
setting.save
|
||||
end
|
43
test/integration/settings_test.rb
Normal file
43
test/integration/settings_test.rb
Normal file
@ -0,0 +1,43 @@
|
||||
class SettingsTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# Called before every test method runs. Can be used
|
||||
# to set up fixture information.
|
||||
def setup
|
||||
@admin = User.find_by(username: 'admin')
|
||||
login_as(@admin, scope: :user)
|
||||
end
|
||||
|
||||
# Called after every test method runs. Can be used to tear
|
||||
# down fixture information.
|
||||
|
||||
def teardown
|
||||
# Do nothing
|
||||
end
|
||||
|
||||
test 'update setting value' do
|
||||
put '/api/settings/fablab_name',
|
||||
{
|
||||
setting: {
|
||||
value: 'Test Fablab'
|
||||
}
|
||||
}
|
||||
assert_equal 200, response.status
|
||||
assert_equal Mime::JSON, response.content_type
|
||||
resp = json_response(response.body)
|
||||
assert_equal 'fablab_name', resp[:setting][:name]
|
||||
assert_equal 'Test Fablab', resp[:setting][:value]
|
||||
end
|
||||
|
||||
|
||||
test 'update setting with wrong name' do
|
||||
put '/api/settings/does_not_exists',
|
||||
{
|
||||
setting: {
|
||||
value: 'ERROR EXPECTED'
|
||||
}
|
||||
}
|
||||
assert_equal 422, response.status
|
||||
assert_match /Name is not included in the list/, response.body
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user