From 19de8ca31989960bce1256c167d3e2341516fe96 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 6 May 2020 09:58:08 +0200 Subject: [PATCH] fix: manager can offer slot to other users --- app/assets/javascripts/directives/cart.js.erb | 14 ++++++++++++++ app/assets/templates/shared/_cart.html.erb | 2 +- app/controllers/api/prices_controller.rb | 2 +- app/controllers/api/reservations_controller.rb | 2 +- app/controllers/api/subscriptions_controller.rb | 2 +- app/models/reservation.rb | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/directives/cart.js.erb b/app/assets/javascripts/directives/cart.js.erb index 6dfba5c2d..8836bb53e 100644 --- a/app/assets/javascripts/directives/cart.js.erb +++ b/app/assets/javascripts/directives/cart.js.erb @@ -285,6 +285,20 @@ Application.Directives.directive('cart', [ '$rootScope', '$uibModal', 'dialogs', return false; }; + /** + * Check if the currently logged user has the 'admin' role OR the 'manager' role, but is not taking reseravtion for himself + * @returns {boolean} + */ + $scope.isAuthorized = function () { + if (AuthService.isAuthorized('admin')) return true; + + if (AuthService.isAuthorized('manager')) { + return ($rootScope.currentUser.id !== $scope.user.id); + } + + return false; + } + /* PRIVATE SCOPE */ /** diff --git a/app/assets/templates/shared/_cart.html.erb b/app/assets/templates/shared/_cart.html.erb index 1a883b8c0..33f28915f 100644 --- a/app/assets/templates/shared/_cart.html.erb +++ b/app/assets/templates/shared/_cart.html.erb @@ -16,7 +16,7 @@
{{ 'app.shared.cart.datetime_to_time' | translate:{START_DATETIME:(slot.start | amDateFormat:'LLLL'), END_TIME:(slot.end | amDateFormat:'LT') } }}
{{ 'app.shared.cart.cost_of_TYPE' | translate:{TYPE:reservableType} }} {{slot.price | currency}}
-
+