Merge branch '3889-functional-testing-TC' into 3889-functional-testing
[arvados.git] / apps / workbench / app / models / job.rb
index 309cadeb69554e1aac0a6dbeaa10b92d7adee30f..d3d38b0b2dbc6109e54cf94afd1ba890e7b3622e 100644 (file)
@@ -8,7 +8,11 @@ class Job < ArvadosBase
   end
 
   def attribute_editable? attr, *args
-    false
+    if attr.to_sym == :description
+      super && attr.to_sym == :description
+    else
+      false
+    end
   end
 
   def self.creatable?
@@ -34,13 +38,21 @@ class Job < ArvadosBase
     arvados_api_client.api "jobs/#{self.uuid}/", "cancel", {}
   end
 
-  def state
-    Job::state(self)
+  def self.queue_size
+    arvados_api_client.api("jobs/", "queue_size", {"_method"=> "GET"})[:queue_size] rescue 0
+  end
+
+  def self.queue 
+    arvados_api_client.unpack_api_response arvados_api_client.api("jobs/", "queue", {"_method"=> "GET"})
   end
 
   def self.state job
+    if job.respond_to? :state and job.state
+      return job.state
+    end
+
     if not job[:cancelled_at].nil?
-      "Canceled"
+      "Cancelled"
     elsif not job[:finished_at].nil? or not job[:success].nil?
       if job[:success]
         "Completed"
@@ -54,4 +66,7 @@ class Job < ArvadosBase
     end
   end
 
+  def textile_attributes
+    [ 'description' ]
+  end
 end