rest_framework 0.7.9 → 0.7.10
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 +4 -4
- data/VERSION +1 -1
- data/lib/rest_framework/controller_mixins/models.rb +13 -10
- data/lib/rest_framework/filters.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71c34ceb6bb68b3b9ea023e62fa2fc5d6ea3382fad38a94d32c235d66fe87281
|
4
|
+
data.tar.gz: d4300ef78a151d25f0d67b74df5d1d6584e0452e3ff3e719ddae41ece6aa3cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce6946077715c32b8e7f5d08c8df1b1d1ae9f7b714c5ed8411a4086ba5fe8a96328179fdf7685c26b7fce7d8d208dba1045d499952b4980c0a3cfac71364cc07
|
7
|
+
data.tar.gz: a4da9fd65a971ddad1e596927d95ff7088fbd6429df007941ef2c990ab08df19d8891abb22166a5cc13ae155438cfc04aa63868060ea4f2c647023a707f45a71
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.10
|
@@ -127,7 +127,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
127
127
|
config = self.field_config&.dig(f.to_sym) || {}
|
128
128
|
|
129
129
|
# Default sub-fields if field is an association.
|
130
|
-
if ref = self.get_model.reflections[f]
|
130
|
+
if ref = self.get_model.reflections[f.to_s]
|
131
131
|
if ref.polymorphic?
|
132
132
|
columns = {}
|
133
133
|
else
|
@@ -218,7 +218,7 @@ module RESTFramework::BaseModelControllerMixin
|
|
218
218
|
if self.permit_id_assignment
|
219
219
|
if ref.collection?
|
220
220
|
metadata[:id_field] = "#{f.singularize}_ids"
|
221
|
-
|
221
|
+
elsif ref.belongs_to?
|
222
222
|
metadata[:id_field] = "#{f}_id"
|
223
223
|
end
|
224
224
|
end
|
@@ -396,26 +396,29 @@ module RESTFramework::BaseModelControllerMixin
|
|
396
396
|
return @allowed_parameters = nil unless fields = self.get_fields
|
397
397
|
|
398
398
|
# For fields, automatically add `_id`/`_ids` and `_attributes` variations for associations.
|
399
|
-
|
399
|
+
id_variations = []
|
400
|
+
variations = {}
|
401
|
+
@allowed_parameters = fields.map { |f|
|
400
402
|
f = f.to_s
|
401
403
|
next f unless ref = self.class.get_model.reflections[f]
|
402
404
|
|
403
|
-
variations = [f]
|
404
|
-
|
405
405
|
if self.class.permit_id_assignment
|
406
406
|
if ref.collection?
|
407
|
-
variations
|
408
|
-
|
409
|
-
|
407
|
+
variations["#{f.singularize}_ids"] = []
|
408
|
+
elsif ref.belongs_to?
|
409
|
+
id_variations << "#{f}_id"
|
410
410
|
end
|
411
411
|
end
|
412
412
|
|
413
413
|
if self.class.permit_nested_attributes_assignment
|
414
|
-
variations
|
414
|
+
variations["#{f}_attributes"] = self.class.get_field_config(f)[:sub_fields] || {}
|
415
415
|
end
|
416
416
|
|
417
|
-
next
|
417
|
+
next f
|
418
418
|
}.flatten
|
419
|
+
@allowed_parameters += id_variations
|
420
|
+
@allowed_parameters << variations
|
421
|
+
return @allowed_parameters
|
419
422
|
end
|
420
423
|
|
421
424
|
# Get the configured serializer class, or `NativeSerializer` as a default.
|
@@ -33,7 +33,7 @@ class RESTFramework::ModelFilter < RESTFramework::BaseFilter
|
|
33
33
|
field, sub_field = match[1..2]
|
34
34
|
next false unless field.in?(fields)
|
35
35
|
|
36
|
-
sub_fields = @controller.class.get_field_config(field)[:sub_fields]
|
36
|
+
sub_fields = @controller.class.get_field_config(field)[:sub_fields] || []
|
37
37
|
next sub_field.in?(sub_fields)
|
38
38
|
end
|
39
39
|
|