rest_framework 0.9.11 → 0.9.14

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: 04ef01197efeca7c6276edbf2ed4c9ef3f50e4fc4d1df927c3d530953d5aab2a
4
- data.tar.gz: 71bd781956d163f33cdc7fd6aa3950ce93d4f86a0c03325e2bebcd2ba1dfc74b
3
+ metadata.gz: f0a39ff15a5a6714fb7dc52f11e7db3cebe918805a44b0a8486567debebcefac
4
+ data.tar.gz: 5e2e530f249b567c64bb0d527875b291180052b07d61919bbbf76ae3f5ad7b1b
5
5
  SHA512:
6
- metadata.gz: 96cbf98cec8f47c54309fa5b2b46c90c60249e7da1fa7142ef85c041bfee1154b9fd60c5d420d145a2dfb852df4d8af906e3577cb2f5f70d0bc6fd2da9beeb97
7
- data.tar.gz: 4b0ab5e4d529f54e4890c8e0da2763ee8915a393ce1260da5c7ce70d6ef940c64e36f15d5a5b70cca255ec881c53b4c48bbcd5f95f2e7d83cc88e233b623b327
6
+ metadata.gz: c15b1d0904dc34e2cbc095628b5d642213c0d33b6387e52b38660cf78b6552bc32818dca5ecbc5de710502139c7308fffb67a0a2aa3049749833c5e64a6757b5
7
+ data.tar.gz: 5656754554aa3bb4acc7ee333b72f21ea848d3e3cc8c06acf9e16d3529b427acfec9e00b3bac3ae67536b39608640146bcaab1459db77a7c6c46e6545e72dbae
data/README.md CHANGED
@@ -149,4 +149,4 @@ end
149
149
  After you clone the repository, cd'ing into the directory should create a new gemset if you are using RVM.
150
150
  Then run `bin/setup` to install the appropriate gems and set things up.
151
151
 
152
- The top-level `bin/rails` proxies all Rails commands to the test project, so you can operate it via the usual commands (e.g., `rails test`, `rails server` and `rails console`).
152
+ The top-level `bin/rails` proxies all Rails commands to the test project, so you can operate it via the usual commands (e.g., `rails test`, `rails server` and `rails console`). For development, use `foreman start` to run the web server and the job queue.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.11
1
+ 0.9.14
@@ -10,13 +10,14 @@
10
10
  </label>
11
11
  </div>
12
12
 
13
- <%= form_with(
13
+ <%= form_with(**{
14
14
  model: @record,
15
15
  url: "",
16
16
  method: :patch,
17
17
  id: "htmlForm",
18
18
  scope: "",
19
- ) do |form| %>
19
+ local: true,
20
+ }.compact) do |form| %>
20
21
  <% controller.get_fields.map(&:to_s).each do |f| %>
21
22
  <%
22
23
  # Don't provide form fields for associations or primary keys.
@@ -32,12 +32,13 @@
32
32
  <% if @is_model_controller && model = controller.class.get_model %>
33
33
  <% if attachment_reflections = model.attachment_reflections.presence %>
34
34
  <div class="mb-2" style="display: none" id="rawFilesFormWrapper">
35
- <%= form_with(
35
+ <%= form_with(**{
36
36
  model: @record,
37
37
  url: "",
38
38
  id: "rawFilesForm",
39
39
  scope: "",
40
- ) do |form| %>
40
+ local: true,
41
+ }.compact) do |form| %>
41
42
  <% attachment_reflections.each do |field, ref| %>
42
43
  <label class="form-label w-100"><%= controller.class.get_label(field) %>
43
44
  <%= form.file_field field, multiple: ref.macro == :has_many_attached %>
@@ -16,7 +16,8 @@ class RESTFramework::Filters::ModelOrderingFilter < RESTFramework::Filters::Base
16
16
  if order_string.present?
17
17
  ordering = {}.with_indifferent_access
18
18
 
19
- order_string.split(",").each do |field|
19
+ order_string = order_string.join(",") if order_string.is_a?(Array)
20
+ order_string.split(",").map(&:strip).each do |field|
20
21
  if field[0] == "-"
21
22
  column = field[1..-1]
22
23
  direction = :desc
@@ -22,8 +22,6 @@ module RESTFramework::Mixins::BaseModelControllerMixin
22
22
 
23
23
  # Options for what should be included/excluded from default fields.
