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