labimotion 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55758d962c5628b469e7c55a72666411eb4f23a2e55a863b9b75baef02edd9d7
4
- data.tar.gz: 46497569a5a844d76be344c12f73f156d2cf7fa2af98817d89e0335eaa17292c
3
+ metadata.gz: 1618c815a5e643e1defe701789af1eb30a3e7e2a166bf65d0b0657893099cd38
4
+ data.tar.gz: 66379371379950fb9666a7472954f9b54087b04095ce23444ce8c463c075e173
5
5
  SHA512:
6
- metadata.gz: e22f4a946c2729b3ba8adfc702308b38f67fa6a5314eb12c375d0369fa84c0f49eec45984989f15cbc8dee70319f69650f2a67f9b0e988470964840db60dc326
7
- data.tar.gz: 0ba7d3e49cad20b91e8d8edbaadba114a8bae0d72c07c8b65a74c712fc9b0823a12a9bf9d9d98b9e75dcc9ac14a7c5e8b856eeebeef942dd82a93b6fdedff788
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
@@ -9,9 +9,9 @@ module Labimotion
9
9
  before_save :check_identifier
10
10
  end
11
11
 
12
-
12
+
13
13
  def check_identifier
14
- self.identifier = identifier || SecureRandom.uuid
14
+ self.identifier = identifier || SecureRandom.uuid if self.has_attribute?(:identifier)
15
15
  end
16
16
 
17
17
  def create_klasses_revision(current_user)
@@ -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'
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
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