diff --git a/app/assets/javascripts/controllers/about.js b/app/assets/javascripts/controllers/about.js index cc661753e..7bcc5e4be 100644 --- a/app/assets/javascripts/controllers/about.js +++ b/app/assets/javascripts/controllers/about.js @@ -1,29 +1,20 @@ -/* eslint-disable - no-return-assign, - no-undef, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ 'use strict'; Application.Controllers.controller('AboutController', ['$scope', 'Setting', 'CustomAsset', function ($scope, Setting, CustomAsset) { /* PUBLIC SCOPE */ - Setting.get({ name: 'about_title' }, data => $scope.aboutTitle = data.setting); + Setting.get({ name: 'about_title' }, data => { $scope.aboutTitle = data.setting; }); - Setting.get({ name: 'about_body' }, data => $scope.aboutBody = data.setting); + Setting.get({ name: 'about_body' }, data => { $scope.aboutBody = data.setting; }); - Setting.get({ name: 'about_contacts' }, data => $scope.aboutContacts = data.setting); + Setting.get({ name: 'about_contacts' }, data => { $scope.aboutContacts = data.setting; }); + + Setting.get({ name: 'privacy_body' }, data => { $scope.privacyPolicy = data.setting; }); // retrieve the CGU - CustomAsset.get({ name: 'cgu-file' }, cgu => $scope.cgu = cgu.custom_asset); + CustomAsset.get({ name: 'cgu-file' }, cgu => { $scope.cgu = cgu.custom_asset; }); // retrieve the CGV - return CustomAsset.get({ name: 'cgv-file' }, cgv => $scope.cgv = cgv.custom_asset); + CustomAsset.get({ name: 'cgv-file' }, cgv => { $scope.cgv = cgv.custom_asset; }); } ]); diff --git a/app/assets/javascripts/controllers/admin/settings.js.erb b/app/assets/javascripts/controllers/admin/settings.js.erb index 71624758a..9be82acea 100644 --- a/app/assets/javascripts/controllers/admin/settings.js.erb +++ b/app/assets/javascripts/controllers/admin/settings.js.erb @@ -261,6 +261,10 @@ Application.Controllers.controller('SettingsController', ['$scope', '$filter', ' * Change the revision of the displayed privacy policy, from drafts history */ $scope.handlePolicyRevisionChange = function () { + if ($scope.privacyPolicy.version === null) { + $scope.privacyPolicy.bodyTemp = settingsPromise.privacy_body; + return; + } for (const draft of $scope.privacyDraftsHistory) { if (draft.id == $scope.privacyPolicy.version) { $scope.privacyPolicy.bodyTemp = draft.content; @@ -308,7 +312,7 @@ Application.Controllers.controller('SettingsController', ['$scope', '$filter', ' } if (profileImageFile.custom_asset) { $scope.methods.profileImage = 'put'; - return $scope.actionUrl.profileImage += '/profile-image-file'; + $scope.actionUrl.profileImage += '/profile-image-file'; } privacyDraftsPromise.setting.history.forEach(function (draft) { @@ -326,8 +330,8 @@ Application.Controllers.controller('SettingsController', ['$scope', '$filter', ' /** * Controller used in the invoice refunding modal window */ -Application.Controllers.controller('SavePolicyController', ['$scope', '$uibModalInstance', 'saveCb', 'privacyPolicy', - function ($scope, $uibModalInstance, saveCb, privacyPolicy) { +Application.Controllers.controller('SavePolicyController', ['$scope', '$uibModalInstance', '_t', 'growl', 'saveCb', 'privacyPolicy', + function ($scope, $uibModalInstance, _t, growl, saveCb, privacyPolicy) { /* PUBLIC SCOPE */ /** @@ -343,6 +347,7 @@ Application.Controllers.controller('SavePolicyController', ['$scope', '$uibModal */ $scope.publish = function () { saveCb({ name: 'privacy_body', value: privacyPolicy.bodyTemp }); + growl.info(_t('settings.privacy.users_notified')); $uibModalInstance.close('privacy_body'); }; /** diff --git a/app/assets/templates/shared/about.html.erb b/app/assets/templates/shared/about.html.erb index 2048da3ea..beb56722d 100644 --- a/app/assets/templates/shared/about.html.erb +++ b/app/assets/templates/shared/about.html.erb @@ -16,7 +16,7 @@

{{ 'about.read_the_fablab_s_general_terms_and_conditions' }}

-

+

{{ 'about.privacy_policy' }}

diff --git a/app/assets/templates/shared/privacy.html.erb b/app/assets/templates/shared/privacy.html.erb index b38c22f86..d7e8220c0 100644 --- a/app/assets/templates/shared/privacy.html.erb +++ b/app/assets/templates/shared/privacy.html.erb @@ -16,7 +16,7 @@ -
+

{{ 'privacy.dpo' }}

diff --git a/app/models/notification_type.rb b/app/models/notification_type.rb index 19ea34456..6043637bb 100644 --- a/app/models/notification_type.rb +++ b/app/models/notification_type.rb @@ -45,6 +45,7 @@ class NotificationType notify_admin_free_disk_space notify_admin_close_period_reminder notify_admin_archive_complete + notify_privacy_policy_changed ] # deprecated: # - notify_member_subscribed_plan_is_changed diff --git a/app/models/setting.rb b/app/models/setting.rb index 3339d0168..2290e08af 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -42,12 +42,20 @@ class Setting < ActiveRecord::Base display_name_enable machines_sort_by] } - after_update :update_stylesheet if :value_changed? + after_update :update_stylesheet, :notify_privacy_policy_changed if :value_changed? def update_stylesheet Stylesheet.first&.rebuild! if %w[main_color secondary_color].include? name end + def notify_privacy_policy_changed + return unless name == 'privacy_body' + + NotificationCenter.call type: :notify_privacy_policy_changed, + receiver: User.all, + attached_object: self + end + def value last_value = history_values.order(HistoryValue.arel_table['created_at'].desc).first last_value&.value diff --git a/app/services/reservations/reserve.rb b/app/services/reservations/reserve.rb index 9cb8de571..8bab493e2 100644 --- a/app/services/reservations/reserve.rb +++ b/app/services/reservations/reserve.rb @@ -1,19 +1,20 @@ -module Reservations - class Reserve - attr_accessor :user_id, :operator_id +# frozen_string_literal: true - def initialize(user_id, operator_id) - @user_id = user_id - @operator_id = operator_id - end +# Provides helper methods for Reservation actions +class Reservations::Reserve + attr_accessor :user_id, :operator_id - def pay_and_save(reservation, payment_method, coupon) - reservation.user_id = user_id - if payment_method == :local - reservation.save_with_local_payment(operator_id, coupon) - elsif payment_method == :stripe - reservation.save_with_payment(operator_id, coupon) - end + def initialize(user_id, operator_id) + @user_id = user_id + @operator_id = operator_id + end + + def pay_and_save(reservation, payment_method, coupon) + reservation.user_id = user_id + if payment_method == :local + reservation.save_with_local_payment(operator_id, coupon) + elsif payment_method == :stripe + reservation.save_with_payment(operator_id, coupon) end end end diff --git a/app/services/subscriptions/subscribe.rb b/app/services/subscriptions/subscribe.rb index 3af97c5f7..4e9fb2bc6 100644 --- a/app/services/subscriptions/subscribe.rb +++ b/app/services/subscriptions/subscribe.rb @@ -1,34 +1,35 @@ -module Subscriptions - class Subscribe - attr_accessor :user_id, :operator_id +# frozen_string_literal: true - def initialize(user_id, operator_id) - @user_id = user_id - @operator_id = operator_id - end +# Provides helper methods for Subscription actions +class Subscriptions::Subscribe + attr_accessor :user_id, :operator_id - def pay_and_save(subscription, payment_method, coupon, invoice) - subscription.user_id = user_id - if payment_method == :local - subscription.save_with_local_payment(operator_id, invoice, coupon) - elsif payment_method == :stripe - subscription.save_with_payment(operator_id, invoice, coupon) - end - end + def initialize(user_id, operator_id) + @user_id = user_id + @operator_id = operator_id + end - def extend_subscription(subscription, new_expiration_date, free_days) - return subscription.free_extend(new_expiration_date) if free_days - - new_sub = Subscription.create( - plan_id: subscription.plan_id, - user_id: subscription.user_id, - expiration_date: new_expiration_date - ) - if new_sub.save - new_sub.user.generate_subscription_invoice(operator_id) - return new_sub - end - false + def pay_and_save(subscription, payment_method, coupon, invoice) + subscription.user_id = user_id + if payment_method == :local + subscription.save_with_local_payment(operator_id, invoice, coupon) + elsif payment_method == :stripe + subscription.save_with_payment(operator_id, invoice, coupon) end end -end + + def extend_subscription(subscription, new_expiration_date, free_days) + return subscription.free_extend(new_expiration_date) if free_days + + new_sub = Subscription.create( + plan_id: subscription.plan_id, + user_id: subscription.user_id, + expiration_date: new_expiration_date + ) + if new_sub.save + new_sub.user.generate_subscription_invoice(operator_id) + return new_sub + end + false + end +end \ No newline at end of file diff --git a/app/views/api/notifications/_notify_privacy_policy_changed.json.jbuilder b/app/views/api/notifications/_notify_privacy_policy_changed.json.jbuilder new file mode 100644 index 000000000..3f73f7bc8 --- /dev/null +++ b/app/views/api/notifications/_notify_privacy_policy_changed.json.jbuilder @@ -0,0 +1,4 @@ +json.title notification.notification_type +json.description t('.policy_updated') + + "." +json.url notification_url(notification, format: :json) diff --git a/app/views/notifications_mailer/notify_privacy_policy_changed.html.erb b/app/views/notifications_mailer/notify_privacy_policy_changed.html.erb new file mode 100644 index 000000000..f4adf20f1 --- /dev/null +++ b/app/views/notifications_mailer/notify_privacy_policy_changed.html.erb @@ -0,0 +1,7 @@ +<%= render 'notifications_mailer/shared/hello', recipient: @recipient %> + +<%= t('.body.content_html') %> + +

