cowtech-rails 1.8.0.1 → 1.9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/helpers/cowtech/ruby_on_rails/helpers/application_helper.rb +4 -4
- data/app/helpers/cowtech/ruby_on_rails/helpers/browser_helper.rb +1 -1
- data/app/helpers/cowtech/ruby_on_rails/helpers/crud_helper.rb +32 -32
- data/app/models/cowtech/ruby_on_rails/models/e_mail.rb +2 -2
- data/lib/cowtech/extensions.rb +1 -1
- data/lib/cowtech/monkey_patches.rb +2 -2
- data/lib/cowtech/version.rb +2 -2
- metadata +2 -2
@@ -9,13 +9,13 @@ module Cowtech
|
|
9
9
|
module Helpers
|
10
10
|
module ApplicationHelper
|
11
11
|
def application_info
|
12
|
-
@application_info = YAML.load_file(Rails.root + "config/application_info.yml")
|
12
|
+
@application_info = YAML.load_file(Rails.root + "config/application_info.yml") if !@application_info
|
13
13
|
@application_info
|
14
14
|
end
|
15
15
|
|
16
16
|
def location_name(action = nil, controller = nil)
|
17
|
-
controller = self.controller_name
|
18
|
-
action = self.action_name
|
17
|
+
controller = self.controller_name if !controller
|
18
|
+
action = self.action_name if !action
|
19
19
|
"#{controller}##{action}"
|
20
20
|
end
|
21
21
|
|
@@ -38,7 +38,7 @@ module Cowtech
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def set_data(key, value)
|
41
|
-
@controller_data = {}
|
41
|
+
@controller_data = {} if !(defined?(@controller_data) && @controller_data.is_a?(Hash))
|
42
42
|
@controller_data[key.to_sym] = value
|
43
43
|
end
|
44
44
|
|
@@ -16,37 +16,37 @@ module Cowtech
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def crud_get_class(data = nil)
|
19
|
-
data = self.crud_get_data
|
19
|
+
data = self.crud_get_data if !data
|
20
20
|
data[:class].constantize
|
21
21
|
end
|
22
22
|
|
23
23
|
def crud_get_records(data)
|
24
|
-
data = self.crud_get_data
|
24
|
+
data = self.crud_get_data if !data
|
25
25
|
data[:records]
|
26
26
|
end
|
27
27
|
|
28
28
|
def crud_query_get_params(data = nil)
|
29
|
-
data = self.crud_get_data
|
29
|
+
data = self.crud_get_data if !data
|
30
30
|
data[:query_params]
|
31
31
|
end
|
32
32
|
|
33
33
|
def crud_get_sort_order(data = nil)
|
34
|
-
data = self.crud_get_data
|
34
|
+
data = self.crud_get_data if !data
|
35
35
|
data[:sort_order]
|
36
36
|
end
|
37
37
|
|
38
38
|
def crud_has_data?(data = nil)
|
39
|
-
data = self.crud_get_data
|
39
|
+
data = self.crud_get_data if !data
|
40
40
|
data[:data_bounds].total > 0
|
41
41
|
end
|
42
42
|
|
43
43
|
def crud_get_pager_data(data = nil)
|
44
|
-
data = self.crud_get_data
|
44
|
+
data = self.crud_get_data if !data
|
45
45
|
data[:pager_data]
|
46
46
|
end
|
47
47
|
|
48
48
|
def crud_get_data_bounds(data = nil)
|
49
|
-
data = self.crud_get_data
|
49
|
+
data = self.crud_get_data if !data
|
50
50
|
data[:data_bounds]
|
51
51
|
end
|
52
52
|
|
@@ -55,49 +55,49 @@ module Cowtech
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def crud_set_class(data, table = "")
|
58
|
-
data = self.crud_get_data
|
58
|
+
data = self.crud_get_data if !data
|
59
59
|
data[:class] = table
|
60
60
|
end
|
61
61
|
|
62
62
|
def crud_set_records(data, records = nil)
|
63
|
-
data = self.crud_get_data
|
63
|
+
data = self.crud_get_data if !data
|
64
64
|
data[:records] = records
|
65
65
|
end
|
66
66
|
|
67
67
|
def crud_finalize_read(data = nil, records = nil, parameter = :count, per_page = nil)
|
68
|
-
data = self.crud_get_data
|
69
|
-
records = self.crud_get_records(data)
|
68
|
+
data = self.crud_get_data if !data
|
69
|
+
records = self.crud_get_records(data) if !records
|
70
70
|
self.crud_calculate_data_bounds(data, records, per_page || params[parameter])
|
71
71
|
data[:pager_data] = records.paginate(:page => data[:data_bounds].page, :per_page => data[:data_bounds].per_page, :total_entries => data[:data_bounds].total) if records.respond_to?(:paginate)
|
72
72
|
end
|
73
73
|
|
74
74
|
def crud_query_initialize(data = nil, force = false)
|
75
|
-
data = self.crud_get_data
|
75
|
+
data = self.crud_get_data if !data
|
76
76
|
data[:query_expr] = [] if !data[:query_expr] || force
|
77
77
|
data[:query_params] = {} if !data[:query_params] || force
|
78
78
|
data[:query_initialized] = true
|
79
79
|
end
|
80
80
|
|
81
81
|
def crud_query_get(data = nil, query = nil)
|
82
|
-
data = self.crud_get_data
|
83
|
-
self.crud_query_initialize(data)
|
84
|
-
query = data[:query_expr]
|
82
|
+
data = self.crud_get_data if !data
|
83
|
+
self.crud_query_initialize(data) if !data[:query_initialized]
|
84
|
+
query = data[:query_expr] if !query
|
85
85
|
|
86
86
|
query.count.times do |i| query[i] = "(#{query[i]})" end
|
87
87
|
query.join(" AND ")
|
88
88
|
end
|
89
89
|
|
90
90
|
def crud_query_dump(data = nil)
|
91
|
-
data = self.crud_get_data
|
92
|
-
self.crud_query_initialize(data)
|
91
|
+
data = self.crud_get_data if !data
|
92
|
+
self.crud_query_initialize(data) if !data[:query_initialized]
|
93
93
|
raise Exception.new("QUERY: #{data[:query_expr]}\nPARAMS: #{data[:query_params].to_json}")
|
94
94
|
end
|
95
95
|
|
96
96
|
def crud_query_add_condition(data, expr, params = {})
|
97
|
-
data = self.crud_get_data
|
98
|
-
self.crud_query_initialize(data)
|
97
|
+
data = self.crud_get_data if !data
|
98
|
+
self.crud_query_initialize(data) if !data[:query_initialized]
|
99
99
|
|
100
|
-
expr = [expr]
|
100
|
+
expr = [expr] if !expr.respond_to?(:each)
|
101
101
|
expr.each do |e| data[:query_expr] << e end
|
102
102
|
|
103
103
|
data[:query_params].merge!(params)
|
@@ -135,21 +135,21 @@ module Cowtech
|
|
135
135
|
end
|
136
136
|
|
137
137
|
def crud_handle_search(data, *fields)
|
138
|
-
data = self.crud_get_data
|
138
|
+
data = self.crud_get_data if !data
|
139
139
|
self.crud_handle_extended_search(data, fields)
|
140
140
|
end
|
141
141
|
|
142
142
|
def crud_handle_extended_search(data, fields, externals = nil, args = nil, parameter = :search)
|
143
|
-
data = self.crud_get_data
|
144
|
-
self.crud_query_initialize(data)
|
145
|
-
parameter = :search
|
143
|
+
data = self.crud_get_data if !data
|
144
|
+
self.crud_query_initialize(data) if !data[:query_initialized]
|
145
|
+
parameter = :search if !parameter
|
146
146
|
|
147
|
-
self.crud_query_add_condition(data, "(#{self.crud_get_class(data).table_name}.#{self.crud_get_class(data).deleted_column} IS NULL)", {})
|
147
|
+
self.crud_query_add_condition(data, "(#{self.crud_get_class(data).table_name}.#{self.crud_get_class(data).deleted_column} IS NULL)", {}) if !data[:skip_deleted]
|
148
148
|
|
149
149
|
# GET QUERY
|
150
|
-
args = params[parameter]
|
150
|
+
args = params[parameter] if !args
|
151
151
|
|
152
|
-
|
152
|
+
if !args.blank? then
|
153
153
|
search, parameters = self.crud_query_parse_search(args)
|
154
154
|
|
155
155
|
# BUILD QUERY
|
@@ -162,7 +162,7 @@ module Cowtech
|
|
162
162
|
externals.each do |external|
|
163
163
|
external_query = ""
|
164
164
|
|
165
|
-
|
165
|
+
if !external[:manual] then
|
166
166
|
external_conds = []
|
167
167
|
external.fetch(:fields, []).each do |external_field| external_conds << "(#{search.gsub("@FIELD@", "#{external[:table]}.#{external_field.to_s}")})" end
|
168
168
|
external_field = external.fetch(:external_field, "id")
|
@@ -191,7 +191,7 @@ module Cowtech
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def crud_handle_sorting(data, default_sorting, sort_data, sort_expression = "@PLACEHOLDER@, updated_at DESC")
|
194
|
-
data = self.crud_get_data
|
194
|
+
data = self.crud_get_data if !data
|
195
195
|
data[:sort_data] = sort_data
|
196
196
|
sort = self.crud_get_sort_param(default_sorting, (sort_data || {}).keys)
|
197
197
|
data[:sort] = "#{sort.what}-#{sort.how.downcase}"
|
@@ -237,8 +237,8 @@ module Cowtech
|
|
237
237
|
end
|
238
238
|
|
239
239
|
def crud_calculate_data_bounds(data, records = nil, per_page = nil)
|
240
|
-
data = self.crud_get_data
|
241
|
-
records = data[:records]
|
240
|
+
data = self.crud_get_data if !data
|
241
|
+
records = data[:records] if !records
|
242
242
|
bounds = OpenStruct.new({:total => 0, :first => 0, :last => 0, :pages => 0, :page => 1, :per_page => 1})
|
243
243
|
|
244
244
|
if records != nil && records.count > 0 then
|
@@ -274,7 +274,7 @@ module Cowtech
|
|
274
274
|
def crud_end_write_action_url(additional = nil, absolute = false)
|
275
275
|
rp = {}
|
276
276
|
|
277
|
-
|
277
|
+
if !absolute then
|
278
278
|
rp = session["params-#{self.location_name(:index)}"] || {}
|
279
279
|
rp[:action] = :index
|
280
280
|
end
|
@@ -26,7 +26,7 @@ module Cowtech
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def setup(method = :smtp)
|
29
|
-
@configuration = EMail.setup(method)
|
29
|
+
@configuration = EMail.setup(method) if !@configuration
|
30
30
|
@configuration
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ module Cowtech
|
|
37
37
|
args = (if args.is_a?(Hash) then args else args[0] end).delete_if { |k,v| v.blank? }
|
38
38
|
|
39
39
|
# AGGIUSTIAMO REPLY TO
|
40
|
-
args[:reply_to] = args[:from]
|
40
|
+
args[:reply_to] = args[:from] if !args[:reply_to]
|
41
41
|
|
42
42
|
# OTTENIAMO IL BODY
|
43
43
|
plain_body = args.delete(:body) || args.delete(:plain_body) || args.delete(:text_body) || args.delete(:plain_text) || args.delete(:text)
|
data/lib/cowtech/extensions.rb
CHANGED
@@ -34,7 +34,7 @@ if defined?(Mail) then
|
|
34
34
|
smtp = Net::SMTP.new(settings[:address], settings[:port])
|
35
35
|
if settings[:tls] || settings[:ssl]
|
36
36
|
if smtp.respond_to?(:enable_tls)
|
37
|
-
|
37
|
+
if !settings[:openssl_verify_mode]
|
38
38
|
smtp.enable_tls
|
39
39
|
else
|
40
40
|
openssl_verify_mode = settings[:openssl_verify_mode]
|
@@ -48,7 +48,7 @@ if defined?(Mail) then
|
|
48
48
|
end
|
49
49
|
elsif settings[:enable_starttls_auto]
|
50
50
|
if smtp.respond_to?(:enable_starttls_auto)
|
51
|
-
|
51
|
+
if !settings[:openssl_verify_mode]
|
52
52
|
smtp.enable_starttls_auto
|
53
53
|
else
|
54
54
|
openssl_verify_mode = settings[:openssl_verify_mode]
|
data/lib/cowtech/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cowtech-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-13 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: A general purpose Rails utility plugin.
|
15
15
|
email: shogun_panda@me.com
|