typus 1.0.0.pre → 1.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -2
- data/app/controllers/admin/account_controller.rb +1 -1
- data/app/controllers/{admin_controller.rb → admin/base_controller.rb} +1 -1
- data/app/controllers/admin/dashboard_controller.rb +1 -1
- data/app/controllers/admin/resource_controller.rb +1 -1
- data/app/controllers/admin/resources_controller.rb +1 -1
- data/app/controllers/admin/session_controller.rb +1 -1
- data/app/helpers/admin/base_helper.rb +60 -0
- data/app/views/admin/session/new.html.erb +1 -1
- data/app/views/layouts/{admin.html.erb → admin/base.html.erb} +0 -0
- data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +17 -11
- data/lib/generators/templates/public/admin/stylesheets/screen.css +1 -0
- data/lib/generators/typus/migration_generator.rb +1 -1
- data/lib/generators/typus/typus_generator.rb +2 -2
- data/lib/typus/format.rb +1 -1
- data/lib/typus/orm/active_record.rb +7 -9
- data/lib/typus/user.rb +3 -3
- data/lib/typus/version.rb +1 -1
- data/test/fixtures/rails_app/config/routes.rb +1 -4
- data/test/fixtures/rails_app/log/test.log +41948 -1879
- data/test/fixtures/rails_app/tmp/{export-posts-20100902120447.csv → export-posts-20100913124503.csv} +0 -0
- data/test/fixtures/rails_app/tmp/{export-posts-20100902120700.csv → export-posts-20100913124524.csv} +0 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913124638.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913124717.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125425.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125626.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125651.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125741.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125827.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125856.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913125928.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913130119.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913130159.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913130319.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913130339.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913131400.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913131915.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913132022.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20100913132844.csv +2 -0
- data/test/lib/typus/active_record_test.rb +49 -18
- data/test/lib/typus/configuration_test.rb +7 -7
- data/test/unit/typus_user_test.rb +37 -21
- metadata +26 -10
- data/app/helpers/admin_helper.rb +0 -56
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -70,7 +70,6 @@ GEM
|
|
70
70
|
rake (>= 0.8.4)
|
71
71
|
thor (~> 0.14.0)
|
72
72
|
rake (0.8.7)
|
73
|
-
redgreen (1.2.2)
|
74
73
|
shoulda (2.11.3)
|
75
74
|
sqlite3-ruby (1.3.1)
|
76
75
|
thor (0.14.0)
|
@@ -91,6 +90,5 @@ DEPENDENCIES
|
|
91
90
|
paperclip
|
92
91
|
pg
|
93
92
|
rails (= 3.0.0)
|
94
|
-
redgreen
|
95
93
|
shoulda
|
96
94
|
sqlite3-ruby
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Admin
|
2
|
+
|
3
|
+
module BaseHelper
|
4
|
+
|
5
|
+
def typus_block(resource = @resource.to_resource, partial = params[:action])
|
6
|
+
partials_path = "admin/#{resource}"
|
7
|
+
resources_partials_path = "admin/resources"
|
8
|
+
|
9
|
+
partials = ActionController::Base.view_paths.map do |view_path|
|
10
|
+
Dir["#{view_path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
|
11
|
+
end.flatten
|
12
|
+
resources_partials = Dir[Rails.root.join("app/views/#{resources_partials_path}/*").to_s].map do |file|
|
13
|
+
File.basename(file, ".html.erb")
|
14
|
+
end
|
15
|
+
|
16
|
+
path = if partials.include?("_#{partial}") then partials_path
|
17
|
+
elsif resources_partials.include?(partial) then resources_partials_path
|
18
|
+
end
|
19
|
+
|
20
|
+
render "#{path}/#{partial}" if path
|
21
|
+
end
|
22
|
+
|
23
|
+
def title(page_title)
|
24
|
+
content_for(:title) { page_title }
|
25
|
+
end
|
26
|
+
|
27
|
+
def header
|
28
|
+
render "admin/helpers/header"
|
29
|
+
end
|
30
|
+
|
31
|
+
def apps
|
32
|
+
render "admin/helpers/apps"
|
33
|
+
end
|
34
|
+
|
35
|
+
def login_info(user = @current_user)
|
36
|
+
return if user.kind_of?(Admin::FakeUser)
|
37
|
+
|
38
|
+
admin_edit_typus_user_path = { :controller => "/admin/#{Typus.user_class.to_resource}",
|
39
|
+
:action => 'edit',
|
40
|
+
:id => user.id }
|
41
|
+
|
42
|
+
message = _("Are you sure you want to sign out and end your session?")
|
43
|
+
|
44
|
+
user_details = if user.can?('edit', Typus.user_class_name)
|
45
|
+
link_to user.name, admin_edit_typus_user_path
|
46
|
+
else
|
47
|
+
user.name
|
48
|
+
end
|
49
|
+
|
50
|
+
render "admin/helpers/login_info", :message => message, :user_details => user_details
|
51
|
+
end
|
52
|
+
|
53
|
+
def display_flash_message(message = flash)
|
54
|
+
return if message.empty?
|
55
|
+
render "admin/helpers/flash_message", :flash_type => message.keys.first, :message => message
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
</li>
|
19
19
|
|
20
20
|
<li>
|
21
|
-
<%= submit_tag _("Sign in"), :class => "button" %> <%= link_to _("Recover password"), forgot_password_admin_account_index_path if
|
21
|
+
<%= submit_tag _("Sign in"), :class => "button" %> <%= link_to _("Recover password"), forgot_password_admin_account_index_path if Typus.mailer_sender %>
|
22
22
|
</li>
|
23
23
|
|
24
24
|
</ul>
|
File without changes
|
@@ -23,18 +23,19 @@ jQuery(function ($) {
|
|
23
23
|
*/
|
24
24
|
callRemote: function () {
|
25
25
|
var el = this,
|
26
|
-
data = el.is('form') ? el.serializeArray() : [],
|
27
26
|
method = el.attr('method') || el.attr('data-method') || 'GET',
|
28
|
-
url = el.attr('action') || el.attr('href')
|
27
|
+
url = el.attr('action') || el.attr('href'),
|
28
|
+
dataType = el.attr('data-type') || 'script';
|
29
29
|
|
30
30
|
if (url === undefined) {
|
31
31
|
throw "No URL specified for remote call (action or href must be present).";
|
32
32
|
} else {
|
33
33
|
if (el.triggerAndReturn('ajax:before')) {
|
34
|
+
var data = el.is('form') ? el.serializeArray() : [];
|
34
35
|
$.ajax({
|
35
36
|
url: url,
|
36
37
|
data: data,
|
37
|
-
dataType:
|
38
|
+
dataType: dataType,
|
38
39
|
type: method.toUpperCase(),
|
39
40
|
beforeSend: function (xhr) {
|
40
41
|
el.trigger('ajax:loading', xhr);
|
@@ -104,23 +105,28 @@ jQuery(function ($) {
|
|
104
105
|
/**
|
105
106
|
* disable-with handlers
|
106
107
|
*/
|
107
|
-
var disable_with_input_selector
|
108
|
-
var
|
108
|
+
var disable_with_input_selector = 'input[data-disable-with]';
|
109
|
+
var disable_with_form_remote_selector = 'form[data-remote]:has(' + disable_with_input_selector + ')';
|
110
|
+
var disable_with_form_not_remote_selector = 'form:not([data-remote]):has(' + disable_with_input_selector + ')';
|
109
111
|
|
110
|
-
|
112
|
+
var disable_with_input_function = function () {
|
111
113
|
$(this).find(disable_with_input_selector).each(function () {
|
112
114
|
var input = $(this);
|
113
115
|
input.data('enable-with', input.val())
|
114
|
-
|
115
|
-
|
116
|
+
.attr('value', input.attr('data-disable-with'))
|
117
|
+
.attr('disabled', 'disabled');
|
116
118
|
});
|
117
|
-
}
|
119
|
+
};
|
120
|
+
|
121
|
+
$(disable_with_form_remote_selector).live('ajax:before', disable_with_input_function);
|
122
|
+
$(disable_with_form_not_remote_selector).live('submit', disable_with_input_function);
|
118
123
|
|
119
|
-
$(
|
124
|
+
$(disable_with_form_remote_selector).live('ajax:complete', function () {
|
120
125
|
$(this).find(disable_with_input_selector).each(function () {
|
121
126
|
var input = $(this);
|
122
127
|
input.removeAttr('disabled')
|
123
128
|
.val(input.data('enable-with'));
|
124
129
|
});
|
125
130
|
});
|
126
|
-
|
131
|
+
|
132
|
+
});
|
@@ -24,7 +24,7 @@ Description:
|
|
24
24
|
DESC
|
25
25
|
|
26
26
|
def self.next_migration_number(path)
|
27
|
-
Time.now.utc.to_s(:number)
|
27
|
+
Time.zone.now.utc.to_s(:number)
|
28
28
|
end
|
29
29
|
|
30
30
|
def copy_config_readme
|
@@ -87,7 +87,7 @@ Description:
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def timestamp
|
90
|
-
Time.now.utc.to_s(:number)
|
90
|
+
Time.zone.now.utc.to_s(:number)
|
91
91
|
end
|
92
92
|
|
93
93
|
private
|
data/lib/typus/format.rb
CHANGED
@@ -39,7 +39,7 @@ module Typus
|
|
39
39
|
csv = CSV
|
40
40
|
end
|
41
41
|
|
42
|
-
filename = Rails.root.join("tmp", "export-#{@resource.to_resource}-#{Time.now.
|
42
|
+
filename = Rails.root.join("tmp", "export-#{@resource.to_resource}-#{Time.zone.now.to_s(:number)}.csv")
|
43
43
|
|
44
44
|
options = { :conditions => @conditions, :batch_size => 1000 }
|
45
45
|
|
@@ -122,12 +122,11 @@ module Typus
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def typus_search_fields
|
125
|
-
data =
|
126
|
-
return [] if data.nil?
|
125
|
+
data = typus_defaults_for(:search)
|
127
126
|
|
128
127
|
search = {}
|
129
128
|
|
130
|
-
data.
|
129
|
+
data.each do |field|
|
131
130
|
if field.starts_with?("=")
|
132
131
|
field.slice!(0)
|
133
132
|
search[field] = "="
|
@@ -140,7 +139,6 @@ module Typus
|
|
140
139
|
end
|
141
140
|
|
142
141
|
return search
|
143
|
-
|
144
142
|
end
|
145
143
|
|
146
144
|
#--
|
@@ -301,10 +299,10 @@ module Typus
|
|
301
299
|
conditions = merge_conditions(conditions, condition)
|
302
300
|
when :datetime
|
303
301
|
interval = case value
|
304
|
-
when 'today' then Time.
|
305
|
-
when 'last_few_days' then 3.days.ago.
|
306
|
-
when 'last_7_days' then 6.days.ago.
|
307
|
-
when 'last_30_days' then Time.
|
302
|
+
when 'today' then Time.zone.now.beginning_of_day..Time.zone.now.beginning_of_day.tomorrow
|
303
|
+
when 'last_few_days' then 3.days.ago.beginning_of_day..Time.zone.now.beginning_of_day.tomorrow
|
304
|
+
when 'last_7_days' then 6.days.ago.beginning_of_day..Time.zone.now.beginning_of_day.tomorrow
|
305
|
+
when 'last_30_days' then Time.zone.now.beginning_of_day.prev_month..Time.zone.now.beginning_of_day.tomorrow
|
308
306
|
end
|
309
307
|
condition = ["#{key} BETWEEN ? AND ?", interval.first.to_s(:db), interval.last.to_s(:db)]
|
310
308
|
conditions = merge_conditions(conditions, condition)
|
@@ -329,7 +327,7 @@ module Typus
|
|
329
327
|
interval = case value
|
330
328
|
when 'today' then nil
|
331
329
|
when 'last_few_days' then 3.days.ago.to_date..Date.tomorrow
|
332
|
-
when 'last_7_days' then 6.days.ago.
|
330
|
+
when 'last_7_days' then 6.days.ago.beginning_of_day..Date.tomorrow
|
333
331
|
when 'last_30_days' then (Date.today << 1)..Date.tomorrow
|
334
332
|
end
|
335
333
|
if interval
|
data/lib/typus/user.rb
CHANGED
@@ -20,7 +20,7 @@ module Typus
|
|
20
20
|
validates_uniqueness_of :email
|
21
21
|
|
22
22
|
validates_confirmation_of :password, :if => :password_required?
|
23
|
-
validates_length_of :password, :within =>
|
23
|
+
validates_length_of :password, :within => 6..40, :if => :password_required?
|
24
24
|
validates_presence_of :password, :if => :password_required?
|
25
25
|
|
26
26
|
validates_presence_of :role
|
@@ -152,7 +152,7 @@ module Typus
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def initialize_salt
|
155
|
-
self.salt = generate_hash("--#{Time.now.
|
155
|
+
self.salt = generate_hash("--#{Time.zone.now.to_s(:number)}--#{email}--") if new_record?
|
156
156
|
end
|
157
157
|
|
158
158
|
def initialize_token
|
@@ -160,7 +160,7 @@ module Typus
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def generate_token
|
163
|
-
self.token = encrypt("--#{Time.now.
|
163
|
+
self.token = encrypt("--#{Time.zone.now.to_s(:number)}--#{password}--").first(12)
|
164
164
|
end
|
165
165
|
|
166
166
|
def password_required?
|
data/lib/typus/version.rb
CHANGED