+ <%=link_to( t('.body.link_to_policy'), "#{root_url}#!/privacy-policy", target: "_blank" )%> +

diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 7477aa085..820adaaf6 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -724,6 +724,7 @@ en: save_or_publish_body: "Do you want to publish a new version of the privacy policy or save it as a draft?" publish_will_notify: "Publish a new version will send a notification to every users." publish: "Publish" + users_notified: "Platform users will be notified of the update." open_api_clients: add_new_client: "Create new API client" diff --git a/config/locales/app.admin.es.yml b/config/locales/app.admin.es.yml index 951b24611..48cab130d 100644 --- a/config/locales/app.admin.es.yml +++ b/config/locales/app.admin.es.yml @@ -724,6 +724,7 @@ es: save_or_publish_body: "Do you want to publish a new version of the privacy policy or save it as a draft?" # translation_missing publish_will_notify: "Publish a new version will send a notification to every users." # translation_missing publish: "Publish" # translation_missing + users_notified: "Platform users will be notified of the update." # translation_missing open_api_clients: add_new_client: "Crear un nuevo cliente de API" diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index be9f4b49e..1637f0c4d 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -724,6 +724,7 @@ fr: save_or_publish_body: "Voulez-vous publier une nouvelle version de la politique de confidentialité ou bien l'enregistrer comme brouillon ?" publish_will_notify: "Publier une nouvelle version enverra une notification à l'ensemble des utilisateurs." publish: "Publier" + users_notified: "Les utilisateurs de la plateforme seront notifiés de la mise à jour." open_api_clients: add_new_client: "Créer un compte client" diff --git a/config/locales/app.admin.pt.yml b/config/locales/app.admin.pt.yml index be40e72b8..40a8ddabe 100755 --- a/config/locales/app.admin.pt.yml +++ b/config/locales/app.admin.pt.yml @@ -724,6 +724,7 @@ pt: save_or_publish_body: "Do you want to publish a new version of the privacy policy or save it as a draft?" # translation_missing publish_will_notify: "Publish a new version will send a notification to every users." # translation_missing publish: "Publish" # translation_missing + users_notified: "Platform users will be notified of the update." # translation_missing open_api_clients: add_new_client: "Criar novo cliente de API" diff --git a/config/locales/en.yml b/config/locales/en.yml index f6eb5d1a7..bd1161268 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -318,7 +318,9 @@ en: warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}" notify_admin_archive_complete: archive_complete: "Data archiving from %{START} to %{END} is done.
click here to download. Remember to save it on an external secured media." - + notify_privacy_policy_changed: + policy_updated: "Privacy policy updated." + click_to_show: "Click here to consult" statistics: # statistics tools for admins subscriptions: "Subscriptions" diff --git a/config/locales/es.yml b/config/locales/es.yml index 4a51305f8..ab0edb301 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -318,7 +318,9 @@ es: warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}" # missing translation notify_admin_archive_complete: # missing translation archive_complete: "Data archiving from %{START} to %{END} is done. click here to download. Remember to save it on an external secured media." # missing translation - + notify_privacy_policy_changed: + policy_updated: "Privacy policy updated." # missing translation + click_to_show: "Click here to consult" # missing translation statistics: # statistics tools for admins subscriptions: "Suscripciones" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f207bed69..3b7d973c6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -318,6 +318,9 @@ fr: warning_no_closed_periods: "Pensez à clôturer régulièrement vos périodes comptables. Vous devez clôturer des périodes depuis le %{FIRST_DATE}" notify_admin_archive_complete: archive_complete: "L'archivage des données du %{START} au %{END} est terminé. Cliquez ici pour la télécharger. Pensez à l'enregistrer sur un support externe sécurisé." + notify_privacy_policy_changed: + policy_updated: "Nouvelle mise à jour de la Politique de confidentialité." + click_to_show: "Cliquez ici pour la consulter" statistics: # outil de statistiques pour les administrateurs diff --git a/config/locales/mails.en.yml b/config/locales/mails.en.yml index cb7befdd0..a71c7ddd5 100644 --- a/config/locales/mails.en.yml +++ b/config/locales/mails.en.yml @@ -294,5 +294,11 @@ en: here: "here." save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check." + notify_privacy_policy_changed: + subject: "Privacy policy updated" + body: + content_html: "

