forest_liana 8.0.12 → 8.0.13

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: 6592c0518a6920b5890863db5cb955631b701a72945ae502c22dda2709108bb5
4
- data.tar.gz: 4706528fb145a74b3baa116129e93b1be5e5f4834c04bedb697309968cea237a
3
+ metadata.gz: 26515d9f2fe7d7fab4a83357eb633fef70a24497248f819dc49f816376adaa66
4
+ data.tar.gz: 6bf44ca7efa508c656765028ce332ce7c56d104be9e7977ac5a341f91c334e67
5
5
  SHA512:
6
- metadata.gz: 07d2ea92279c1e33d990a68ca9f22dbbcd072638ff70405806d2d6ebeb13666caa660f2168cf8e34646651027c5da5ba4e865b3ada9e54091ed045a3fc66fb76
7
- data.tar.gz: 8edd86befccab8acd25a5b4307009899e3ec6f2fc3b76671c348caf51934308e60fbfc58bd46eea861afc7bc6a90f11c3a98719725e99de91c5298e8f5865b81
6
+ metadata.gz: 301867aadc94a7d2525331746d79c8464bb27c0f2009182485893671f9c0e1bddb539145d8dd55158dfa8376ac482d6c7c491916b0b5b7a8df138032b2b5b87b
7
+ data.tar.gz: 929e363b0e2d19fc2b2472eb54d1b82fbe30bc4966ce45f34cedd2c06163c45596692c9b253a8743aa91cef8feb603020b1fd2bab23b63069d06098868fad80d
@@ -129,7 +129,7 @@ module ForestLiana
129
129
 
130
130
  def destroy
131
131
  forest_authorize!('delete', forest_user, @resource)
132
- begin
132
+ begin
133
133
  collection_name = ForestLiana.name_for(@resource)
134
134
  scoped_records = ForestLiana::ScopeManager.apply_scopes_on_records(@resource, forest_user, collection_name, params[:timezone])
135
135
 
@@ -137,9 +137,12 @@ module ForestLiana
137
137
  return render serializer: nil, json: { status: 404 }, status: :not_found
138
138
  end
139
139
 
140
- scoped_records.destroy(params[:id])
141
-
142
- head :no_content
140
+ if scoped_records.destroy(params[:id])
141
+ head :no_content
142
+ else
143
+ restrict_error = ActiveRecord::DeleteRestrictionError.new
144
+ render json: { errors: [{ status: :bad_request, detail: restrict_error.message }] }, status: :bad_request
145
+ end
143
146
  rescue => error
144
147
  FOREST_REPORTER.report error
145
148
  FOREST_LOGGER.error "Record Destroy error: #{error}\n#{format_stacktrace(error)}"
@@ -151,9 +154,14 @@ module ForestLiana
151
154
  forest_authorize!('delete', forest_user, @resource)
152
155
  begin
153
156
  ids = ForestLiana::ResourcesGetter.get_ids_from_request(params, forest_user)
154
- @resource.destroy(ids) if ids&.any?
155
-
156
- head :no_content
157
+ @resource.transaction do
158
+ ids.each do |id|
159
+ record = @resource.find(id)
160
+ record.destroy!
161
+ end
162
+ end
163
+ rescue ActiveRecord::RecordNotDestroyed => error
164
+ render json: { errors: [{ status: :bad_request, detail: error.message }] }, status: :bad_request
157
165
  rescue => error
158
166
  FOREST_REPORTER.report error
159
167
  FOREST_LOGGER.error "Records Destroy error: #{error}\n#{format_stacktrace(error)}"
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "8.0.12"
2
+ VERSION = "8.0.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.12
4
+ version: 8.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-07 00:00:00.000000000 Z
11
+ date: 2023-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails