2809: Merge branch 'master' into 2809-workbench-rails4 refs #2809
[arvados.git] / apps / workbench / app / models / collection.rb
1 class Collection < ArvadosBase
2   include ApplicationHelper
3
4   MD5_EMPTY = 'd41d8cd98f00b204e9800998ecf8427e'
5
6   # Return true if the given string is the locator of a zero-length blob
7   def self.is_empty_blob_locator? locator
8     !!locator.to_s.match("^#{MD5_EMPTY}(\\+.*)?\$")
9   end
10
11   def content_summary
12     human_readable_bytes_html(total_bytes) + " " + super
13   end
14
15   def total_bytes
16     if files
17       tot = 0
18       files.each do |file|
19         tot += file[2]
20       end
21       tot
22     end
23   end
24
25   def attribute_editable?(attr)
26     false
27   end
28
29   def self.creatable?
30     false
31   end
32
33   def provenance
34     arvados_api_client.api "collections/#{self.uuid}/", "provenance"
35   end
36
37   def used_by
38     arvados_api_client.api "collections/#{self.uuid}/", "used_by"
39   end
40
41 end