active_scaffold_vho 3.2.4 → 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/active_scaffold/actions/core.rb +17 -1
- data/lib/active_scaffold/actions/create.rb +6 -3
- data/lib/active_scaffold/actions/delete.rb +6 -3
- data/lib/active_scaffold/actions/list.rb +29 -14
- data/lib/active_scaffold/actions/show.rb +6 -3
- data/lib/active_scaffold/actions/update.rb +6 -3
- data/lib/active_scaffold/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDc3NWI5YWQ0NmNlZTY0YzNiZjBhZmMxZGRlYzdjYjI3OWY2NTYyNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmYzMzdhMzJmMmNiNTk0NGY4MTAyNzcwZGE2Nzg3YjBhMzhjZDM2Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2EyYTljMzA2YmE1OWFlMmExNGZjMDZlNThhYzQzM2I5MDBmN2Q0ZTkwNWJj
|
10
|
+
MDFlZjhhYWQyN2VkMjdiNWM5NjhiNzlkOTE2ZjI2ZDI2YjBiOGU5NGRlNmE1
|
11
|
+
ZTFmY2Y1M2RiNDAyZjA2OWQ2ZWE4NmQ0OThiOTZjZTY5N2E3M2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDg0ZTNkMzhlYzdlY2U0NTYwMGQ2NjhlY2NiY2Q2MGE4MTI0YzI5YTU3OWJh
|
14
|
+
NjFmMWQ2ZjMzNTJlZmY2ZWVhNDkyZjNkZjY1ZThmYjU4YTBiMmU1NmNmMmQz
|
15
|
+
MWYzNmViYjc5YTJkNDlmZGI0M2QzYmVhZmM1ZWY5OTRmOTdlNGQ=
|
data/Gemfile.lock
CHANGED
@@ -88,7 +88,19 @@ module ActiveScaffold::Actions
|
|
88
88
|
|
89
89
|
# API response object that will be converted to XML/YAML/JSON using to_xxx
|
90
90
|
def response_object
|
91
|
-
@response_object = successful?
|
91
|
+
@response_object = if successful?
|
92
|
+
(@record || @records)
|
93
|
+
else
|
94
|
+
unless flash[:error].nil?
|
95
|
+
@record.errors.add(:base, flash[:error])
|
96
|
+
flash.discard(:error)
|
97
|
+
end
|
98
|
+
{:errors => @record.errors}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def error_object_attributes
|
103
|
+
[:errors]
|
92
104
|
end
|
93
105
|
|
94
106
|
# Success is the existence of certain variables and the absence of errors (when applicable).
|
@@ -153,6 +165,10 @@ module ActiveScaffold::Actions
|
|
153
165
|
model.respond_to?(:build) ? model.build(build_options || {}) : model.new
|
154
166
|
end
|
155
167
|
|
168
|
+
def virtual_columns(columns)
|
169
|
+
columns.reject {|col| active_scaffold_config.model.columns_hash[col] || active_scaffold_config.model.reflect_on_association(col)}
|
170
|
+
end
|
171
|
+
|
156
172
|
private
|
157
173
|
def respond_to_action(action)
|
158
174
|
respond_to do |type|
|
@@ -67,15 +67,18 @@ module ActiveScaffold::Actions
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def create_respond_to_xml
|
70
|
-
|
70
|
+
column_names = successful? ? create_columns_names : error_object_attributes
|
71
|
+
render :xml => response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::XML, :status => response_status, :location => response_location
|
71
72
|
end
|
72
73
|
|
73
74
|
def create_respond_to_json
|
74
|
-
|
75
|
+
column_names = successful? ? create_columns_names : error_object_attributes
|
76
|
+
render :text => response_object.to_json(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::JSON, :status => response_status, :location => response_location
|
75
77
|
end
|
76
78
|
|
77
79
|
def create_respond_to_yaml
|
78
|
-
|
80
|
+
column_names = successful? ? create_columns_names : error_object_attributes
|
81
|
+
render :text => Hash.from_xml(response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names))).to_yaml, :content_type => Mime::YAML, :status => response_status, :location => response_location
|
79
82
|
end
|
80
83
|
|
81
84
|
# A simple method to find and prepare an example new record for the form
|
@@ -31,15 +31,18 @@ module ActiveScaffold::Actions
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def destroy_respond_to_xml
|
34
|
-
|
34
|
+
column_names = successful? ? [active_scaffold_config.model.primary_key] : error_object_attributes
|
35
|
+
render :xml => successful? ? "" : response_object.to_xml(:only => column_names), :content_type => Mime::XML, :status => response_status
|
35
36
|
end
|
36
37
|
|
37
38
|
def destroy_respond_to_json
|
38
|
-
|
39
|
+
column_names = successful? ? [active_scaffold_config.model.primary_key] : error_object_attributes
|
40
|
+
render :text => successful? ? "" : response_object.to_json(:only => column_names), :content_type => Mime::JSON, :status => response_status
|
39
41
|
end
|
40
42
|
|
41
43
|
def destroy_respond_to_yaml
|
42
|
-
|
44
|
+
column_names = successful? ? [active_scaffold_config.model.primary_key] : error_object_attributes
|
45
|
+
render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => column_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
|
43
46
|
end
|
44
47
|
|
45
48
|
def destroy_find_record
|
@@ -40,13 +40,16 @@ module ActiveScaffold::Actions
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
def list_respond_to_xml
|
43
|
-
|
43
|
+
column_names = successful? ? list_columns_names : error_object_attributes
|
44
|
+
render :xml => response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::XML, :status => response_status
|
44
45
|
end
|
45
46
|
def list_respond_to_json
|
46
|
-
|
47
|
+
column_names = successful? ? list_columns_names : error_object_attributes
|
48
|
+
render :text => response_object.to_json(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::JSON, :status => response_status
|
47
49
|
end
|
48
50
|
def list_respond_to_yaml
|
49
|
-
|
51
|
+
column_names = successful? ? list_columns_names : error_object_attributes
|
52
|
+
render :text => Hash.from_xml(response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names))).to_yaml, :content_type => Mime::YAML, :status => response_status
|
50
53
|
end
|
51
54
|
|
52
55
|
def row_respond_to_html
|
@@ -115,16 +118,25 @@ module ActiveScaffold::Actions
|
|
115
118
|
@record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
|
116
119
|
respond_to_action(:action_confirmation)
|
117
120
|
else
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
121
|
+
begin
|
122
|
+
if params[:id] && params[:id] && params[:id].to_i > 0
|
123
|
+
@record = find_if_allowed(params[:id], (request.post? || request.put?) ? :update : :delete)
|
124
|
+
unless @record.nil?
|
125
|
+
yield @record
|
126
|
+
else
|
127
|
+
self.successful = false
|
128
|
+
flash[:error] = as_(:no_authorization_for_action, :action => action_name)
|
129
|
+
end
|
122
130
|
else
|
123
|
-
|
124
|
-
flash[:error] = as_(:no_authorization_for_action, :action => action_name)
|
131
|
+
yield
|
125
132
|
end
|
126
|
-
|
127
|
-
|
133
|
+
rescue ActiveRecord::RecordInvalid
|
134
|
+
rescue ActiveRecord::StaleObjectError
|
135
|
+
@record.errors.add(:base, as_(:version_inconsistency)) unless @record.nil?
|
136
|
+
self.successful=false
|
137
|
+
rescue ActiveRecord::RecordNotSaved
|
138
|
+
@record.errors.add(:base, as_(:record_not_saved)) if !@record.nil? && @record.errors.empty?
|
139
|
+
self.successful = false
|
128
140
|
end
|
129
141
|
respond_to_action(render_action)
|
130
142
|
end
|
@@ -146,15 +158,18 @@ module ActiveScaffold::Actions
|
|
146
158
|
end
|
147
159
|
|
148
160
|
def action_update_respond_to_xml
|
149
|
-
|
161
|
+
column_names = successful? ? list_columns_names : error_object_attributes
|
162
|
+
render :xml => response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::XML, :status => response_status
|
150
163
|
end
|
151
164
|
|
152
165
|
def action_update_respond_to_json
|
153
|
-
|
166
|
+
column_names = successful? ? list_columns_names : error_object_attributes
|
167
|
+
render :text => response_object.to_json(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::JSON, :status => response_status
|
154
168
|
end
|
155
169
|
|
156
170
|
def action_update_respond_to_yaml
|
157
|
-
|
171
|
+
column_names = successful? ? list_columns_names : error_object_attributes
|
172
|
+
render :text => Hash.from_xml(response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names))).to_yaml, :content_type => Mime::YAML, :status => response_status
|
158
173
|
end
|
159
174
|
|
160
175
|
def save_current_page_num
|
@@ -21,15 +21,18 @@ module ActiveScaffold::Actions
|
|
21
21
|
protected
|
22
22
|
|
23
23
|
def show_respond_to_json
|
24
|
-
|
24
|
+
column_names = successful? ? show_columns_names : error_object_attributes
|
25
|
+
render :text => response_object.to_json(:only => show_columns_names, :methods => virtual_columns(column_names)), :content_type => Mime::JSON, :status => response_status
|
25
26
|
end
|
26
27
|
|
27
28
|
def show_respond_to_yaml
|
28
|
-
|
29
|
+
column_names = successful? ? show_columns_names : error_object_attributes
|
30
|
+
render :text => Hash.from_xml(response_object.to_xml(:only => show_columns_names, :methods => virtual_columns(column_names))).to_yaml, :content_type => Mime::YAML, :status => response_status
|
29
31
|
end
|
30
32
|
|
31
33
|
def show_respond_to_xml
|
32
|
-
|
34
|
+
column_names = successful? ? show_columns_names : error_object_attributes
|
35
|
+
render :xml => response_object.to_xml(:only => show_columns_names, :methods => virtual_columns(column_names)), :content_type => Mime::XML, :status => response_status
|
33
36
|
end
|
34
37
|
|
35
38
|
def show_respond_to_js
|
@@ -55,13 +55,16 @@ module ActiveScaffold::Actions
|
|
55
55
|
render :action => 'on_update'
|
56
56
|
end
|
57
57
|
def update_respond_to_xml
|
58
|
-
|
58
|
+
column_names = successful? ? update_columns_names : error_object_attributes
|
59
|
+
render :xml => response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::XML, :status => response_status
|
59
60
|
end
|
60
61
|
def update_respond_to_json
|
61
|
-
|
62
|
+
column_names = successful? ? update_columns_names : error_object_attributes
|
63
|
+
render :text => response_object.to_json(:only => column_names, :methods => virtual_columns(column_names)), :content_type => Mime::JSON, :status => response_status
|
62
64
|
end
|
63
65
|
def update_respond_to_yaml
|
64
|
-
|
66
|
+
column_names = successful? ? update_columns_names : error_object_attributes
|
67
|
+
render :text => Hash.from_xml(response_object.to_xml(:only => column_names, :methods => virtual_columns(column_names))).to_yaml, :content_type => Mime::YAML, :status => response_status
|
65
68
|
end
|
66
69
|
# A simple method to find and prepare a record for editing
|
67
70
|
# May be overridden to customize the record (set default values, etc.)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_vho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Many, see README
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda
|