Update permission markup

This commit is contained in:
aignatov-bio 2020-10-29 14:59:14 +01:00
parent b0fe68553a
commit f51416d83a
2 changed files with 13 additions and 13 deletions

View file

@ -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);
});
});

View file

@ -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