diff --git a/app/assets/javascripts/sitewide/image_editor.js b/app/assets/javascripts/sitewide/image_editor.js index 209b73844..2e0b8d477 100644 --- a/app/assets/javascripts/sitewide/image_editor.js +++ b/app/assets/javascripts/sitewide/image_editor.js @@ -407,7 +407,7 @@ var ImageEditorModal = (function() { 'mime-type': editButton.data('image-mime-type') }; $('#filePreviewModal').modal('hide'); - $.post(editButton.data('start-edit-url')); + $.post(editButton.data('image-start-edit-url')); initImageEditor(data, fileUrl); }); }); diff --git a/app/permissions/asset.rb b/app/permissions/asset.rb index 6cea35793..482c56a8a 100644 --- a/app/permissions/asset.rb +++ b/app/permissions/asset.rb @@ -2,31 +2,31 @@ Canaid::Permissions.register_for(Asset) do can :read_asset do |user, asset| - object ||= asset.step - object ||= asset.result - object ||= asset.repository_cell + object = asset.step || asset.result || asset.repository_cell - if object.class == Step + case object + when Step protocol = object.protocol can_read_protocol_in_module?(user, protocol) || can_read_protocol_in_repository?(user, protocol) - elsif object.class == Result + when Result can_read_experiment?(user, object.my_module.experiment) - elsif object.class == RepositoryCell + when RepositoryCell can_read_repository?(user, object.repository_column.repository) end end can :manage_asset do |user, asset| - object ||= asset.step - object ||= asset.result - object ||= asset.repository_cell + object = asset.step || asset.result || asset.repository_cell - if object.class == Step + case object + when Step protocol = object.protocol can_manage_protocol_in_module?(user, protocol) || can_manage_protocol_in_repository?(user, protocol) - elsif object.class == Result + when Result can_manage_experiment?(user, object.my_module.experiment) - elsif object.class == RepositoryCell && !object.repository_column.repository.is_a?(RepositorySnapshot) + when RepositoryCell + return false if object.repository_column.repository.is_a?(RepositorySnapshot) + can_manage_repository?(user, object.repository_column.repository) end end