forest_liana 8.0.12 → 8.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/forest_liana/resources_controller.rb +15 -7
- data/lib/forest_liana/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26515d9f2fe7d7fab4a83357eb633fef70a24497248f819dc49f816376adaa66
|
4
|
+
data.tar.gz: 6bf44ca7efa508c656765028ce332ce7c56d104be9e7977ac5a341f91c334e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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.
|
155
|
-
|
156
|
-
|
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)}"
|
data/lib/forest_liana/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|