Merge branch 'master' into 3699-arv-copy
[arvados.git] / apps / workbench / app / models / job.rb
index 56428abb2c54e3b2ea0967d2a08da2bb2092b62e..aac6168d22aecac8d37d9afcaee56db844cecdcd 100644 (file)
@@ -1,13 +1,36 @@
 class Job < ArvadosBase
-  def self.goes_in_folders?
+  def self.goes_in_projects?
     true
   end
 
-  def attribute_editable?(attr)
+  def content_summary
+    "#{script} job"
+  end
+
+  def attribute_editable? attr, *args
     false
   end
 
   def self.creatable?
     false
   end
+
+  def default_name
+    if script
+      x = "\"#{script}\" job"
+    else
+      x = super
+    end
+    if finished_at
+      x += " finished #{finished_at.strftime('%b %-d')}"
+    elsif started_at
+      x += " started #{started_at.strftime('%b %-d')}"
+    elsif created_at
+      x += " submitted #{created_at.strftime('%b %-d')}"
+    end
+  end
+
+  def cancel
+    arvados_api_client.api "jobs/#{self.uuid}/", "cancel", {}
+  end
 end