1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-02 13:24:20 +01:00
fab-manager/app/policies/cart_policy.rb

21 lines
501 B
Ruby
Raw Normal View History

2022-08-19 19:59:13 +02:00
# frozen_string_literal: true
# Check the access policies for API::CartController
class CartPolicy < ApplicationPolicy
def create?
true
end
%w[add_item remove_item set_quantity refresh_item validate].each do |action|
2022-08-19 19:59:13 +02:00
define_method "#{action}?" do
return user.privileged? || (record.statistic_profile_id == user.statistic_profile.id) if user
record.statistic_profile_id.nil? && record.operator_profile_id.nil?
2022-08-19 19:59:13 +02:00
end
end
def set_offer?
user.privileged?
end
2022-08-19 19:59:13 +02:00
end