We wish to inform you that we have just updated our privacy policy.

We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.

By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.

" + link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." + shared: hello: "Hello %{user_name}" diff --git a/config/locales/mails.es.yml b/config/locales/mails.es.yml index 2c7bf207d..b48b34d57 100644 --- a/config/locales/mails.es.yml +++ b/config/locales/mails.es.yml @@ -293,5 +293,11 @@ es: here: "here." save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check." + notify_privacy_policy_changed: #translation_missing + subject: "Privacy policy updated" + body: + content_html: "

We wish to inform you that we have just updated our privacy policy.

We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.

By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.

" + link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." + shared: hello: "¡Hola %{user_name}!" diff --git a/config/locales/mails.fr.yml b/config/locales/mails.fr.yml index 6bd198b2e..f8c4df617 100644 --- a/config/locales/mails.fr.yml +++ b/config/locales/mails.fr.yml @@ -294,5 +294,11 @@ fr: here: "ici." save_on_secured: "N'oubliez pas que vous devez obligatoirement enregistrer cette archive sur un support externe sécurisé, qui peut vous être demandé par l'administration fiscale lors d'un contrôle." + notify_privacy_policy_changed: + subject: "Mise à jour de la Politique de confidentialité" + body: + content_html: "

Nous souhaitons vous signaler que nous venons de mettre à jour notre politique de confidentialité.

Nous pouvons apporter régulièrement des modifications à notre politique de confidentialité. Conformément à la réglementation, une notification vous sera envoyée à chaque mise à jour.

En accédant ou en utilisant nos services après la mise à jour de la Politique de confidentialité, nous considérerons que vous acceptez les termes de celle-ci, mises à jour comprises.

" + link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." + shared: hello: "Bonjour %{user_name}" diff --git a/config/locales/mails.pt.yml b/config/locales/mails.pt.yml index 18ae430c5..2d41e019e 100755 --- a/config/locales/mails.pt.yml +++ b/config/locales/mails.pt.yml @@ -294,5 +294,11 @@ pt: here: "here." save_on_secured: "Remember that you must save this archive on a secured external support, which may be requested by the tax authorities during a check." + notify_privacy_policy_changed: #translation_missing + subject: "Privacy policy updated" + body: + content_html: "

We wish to inform you that we have just updated our privacy policy.

We may change our privacy policy regularly. In accordance with the regulations, you will receive a notification for each update.

By accessing or using our services after the privacy policy update, we will consider that you agree its terms, updates included.

" + link_to_policy: "Cliquez ici pour consultez la politique de confidentialité." + shared: hello: "Olá %{user_name}" diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 493a69530..f1d65bf36 100755 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -318,7 +318,9 @@ pt: warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}" # missing translation notify_admin_archive_complete: # missing translation archive_complete: "Data archiving from %{START} to %{END} is done. click here to download. Remember to save it on an external secured media." # missing translation - + notify_privacy_policy_changed: + policy_updated: "Privacy policy updated." # missing translation + click_to_show: "Click here to consult" # missing translation statistics: # statistics tools for admins subscriptions: "Assinaturas" diff --git a/config/spring.rb b/config/spring.rb index acfebafa8..21f17cb85 100644 --- a/config/spring.rb +++ b/config/spring.rb @@ -1,8 +1,11 @@ # frozen_string_literal: true + Spring.after_fork do if ENV['DEBUGGER_STORED_RUBYLIB'] - starter = ENV['BUNDLER_ORIG_RUBYOPT'][2..-1] - load(starter + '.rb') + ENV['DEBUGGER_STORED_RUBYLIB'].split(File::PATH_SEPARATOR).each do |path| + next unless path =~ /ruby-debug-ide/ + load path + '/ruby-debug-ide/multiprocess/starter.rb' + end end -end +end \ No newline at end of file