rest_framework 0.9.14 → 0.9.15

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: f0a39ff15a5a6714fb7dc52f11e7db3cebe918805a44b0a8486567debebcefac
4
- data.tar.gz: 5e2e530f249b567c64bb0d527875b291180052b07d61919bbbf76ae3f5ad7b1b
3
+ metadata.gz: 734af1c9a436fd842c36503794ef16b94e4b0d3f7ad91d011bcd12d06e4b1e21
4
+ data.tar.gz: d4c0140985a5405750cdd092c4a70b092be69b3523a3c088d2268711c38e5ad1
5
5
  SHA512:
6
- metadata.gz: c15b1d0904dc34e2cbc095628b5d642213c0d33b6387e52b38660cf78b6552bc32818dca5ecbc5de710502139c7308fffb67a0a2aa3049749833c5e64a6757b5
7
- data.tar.gz: 5656754554aa3bb4acc7ee333b72f21ea848d3e3cc8c06acf9e16d3529b427acfec9e00b3bac3ae67536b39608640146bcaab1459db77a7c6c46e6545e72dbae
6
+ metadata.gz: 4fc442c77a0c8543913ceacd7a7116f9e044ee1d9b0e3e08a5c58ddb6d00ee12b7f719c83e7aed233070075bb031aa8a90cabc7337bd57e28883aca4221d5ea6
7
+ data.tar.gz: 2f60ffddea13e956a3a0a0ec909d2de533cc0c5b350af75467f7e006b5133c982192cbcc28da7cb566803458c76917ae702f4838c3f0096722a94f5309babb7a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.14
1
+ 0.9.15
@@ -6,9 +6,11 @@ module RESTFramework::Mixins::BaseModelControllerMixin
6
6
  return {
7
7
  io: StringIO.new(Base64.decode64(payload)),
8
8
  content_type: content_type,
9
- filename: "image_#{field}#{Rack::Mime::MIME_TYPES.invert[content_type]}",
9
+ filename: "file_#{field}#{Rack::Mime::MIME_TYPES.invert[content_type]}",
10
10
  }
11
11
  }
12
+ ACTIVESTORAGE_KEYS = [:io, :content_type, :filename, :identify, :key]
13
+
12
14
  include RESTFramework::BaseControllerMixin
13
15
 
14
16
  RRF_BASE_MODEL_CONFIG = {
@@ -411,18 +413,21 @@ module RESTFramework::Mixins::BaseModelControllerMixin
411
413
  # For fields, automatically add `_id`/`_ids` and `_attributes` variations for associations.
412
414
  variations = []
413
415
  hash_variations = {}
416
+ alt_hash_variations = {}
414
417
  reflections = self.class.get_model.reflections
415
418
  @_get_allowed_parameters = self.get_fields.map { |f|
416
419
  f = f.to_s
417
420
 
418
421
  # ActiveStorage Integration: `has_one_attached`.
419
422
  if reflections.key?("#{f}_attachment")
423
+ hash_variations[f] = ACTIVESTORAGE_KEYS
420
424
  next f
421
425
  end
422
426
 
423
427
  # ActiveStorage Integration: `has_many_attached`.
424
428
  if reflections.key?("#{f}_attachments")
425
429
  hash_variations[f] = []
430
+ alt_hash_variations[f] = ACTIVESTORAGE_KEYS
426
431
  next nil
427
432
  end
428
433
 
@@ -443,7 +448,9 @@ module RESTFramework::Mixins::BaseModelControllerMixin
443
448
  end
444
449
 
445
450
  if self.permit_nested_attributes_assignment
446
- hash_variations["#{f}_attributes"] = self.class.get_field_config(f)[:sub_fields]
451
+ hash_variations["#{f}_attributes"] = (
452
+ self.class.get_field_config(f)[:sub_fields] + ["_destroy"]
453
+ )
447
454
  end
448
455
 
449
456
  # Associations are not allowed to be submitted in their bare form.
@@ -451,6 +458,7 @@ module RESTFramework::Mixins::BaseModelControllerMixin
451
458
  }.compact
452
459
  @_get_allowed_parameters += variations
453
460
  @_get_allowed_parameters << hash_variations
461
+ @_get_allowed_parameters << alt_hash_variations
454
462
  return @_get_allowed_parameters
455
463
  end
456
464
 
@@ -520,14 +528,22 @@ module RESTFramework::Mixins::BaseModelControllerMixin
520
528
  #
521
529
  # rubocop:enable Layout/LineLength
522
530
  self.class.get_model.attachment_reflections.keys.each do |k|
523
- next unless (body_params[k].is_a?(String) && body_params[k].match?(BASE64_REGEX)) ||
524
- (body_params[k].is_a?(Array) && body_params[k].all? { |v|
525
- v.is_a?(String) && v.match?(BASE64_REGEX)
526
- })
527
-
528
531
  if body_params[k].is_a?(Array)
529
- body_params[k] = body_params[k].map { |v| BASE64_TRANSLATE.call(k, v) }
530
- else
532
+ body_params[k] = body_params[k].map { |v|
533
+ if v.is_a?(String)
534
+ BASE64_TRANSLATE.call(k, v)
535
+ elsif v.is_a?(ActionController::Parameters)
536
+ if v[:io].is_a?(String)
537
+ v[:io] = StringIO.new(Base64.decode64(v[:io]))
538
+ end
539
+ v
540
+ end
541
+ }
542
+ elsif body_params[k].is_a?(ActionController::Parameters)
543
+ if body_params[k][:io].is_a?(String)
544
+ body_params[k][:io] = StringIO.new(Base64.decode64(body_params[k][:io]))
545
+ end
546
+ elsif body_params[k].is_a?(String)
531
547
  body_params[k] = BASE64_TRANSLATE.call(k, body_params[k])
532
548
  end
533
549
  end
@@ -271,6 +271,9 @@ class RESTFramework::Serializers::NativeSerializer < RESTFramework::Serializers:
271
271
  end
272
272
  elsif @model.method_defined?(f)
273
273
  methods << f
274
+ else
275
+ # Assume anything else is a virtual column.
276
+ columns << f
274
277
  end
275
278
  end
276
279
 
@@ -159,9 +159,10 @@ module RESTFramework::Utils
159
159
  )
160
160
  parsed_fields += fields_hash[:include].map(&:to_s) if fields_hash[:include]
161
161
  parsed_fields -= fields_hash[:exclude].map(&:to_s) if fields_hash[:exclude]
162
+ parsed_fields -= fields_hash[:except].map(&:to_s) if fields_hash[:except]
162
163
 
163
164
  # Warn for any unknown keys.
164
- (fields_hash.keys - [:only, :include, :exclude]).each do |k|
165
+ (fields_hash.keys - [:only, :except, :include, :exclude]).each do |k|
165
166
  Rails.logger.warn("RRF: Unknown key in fields hash: #{k}")
166
167
  end
167
168
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.9.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory N. Schmit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-06 00:00:00.000000000 Z
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails