Merge branch 'master' into 3699-arv-copy
[arvados.git] / apps / workbench / app / models / job.rb
1 class Job < ArvadosBase
2   def self.goes_in_projects?
3     true
4   end
5
6   def content_summary
7     "#{script} job"
8   end
9
10   def attribute_editable? attr, *args
11     if attr.to_sym == :description
12       super && attr.to_sym == :description
13     else
14       false
15     end
16   end
17
18   def self.creatable?
19     false
20   end
21
22   def default_name
23     if script
24       x = "\"#{script}\" job"
25     else
26       x = super
27     end
28     if finished_at
29       x += " finished #{finished_at.strftime('%b %-d')}"
30     elsif started_at
31       x += " started #{started_at.strftime('%b %-d')}"
32     elsif created_at
33       x += " submitted #{created_at.strftime('%b %-d')}"
34     end
35   end
36
37   def cancel
38     arvados_api_client.api "jobs/#{self.uuid}/", "cancel", {}
39   end
40
41   def textile_attributes
42     [ 'description' ]
43   end
44 end