rails_admin_draft 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50f58bc7bf92dc6416841d6c1f6d45ec06d10c08c8c2c73c6ef44d9a992c0fc0
|
4
|
+
data.tar.gz: e9c3a67f666a61995fd37c687b9b2a1b35d0cfde738e905b6f2d5af2e47a19b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d727b538cd1d7c1ee072fd03575215df9c651f9396f31dc5f58af2c2246e55f13ff49f5741f460a37351221351877dc0dfbbc6693def7bde51607b996b50b639
|
7
|
+
data.tar.gz: 845c88469340f36465b6b71f91dbd2e5ca1b7afc69edb15e06b0a22e3fd5abd4ca4dfc35edd7f1a324d63c9c1255db67ffd1bae83532a18cc170ce69462f4451
|
@@ -55,22 +55,27 @@ module DraftConcern
|
|
55
55
|
return if !self.is_draft?
|
56
56
|
model_to_publish = self
|
57
57
|
|
58
|
-
|
59
|
-
if
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
58
|
+
if self.draft_source_id.present?
|
59
|
+
# Save new image if we publish directly the draft
|
60
|
+
self.image.store! if self.image.present?
|
61
|
+
self.save!
|
62
|
+
|
63
|
+
model_to_publish = Draft::OverwriteService.new(source: self, destination: self.draft_source).perform
|
64
|
+
model_to_publish.slug = self.slug # Keep same slug
|
65
|
+
|
66
|
+
if Object.const_defined?('DiscardConcern') && self.class.include?('DiscardConcern'.constantize)
|
67
|
+
self.image.remove!
|
68
|
+
self.destroy(true)
|
69
|
+
else
|
70
|
+
self.image.remove!
|
71
|
+
self.destroy
|
68
72
|
end
|
69
|
-
|
70
|
-
model_to_publish.draft_status = DraftStatus::PUBLISHED
|
71
|
-
model_to_publish.save!
|
73
|
+
remove_draft_on_unique_text_fields(model_to_publish)
|
72
74
|
end
|
73
75
|
|
76
|
+
model_to_publish.draft_status = DraftStatus::PUBLISHED
|
77
|
+
model_to_publish.save!
|
78
|
+
|
74
79
|
return model_to_publish
|
75
80
|
end
|
76
81
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Draft
|
2
4
|
class OverwriteService
|
3
5
|
DRAFT_ASSOCIATIONS = [:draft, :draft_source]
|
@@ -46,8 +48,26 @@ module Draft
|
|
46
48
|
return if attributes.blank?
|
47
49
|
|
48
50
|
attributes.each do |attribute|
|
49
|
-
|
51
|
+
if @destination.send(attribute).present?
|
52
|
+
destination_path = File.dirname(File.open(@destination.send(attribute).file.path))
|
53
|
+
@destination.send(attribute).remove!
|
54
|
+
|
55
|
+
end
|
56
|
+
|
50
57
|
new_upload = @source.send(attribute).present? ? File.open(@source.send(attribute).file.path) : nil
|
58
|
+
|
59
|
+
if @source.image.present?
|
60
|
+
dir_source = @source.send(attribute).file.path.remove(@source.send(attribute).identifier)
|
61
|
+
|
62
|
+
Dir[File.join(dir_source, "*#{@source.send(attribute).identifier}")].each do | filename |
|
63
|
+
# copy if image destination is present
|
64
|
+
FileUtils.mv(filename, destination_path) if destination_path.present?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Delete folder
|
69
|
+
FileUtils.remove_dir(dir_source, true) if dir_source.present?
|
70
|
+
|
51
71
|
@destination.send("#{attribute}=", new_upload)
|
52
72
|
end
|
53
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_draft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grégory Huet
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-02-
|
12
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|