labimotion 1.3.1.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45876f170c9ebeb8292483cd8d6de0c56f5b341b22ce861a3994c93a6344e665
4
- data.tar.gz: ac171314ea6ce8b2c9c04bf03b3f84eddf84c10508381bf088d658a5a511c11e
3
+ metadata.gz: 1618c815a5e643e1defe701789af1eb30a3e7e2a166bf65d0b0657893099cd38
4
+ data.tar.gz: 66379371379950fb9666a7472954f9b54087b04095ce23444ce8c463c075e173
5
5
  SHA512:
6
- metadata.gz: caab23ae23ce25b9b4472b23f58ee7b86e3f4fc9813ceac5a9dda0810c053f1fdc1f2f7ada3f294c826091246b167646085301a336c34cb9f72e70f9a3fc854e
7
- data.tar.gz: 60befb364746e5f8a0ea6ea89fe7713857f61ca20c013b51eb744fb0c9152ef315e83546ccb5a61ec9e33f989be473d16869eec582628651a86e49f0a13489b6
6
+ metadata.gz: f735c423f7975f6155be3d129b9b3918b8c64b019e45c146e148cefd66f5184f62d982d117b6f1c863822446776d6f9a91ba5b4be479ad79457aa9629e903286
7
+ data.tar.gz: dbb7a6e448818ceceb32f885725167e99efa5bd2ef142e241c6c58f4a9dd74fa36713cf4e66434fed7cf74b3a64b1ef2830e5c2fc258cc8443216bb7e526baef
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'labimotion/version'
3
+
4
+ module Labimotion
5
+ ## ExportDataset
6
+ class AttachmentHandler
7
+ def self.copy(original_attach, element_id, element_type, current_user_id)
8
+ copy_attach = Attachment.new(
9
+ attachable_id: element_id,
10
+ attachable_type: element_type,
11
+ aasm_state: original_attach.aasm_state,
12
+ created_by: current_user_id,
13
+ created_for: current_user_id,
14
+ filename: original_attach.filename,
15
+ )
16
+ copy_attach.save
17
+
18
+ copy_io = original_attach.attachment_attacher.get.to_io
19
+ attacher = copy_attach.attachment_attacher
20
+ attacher.attach copy_io
21
+ copy_attach.file_path = copy_io.path
22
+ copy_attach.save
23
+
24
+ Usecases::Attachments::Copy.update_annotation(original_attach.id, copy_attach.id) if (original_attach.attachment_data && original_attach.attachment_data['derivatives'])
25
+ copy_attach
26
+ end
27
+
28
+ end
29
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'labimotion/utils/utils'
4
+ require 'labimotion/libs/attachment_handler'
4
5
 
5
6
  module Labimotion
6
7
  # Segmentable concern
@@ -29,7 +30,8 @@ module Labimotion
29
30
 
30
31
  att = Attachment.find_by(id: aid)
31
32
  att = Attachment.find_by(identifier: uid) if att.nil?
32
- copied_att = att&.copy(attachable_type: Labimotion::Prop::SEGMENTPROPS, attachable_id: segment.id, transferred: true)
33
+ copied_att = Labimotion::AttachmentHandler.copy(att, segment.id, Labimotion::Prop::SEGMENTPROPS, args[:current_user_id])
34
+
33
35
  if copied_att.nil?
34
36
  properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS][idx]['value']['files'].delete_at(fdx)
35
37
  else
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## Labimotion Version
4
4
  module Labimotion
5
- VERSION = '1.3.1.1'
5
+ VERSION = '1.3.2'
6
6
  end
data/lib/labimotion.rb CHANGED
@@ -62,6 +62,7 @@ module Labimotion
62
62
  autoload :ExportDataset, 'labimotion/libs/export_dataset'
63
63
  autoload :SampleAssociation, 'labimotion/libs/sample_association'
64
64
  autoload :PropertiesHandler, 'labimotion/libs/properties_handler'
65
+ autoload :AttachmentHandler, 'labimotion/libs/attachment_handler'
65
66
 
66
67
  ######## Utils
67
68
  autoload :Prop, 'labimotion/utils/prop'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labimotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chia-Lin Lin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-05-07 00:00:00.000000000 Z
12
+ date: 2024-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - lib/labimotion/helpers/sample_association_helpers.rb
67
67
  - lib/labimotion/helpers/search_helpers.rb
68
68
  - lib/labimotion/helpers/segment_helpers.rb
69
+ - lib/labimotion/libs/attachment_handler.rb
69
70
  - lib/labimotion/libs/converter.rb
70
71
  - lib/labimotion/libs/export_dataset.rb
71
72
  - lib/labimotion/libs/export_element.rb