parent
bfb0d9167a
commit
c3c77d1ea4
@ -0,0 +1,24 @@ |
||||
module ::Bim |
||||
module Views |
||||
class ContractStrategy < ::BaseContract |
||||
validate :manageable |
||||
|
||||
private |
||||
|
||||
def manageable |
||||
return if model.query.blank? |
||||
|
||||
errors.add(:base, :error_unauthorized) unless query_permissions? |
||||
end |
||||
|
||||
def query_permissions? |
||||
# TODO: This currently does not differentiate between public and private queries since it isn't specified yet. |
||||
user_allowed_on_query?(:manage_ifc_models) |
||||
end |
||||
|
||||
def user_allowed_on_query?(permission) |
||||
user.allowed_to?(permission, model.query.project, global: model.query.project.nil?) |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue