2015-09-11 13:16:53 +02:00
|
|
|
class UserAbility
|
2015-09-08 17:18:38 +02:00
|
|
|
include CanCan::Ability
|
|
|
|
|
|
|
|
def initialize(user)
|
2015-09-09 16:56:55 +02:00
|
|
|
return unless user
|
2015-09-08 17:18:38 +02:00
|
|
|
|
2015-09-09 16:56:55 +02:00
|
|
|
can :manage, :all if user.penning?
|
2018-06-20 19:28:01 +02:00
|
|
|
can :manage, user, id: user.id
|
2017-01-11 14:34:17 +01:00
|
|
|
can :manage, Request, creditor_id: user.id
|
2017-01-09 16:22:58 +01:00
|
|
|
can :manage, Notification, user_id: user.id
|
2016-02-02 18:34:19 +01:00
|
|
|
can :create, Transaction do |t|
|
2018-03-21 19:39:41 +01:00
|
|
|
t.debtor == user && t.amount <= Rails.application.config.maximum_amount
|
2016-02-02 18:34:19 +01:00
|
|
|
end
|
2015-09-08 17:18:38 +02:00
|
|
|
end
|
|
|
|
end
|