cowtech-rails 1.4.1.0 → 1.5.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,7 +107,7 @@ module Cowtech
107
107
  search = "(@#{search}@)"
108
108
  search.gsub!(/(\s+(AND|OR|NOT)\s+)/, "@) \\1 (@")
109
109
 
110
- # SOSTITUIAMO I PARAMETRI
110
+ # SUBSTITUTE PARAMETERS
111
111
  i = -1
112
112
  parameters = {}
113
113
  search.gsub!(/@(.+?)@/) do |s|
@@ -116,7 +116,7 @@ module Cowtech
116
116
  key = "search_parameter_#{i}".to_sym
117
117
  val = $1
118
118
 
119
- # GESTIAMO I MARCATORI DI INIZIO E FINE RIGA
119
+ # HANDLE LINE MARKERS
120
120
  if val =~ /^\^.+\$$/ then
121
121
  val = "#{val.gsub(/^\^(.+)\$$/, "\\1").strip}"
122
122
  elsif val =~ /^\^/ then
@@ -144,20 +144,20 @@ module Cowtech
144
144
  self.crud_query_initialize(data) unless data[:query_initialized]
145
145
  parameter = :search unless parameter
146
146
 
147
- self.crud_query_add_condition(data, "(#{self.crud_get_class(data).table_name}.eliminato = :eliminato)", {:eliminato => false}) unless data[:skip_eliminato]
147
+ self.crud_query_add_condition(data, "(#{self.crud_get_class(data).table_name}.#{self.crud_get_class(data).deleted_column} = :deleted)", {:deleted => false}) unless data[:skip_deleted]
148
148
 
149
- # OTTENIAMO LA QUERY
149
+ # GET QUERY
150
150
  args = params[parameter] unless args
151
151
 
152
152
  unless args.blank? then
153
153
  search, parameters = self.crud_query_parse_search(args)
154
154
 
155
- # COMPONIAMO LA QUERY
155
+ # BUILD QUERY
156
156
  data[:query_params].merge!(parameters)
157
157
  search_query = []
158
158
  fields.each do |field| search_query << "(#{search.gsub("@FIELD@", field.to_s)})" end
159
159
 
160
- # ADESSO AGGIUNGIAMO I CAMPI ADDIZIONALI
160
+ # ADD OPTIONAL DATA
161
161
  if externals then
162
162
  externals.each do |external|
163
163
  external_query = ""
@@ -193,14 +193,14 @@ module Cowtech
193
193
 
194
194
  def crud_form_header(female = false)
195
195
  if self.crud_get_form_data.new_record? then
196
- "Crea nuov#{if female then "a" else "o" end}"
196
+ "Create new"
197
197
  else
198
- "Modifica"
198
+ "Edit"
199
199
  end
200
200
  end
201
201
 
202
202
  def crud_form_submit_label
203
- if self.crud_get_form_data.new_record? then "Inserisci" else "Modifica" end
203
+ if self.crud_get_form_data.new_record? then "Create" else "Edit" end
204
204
  end
205
205
 
206
206
  def crud_get_page_param(key = :page, upperbound = -1)
@@ -219,8 +219,8 @@ module Cowtech
219
219
  sf = sort_by.split("-")
220
220
  rv = OpenStruct.new({:what => mo["what"], :how => mo["how"].upcase})
221
221
 
222
- # ADATTIAMO ALCUNI PARAMETRI
223
- rv.what = "stato_id" if rv.what == "stato"
222
+ # ADAPT SOME PARAMETERS
223
+ rv.what = "status_id" if rv.what == "status"
224
224
 
225
225
  rv
226
226
  end
@@ -280,7 +280,7 @@ module Cowtech
280
280
 
281
281
  if record then
282
282
  if only_check then
283
- record.deletable?(controller.authenticated_user)
283
+ record.deletable?
284
284
  else
285
285
  record.delete
286
286
  end
@@ -8,6 +8,18 @@ module Cowtech
8
8
  module RubyOnRails
9
9
  module Models
10
10
  class ModelBase < ::ActiveRecord::Base
11
+ def deleted_column
12
+ "deleted"
13
+ end
14
+
15
+ def status_column
16
+ "status_id"
17
+ end
18
+
19
+ def self.deleted_status_id
20
+ 0
21
+ end
22
+
11
23
  def safe_id
12
24
  if self.id then self.id else 0 end
13
25
  end
@@ -19,9 +31,27 @@ module Cowtech
19
31
  def deletable?(user = nil)
20
32
  true
21
33
  end
22
-
34
+
23
35
  def delete(definitive = false)
24
- super()
36
+ if !definitive then
37
+ if self.deletable? then
38
+ if self.respond_to?(self.deleted_column) then
39
+ self.send(self.deleted_column, true)
40
+ self.save
41
+ true
42
+ elsif self.respond_to?(self.status_column) then
43
+ self.send(self.status_column, self.deleted_status)
44
+ self.save
45
+ true
46
+ else
47
+ super()
48
+ end
49
+ else
50
+ false
51
+ end
52
+ else
53
+ super()
54
+ end
25
55
  end
26
56
  end
27
57
  end
@@ -62,7 +62,7 @@ module Cowtech
62
62
  end
63
63
 
64
64
  def format_boolean
65
- self.to_boolean ? "" : "No"
65
+ self.to_boolean ? "Yes" : "No"
66
66
  end
67
67
 
68
68
  def dump
@@ -204,11 +204,11 @@ module Cowtech
204
204
  format = self.class.custom_format($1) if format =~ /^custom::(.+)/
205
205
  unlocal = self.strftime(format || self.class.custom_format("update"))
206
206
 
207
- # SCAMBIAMO I MESI E I GIORNI COMPLETI
207
+ # CHANGE LONG DAYS AND MONTHS
208
208
  unlocal.gsub!(/(#{self.class.localized_months.keys.join("|")})/i) do |s| self.class.localized_months[$1] end
209
209
  unlocal.gsub!(/(#{self.class.localized_days.keys.join("|")})/i) do |s| self.class.localized_days[$1] end
210
210
 
211
- # SCAMBIAMO I MESI E I GIORNI CORTI
211
+ # CHANGE SHORT DAYS AND MONTHS
212
212
  unlocal.gsub!(/(#{self.class.localized_short_months.keys.join("|")})/i) do |s| self.class.localized_short_months[$1] end
213
213
  unlocal.gsub!(/(#{self.class.localized_short_days.keys.join("|")})/i) do |s| self.class.localized_short_days[$1] end
214
214
 
@@ -8,8 +8,8 @@ module Cowtech
8
8
  module Rails
9
9
  module Version
10
10
  MAJOR = 1
11
- MINOR = 4
12
- PATCH = 1
11
+ MINOR = 5
12
+ PATCH = 0
13
13
  BUILD = 0
14
14
 
15
15
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
metadata CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 4
8
- - 1
7
+ - 5
8
+ - 0
9
9
  - 0
10
- version: 1.4.1.0
10
+ version: 1.5.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shogun