Browse Source
* Do not allow adding stock owners as data providers * Do not allow removing stock owners as data providers * Do not allow adding managing agents as data providers * Do not allow removing managing agents as data providers and fix remove_stock_owner * Authorise add managing agent/stock owner pages * Refactor organisation_relationship_policy * Update test names * Refactor policy and remove headers from testspull/1749/head
kosiakkatrina
2 years ago
committed by
GitHub
3 changed files with 127 additions and 12 deletions
@ -0,0 +1,21 @@ |
|||||||
|
class OrganisationRelationshipPolicy |
||||||
|
attr_reader :user, :organisation_relationship |
||||||
|
|
||||||
|
def initialize(user, organisation_relationship) |
||||||
|
@user = user |
||||||
|
@organisation_relationship = organisation_relationship |
||||||
|
end |
||||||
|
|
||||||
|
%w[ |
||||||
|
add_stock_owner? |
||||||
|
create_stock_owner? |
||||||
|
remove_stock_owner? |
||||||
|
add_managing_agent? |
||||||
|
create_managing_agent? |
||||||
|
remove_managing_agent? |
||||||
|
].each do |method_name| |
||||||
|
define_method method_name do |
||||||
|
!user.data_provider? |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue