Merge branch '10346-rearrange-api-docs' closes #10346
[arvados.git] / apps / workbench / app / models / arvados_base.rb
index 29379a03ced62b5fad1e782bc08a24ad0c8ba0f3..6250daa06a3d0c65d2233f51c33588a9de3855a5 100644 (file)
@@ -334,7 +334,7 @@ class ArvadosBase < ActiveRecord::Base
   end
 
   def self.creatable?
-    current_user.andand.is_active
+    current_user.andand.is_active && api_exists?(:create)
   end
 
   def self.goes_in_projects?
@@ -357,6 +357,14 @@ class ArvadosBase < ActiveRecord::Base
        (ArvadosBase.find(owner_uuid).writable_by.include? current_user.uuid rescue false)))) or false
   end
 
+  def deletable?
+    editable?
+  end
+
+  def self.api_exists?(method)
+    arvados_api_client.discovery[:resources][self.to_s.underscore.pluralize.to_sym].andand[:methods].andand[method]
+  end
+
   # Array of strings that are the names of attributes that can be edited
   # with X-Editable.
   def editable_attributes