Merge branch '3877-log-memory-leak' closes #3877
[arvados.git] / apps / workbench / app / models / job.rb
index a779d8d236f183f5bf14baa9b2047f1aa8ed15d4..9e9c0967871ba4e6408a79c1855b87460f156694 100644 (file)
@@ -1,2 +1,44 @@
-class Job < OrvosBase
+class Job < ArvadosBase
+  def self.goes_in_projects?
+    true
+  end
+
+  def content_summary
+    "#{script} job"
+  end
+
+  def attribute_editable? attr, *args
+    if attr.to_sym == :description
+      super && attr.to_sym == :description
+    else
+      false
+    end
+  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
+
+  def textile_attributes
+    [ 'description' ]
+  end
 end