custom_fields 2.10.0.beta2 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/custom_fields/extensions/carrierwave.rb +21 -5
- data/lib/custom_fields/types/file.rb +9 -0
- data/lib/custom_fields/version.rb +1 -1
- data/lib/custom_fields.rb +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a51660465e7fc7fcce0e0d68721fd629e3a7d970da166fda4166c964aa9c1c6a
|
4
|
+
data.tar.gz: 3dec7501714fa700975e47dfc2989e78ad31e070ec47cf7a0c79f30e4b64bd1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29c47fa50966d7c86e8a1ab6b92240f630ac471b0fa4c0824b0e7c63cd161c0d0d94566735689b98acd453dbfccca8de2fc59244619f3dc0b34456c025bf6f7e
|
7
|
+
data.tar.gz: ad06f66129e77dc3297256ba4645170040d408724deee848bc4cfbe119d4e52ab2e8a7aa11ad3e399544d2acfcfe7b6f0cd9defe90b44ab9729beb0f966e0154
|
@@ -8,9 +8,10 @@ module CarrierWave
|
|
8
8
|
mount_uploader_without_localization(column, uploader, options, &block)
|
9
9
|
|
10
10
|
define_method(:read_uploader) do |name|
|
11
|
-
# puts "read_uploader #{name} / #{read_attribute(name.to_sym).inspect}" # DEBUG
|
11
|
+
# puts "read_uploader #{name} / #{read_attribute(name.to_sym).inspect} / #{::Mongoid::Fields::I18n.locale.inspect}" # DEBUG
|
12
12
|
|
13
13
|
value = read_attribute(name.to_sym)
|
14
|
+
|
14
15
|
unless value.nil?
|
15
16
|
self.class.fields[name.to_s].demongoize(value)
|
16
17
|
else
|
@@ -26,15 +27,30 @@ module CarrierWave
|
|
26
27
|
|
27
28
|
class Mounter
|
28
29
|
|
29
|
-
def remove_previous_with_localization(before=nil, after=nil)
|
30
|
-
_after = after
|
30
|
+
def remove_previous_with_localization(before = nil, after = nil)
|
31
|
+
_before, _after = before, after
|
32
|
+
locale = ::Mongoid::Fields::I18n.locale.to_s
|
33
|
+
|
34
|
+
# custom case:
|
35
|
+
# the record owns a localized file field. A new file has been attached to it
|
36
|
+
# in the default locale. Now, we want to upload a file in another locale with
|
37
|
+
# a different name.
|
38
|
+
# We absolutely don't want to erase the file in the default locale
|
39
|
+
if record.class.fields[column.to_s]&.localized? &&
|
40
|
+
record.changes[column]&.first == '_new_'
|
41
|
+
_before = [nil]
|
42
|
+
end
|
43
|
+
|
44
|
+
# FIXME: can't reproduce this behavior locally but it happens in production
|
45
|
+
if before && before.first.is_a?(Hash)
|
46
|
+
_before = [before.first[locale]]
|
47
|
+
end
|
31
48
|
|
32
49
|
if after && after.first.is_a?(Hash)
|
33
|
-
locale = ::Mongoid::Fields::I18n.locale.to_s
|
34
50
|
_after = [after.first[locale]]
|
35
51
|
end
|
36
52
|
|
37
|
-
remove_previous_without_localization(
|
53
|
+
remove_previous_without_localization(_before, _after)
|
38
54
|
end
|
39
55
|
|
40
56
|
alias_method :remove_previous_without_localization, :remove_previous
|
@@ -87,6 +87,15 @@ module CustomFields
|
|
87
87
|
|
88
88
|
process :set_size_in_model
|
89
89
|
|
90
|
+
def filename
|
91
|
+
if original_filename && model.fields[mounted_as.to_s].localized?
|
92
|
+
_original_filename, extension = original_filename.split('.')
|
93
|
+
["#{_original_filename}_#{::Mongoid::Fields::I18n.locale}", extension].compact.join('.')
|
94
|
+
else
|
95
|
+
original_filename
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
90
99
|
def set_size_in_model
|
91
100
|
size_field_name = :"#{mounted_as}_size"
|
92
101
|
|
data/lib/custom_fields.rb
CHANGED
@@ -10,7 +10,7 @@ Money.locale_backend = :currency
|
|
10
10
|
module CustomFields
|
11
11
|
|
12
12
|
@@options = {
|
13
|
-
reserved_names: Mongoid.destructive_fields + %w(id _id send class destroy),
|
13
|
+
reserved_names: Mongoid.destructive_fields + %w(id _id send class destroy system),
|
14
14
|
default_currency: 'EUR'
|
15
15
|
}
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.
|
39
|
+
version: 1.3.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.3.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,15 +160,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements:
|
161
161
|
- - "~>"
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '2.
|
163
|
+
version: '2.6'
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
|
-
- - "
|
166
|
+
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version: '
|
168
|
+
version: '0'
|
169
169
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.7.3
|
170
|
+
rubygems_version: 3.1.4
|
172
171
|
signing_key:
|
173
172
|
specification_version: 4
|
174
173
|
summary: Custom fields extension for Mongoid.
|