24
24
  exclude_associations: false,
25
- include_active_storage: false,
26
- include_action_text: false,
27
25
  }
28
26
  RRF_BASE_MODEL_INSTANCE_CONFIG = {
29
27
  # Attributes for finding records.
@@ -221,6 +221,14 @@ class RESTFramework::Serializers::NativeSerializer < RESTFramework::Serializers:
221
221
  self.define_singleton_method(f) do |record|
222
222
  next record.send(f).limit(limit).as_json(**sub_config)
223
223
  end
224
+
225
+ # Disable this for now, as it's not clear if this improves performance of count.
226
+ #
227
+ # # Even though we use a serializer method, if the count will later be added, then put
228
+ # # this field into the includes_map.
229
+ # if @controller.native_serializer_include_associations_count
230
+ # includes_map[f] = f.to_sym
231
+ # end
224
232
  else
225
233
  includes[f] = sub_config
226
234
  includes_map[f] = f.to_sym
@@ -15,13 +15,18 @@ module RESTFramework::Utils
15
15
  # Symbolize keys (which also makes a copy so we don't mutate the original).
16
16
  v = v.symbolize_keys
17
17
  methods = v.delete(:methods)
18
+ if v.key?(:method)
19
+ methods = v.delete(:method)
20
+ end
18
21
 
19
22
  # First, remove the route metadata.
20
23
  metadata = v.delete(:metadata) || {}
21
24
 
22
25
  # Add label to fields.
23
26
  if controller && metadata[:fields]
24
- metadata[:fields] = metadata[:fields].map { |f| [f, {}] }.to_h if f.is_a?(Array)
27
+ metadata[:fields] = metadata[:fields].map { |f|
28
+ [f, {}]
29
+ }.to_h if metadata[:fields].is_a?(Array)
25
30
  metadata[:fields]&.each do |field, cfg|
26
31
  cfg[:label] = controller.get_label(field) unless cfg[:label]
27
32
  end
@@ -99,12 +104,10 @@ module RESTFramework::Utils
99
104
  return route_props, application_routes.routes.select { |r|
100
105
  # We `select` first to avoid unnecessarily calculating metadata for routes we don't even want
101
106
  # to show.
102
- (
103
- (r.defaults[:subdomain].blank? || r.defaults[:subdomain] == request.subdomain) &&
107
+ (r.defaults[:subdomain].blank? || r.defaults[:subdomain] == request.subdomain) &&
104
108
  current_comparable_path.match?(self.comparable_path(r.path.spec.to_s)) &&
105
109
  r.defaults[:controller].present? &&
106
110
  r.defaults[:action].present?
107
- )
108
111
  }.map { |r|
109
112
  path = r.path.spec.to_s.gsub("(.:format)", "")
110
113
  levels = path.count("/")
@@ -171,15 +174,12 @@ module RESTFramework::Utils
171
174
  # strings, not symbols.
172
175
  def self.fields_for(model, exclude_associations: nil)
173
176
  foreign_keys = model.reflect_on_all_associations(:belongs_to).map(&:foreign_key)
177
+ base_fields = model.column_names.reject { |c| c.in?(foreign_keys) }
174
178
 
175
- if exclude_associations
176
- return model.column_names.reject { |c| c.in?(foreign_keys) }
177
- end
179
+ return base_fields if exclude_associations
178
180
 
179
181
  # Add associations in addition to normal columns.
180
- return model.column_names.reject { |c|
181
- c.in?(foreign_keys)
182
- } + model.reflections.map { |association, ref|
182
+ return base_fields + model.reflections.map { |association, ref|
183
183
  # Ignore associations for which we have custom integrations.
184
184
  if ref.class_name.in?(%w(ActiveStorage::Attachment ActiveStorage::Blob ActionText::RichText))
185
185
  next nil
@@ -149,7 +149,7 @@ module RESTFramework
149
149
  # Freeze configuration attributes during finalization to prevent accidental mutation.
150
150
  attr_accessor :freeze_config
151
151
 
152
- # Specify reverse association tables that are typically very large, andd therefore should not be
152
+ # Specify reverse association tables that are typically very large, and therefore should not be
153
153
  # added to fields by default.
154
154
  attr_accessor :large_reverse_association_tables
155
155
 
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.11
4
+ version: 0.9.14
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: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2024-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails