fesplugas-typus 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/app/controllers/admin/master_controller.rb +2 -2
- data/app/controllers/typus_controller.rb +2 -2
- data/app/helpers/admin/form_helper.rb +34 -34
- data/app/helpers/admin/master_helper.rb +1 -1
- data/app/helpers/admin/public_helper.rb +9 -6
- data/app/helpers/typus_helper.rb +14 -4
- data/app/views/admin/dashboard/_sidebar.html.erb +2 -2
- data/app/views/admin/resources/edit.html.erb +3 -7
- data/app/views/admin/resources/index.html.erb +3 -7
- data/app/views/admin/resources/new.html.erb +3 -7
- data/app/views/admin/resources/show.html.erb +3 -7
- data/app/views/admin/shared/_footer.html.erb +1 -1
- data/app/views/typus/dashboard.html.erb +2 -6
- data/app/views/typus/recover_password.html.erb +3 -3
- data/app/views/typus/reset_password.html.erb +3 -3
- data/app/views/typus/sign_in.html.erb +3 -3
- data/app/views/typus/sign_up.html.erb +2 -2
- data/config/locales/es.yml +0 -1
- data/config/locales/pt-BR.yml +0 -1
- data/config/locales/ru.yml +107 -0
- data/lib/typus/active_record.rb +1 -1
- data/lib/typus/generator.rb +1 -1
- data/lib/typus/quick_edit.rb +26 -19
- data/lib/typus.rb +1 -1
- data/test/fixtures/app/views/admin/comments/_edit.html.erb +1 -0
- data/test/fixtures/app/views/admin/comments/_index.html.erb +1 -0
- data/test/fixtures/app/views/admin/comments/_new.html.erb +1 -0
- data/test/fixtures/app/views/admin/comments/_show.html.erb +1 -0
- data/test/fixtures/app/views/admin/comments/_sidebar.html.erb +1 -0
- data/test/fixtures/app/views/admin/dashboard/_content.html.erb +1 -0
- data/test/fixtures/app/views/admin/resources/_sidebar.html.erb +1 -0
- data/test/functional/admin/comments_controller_test.rb +13 -6
- data/test/functional/typus_controller_test.rb +8 -1
- data/test/helpers/admin/form_helper_test.rb +33 -13
- data/test/helpers/admin/master_helper_test.rb +1 -1
- data/test/helpers/admin/public_helper_test.rb +6 -2
- data/test/lib/configuration_test.rb +2 -2
- data/test/lib/typus_test.rb +1 -1
- data/test/unit/typus_user_test.rb +6 -0
- data/typus.gemspec +10 -16
- metadata +10 -16
- data/test/fixtures/app/views/admin/comments/_edit_bottom.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_edit_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_edit_top.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_index_bottom.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_index_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_index_top.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_new_bottom.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_new_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_new_top.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_show_bottom.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_show_sidebar.html.erb +0 -1
- data/test/fixtures/app/views/admin/comments/_show_top.html.erb +0 -1
- data/test/fixtures/app/views/admin/dashboard/_bottom.html.erb +0 -1
- data/test/fixtures/app/views/admin/dashboard/_top.html.erb +0 -1
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.7
|
|
@@ -290,8 +290,8 @@ private
|
|
|
290
290
|
end
|
|
291
291
|
|
|
292
292
|
def select_template(template, resource = @resource[:self])
|
|
293
|
-
folder = (File.
|
|
294
|
-
render
|
|
293
|
+
folder = (File.exist?("app/views/admin/#{resource}/#{template}.html.erb")) ? resource : 'resources'
|
|
294
|
+
render "admin/#{folder}/#{template}"
|
|
295
295
|
end
|
|
296
296
|
|
|
297
297
|
##
|
|
@@ -80,8 +80,8 @@ class TypusController < ApplicationController
|
|
|
80
80
|
@user.password = params[:user][:password]
|
|
81
81
|
@user.password_confirmation = params[:user][:password_confirmation]
|
|
82
82
|
if @user.save
|
|
83
|
-
|
|
84
|
-
redirect_to
|
|
83
|
+
session[:typus_user_id] = @user.id
|
|
84
|
+
redirect_to admin_dashboard_path
|
|
85
85
|
else
|
|
86
86
|
flash[:error] = _("Passwords don't match.")
|
|
87
87
|
redirect_to admin_reset_password_path(:token => params[:token])
|
|
@@ -33,7 +33,7 @@ module Admin::FormHelper
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def typus_belongs_to_field(attribute
|
|
36
|
+
def typus_belongs_to_field(attribute)
|
|
37
37
|
|
|
38
38
|
##
|
|
39
39
|
# We only can pass parameters to 'new' and 'edit', so this hack makes
|
|
@@ -43,8 +43,8 @@ module Admin::FormHelper
|
|
|
43
43
|
|
|
44
44
|
back_to = '/' + [ params[:controller], params[:action], params[:id] ].compact.join('/')
|
|
45
45
|
|
|
46
|
-
related =
|
|
47
|
-
related_fk =
|
|
46
|
+
related = @resource[:class].reflect_on_association(attribute.to_sym).class_name.constantize
|
|
47
|
+
related_fk = @resource[:class].reflect_on_association(attribute.to_sym).primary_key_name
|
|
48
48
|
|
|
49
49
|
message = [ _("Are you sure you want to leave this page?"),
|
|
50
50
|
_("If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost."),
|
|
@@ -59,7 +59,7 @@ module Admin::FormHelper
|
|
|
59
59
|
<li><label for="item_#{attribute}">#{_(related_fk.humanize)}
|
|
60
60
|
<small>#{link_to _('Add'), { :controller => "admin/#{related.class_name.tableize}", :action => 'new', :back_to => back_to, :selected => related_fk }, :confirm => message.join("\n\n") if @current_user.can_perform?(related, 'create')}</small>
|
|
61
61
|
</label>
|
|
62
|
-
#{select :item, related_fk, related.find(:all, :order => related.typus_order_by).collect { |p| [p.typus_name, p.id] }, { :include_blank => true }, { :disabled => attribute_disabled?(attribute
|
|
62
|
+
#{select :item, related_fk, related.find(:all, :order => related.typus_order_by).collect { |p| [p.typus_name, p.id] }, { :include_blank => true }, { :disabled => attribute_disabled?(attribute) } }</li>
|
|
63
63
|
HTML
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -67,47 +67,47 @@ module Admin::FormHelper
|
|
|
67
67
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
def typus_boolean_field(attribute
|
|
70
|
+
def typus_boolean_field(attribute)
|
|
71
71
|
attribute_name = attribute.gsub(/\?$/,'')
|
|
72
72
|
<<-HTML
|
|
73
|
-
<li><label for="item_#{attribute_name}">#{
|
|
73
|
+
<li><label for="item_#{attribute_name}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
74
74
|
#{check_box :item, attribute_name} #{_('Checked if active')}</li>
|
|
75
75
|
HTML
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def typus_date_field(attribute, options
|
|
78
|
+
def typus_date_field(attribute, options)
|
|
79
79
|
<<-HTML
|
|
80
|
-
<li><label for="item_#{attribute}">#{
|
|
81
|
-
#{date_select :item, attribute, options, { :disabled => attribute_disabled?(attribute
|
|
80
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
81
|
+
#{date_select :item, attribute, options, { :disabled => attribute_disabled?(attribute)} }</li>
|
|
82
82
|
HTML
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
def typus_datetime_field(attribute, options
|
|
85
|
+
def typus_datetime_field(attribute, options)
|
|
86
86
|
<<-HTML
|
|
87
|
-
<li><label for="item_#{attribute}">#{
|
|
88
|
-
#{datetime_select :item, attribute, options, {:disabled => attribute_disabled?(attribute
|
|
87
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
88
|
+
#{datetime_select :item, attribute, options, {:disabled => attribute_disabled?(attribute)}}</li>
|
|
89
89
|
HTML
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def typus_file_field(attribute
|
|
92
|
+
def typus_file_field(attribute)
|
|
93
93
|
|
|
94
94
|
attribute_display = attribute.split('_file_name').first
|
|
95
95
|
|
|
96
96
|
<<-HTML
|
|
97
97
|
<li><label for="item_#{attribute}">#{_(attribute_display.humanize)}</label>
|
|
98
|
-
#{file_field :item, attribute.split("_file_name").first, :disabled => attribute_disabled?(attribute
|
|
98
|
+
#{file_field :item, attribute.split("_file_name").first, :disabled => attribute_disabled?(attribute)}</li>
|
|
99
99
|
HTML
|
|
100
100
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
def typus_password_field(attribute
|
|
103
|
+
def typus_password_field(attribute)
|
|
104
104
|
<<-HTML
|
|
105
|
-
<li><label for="item_#{attribute}">#{
|
|
106
|
-
#{password_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute
|
|
105
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
106
|
+
#{password_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute)}</li>
|
|
107
107
|
HTML
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def typus_selector_field(attribute
|
|
110
|
+
def typus_selector_field(attribute)
|
|
111
111
|
returning(String.new) do |html|
|
|
112
112
|
options = []
|
|
113
113
|
@resource[:class].send(attribute).each do |option|
|
|
@@ -121,7 +121,7 @@ module Admin::FormHelper
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
html << <<-HTML
|
|
124
|
-
<li><label for="item_#{attribute}">#{
|
|
124
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
125
125
|
<select id="item_#{attribute}" #{attribute_disabled?(attribute) ? 'disabled="disabled"' : ''} name="item[#{attribute}]">
|
|
126
126
|
<option value=""></option>
|
|
127
127
|
#{options.join("\n")}
|
|
@@ -130,23 +130,23 @@ module Admin::FormHelper
|
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
-
def typus_text_field(attribute
|
|
133
|
+
def typus_text_field(attribute)
|
|
134
134
|
<<-HTML
|
|
135
|
-
<li><label for="item_#{attribute}">#{
|
|
136
|
-
#{text_area :item, attribute, :class => 'text', :rows =>
|
|
135
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
136
|
+
#{text_area :item, attribute, :class => 'text', :rows => @resource[:class].typus_options_for(:form_rows), :disabled => attribute_disabled?(attribute)}</li>
|
|
137
137
|
HTML
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
def typus_time_field(attribute, options
|
|
140
|
+
def typus_time_field(attribute, options)
|
|
141
141
|
<<-HTML
|
|
142
|
-
<li><label for="item_#{attribute}">#{
|
|
143
|
-
#{time_select :item, attribute, options, {:disabled => attribute_disabled?(attribute
|
|
142
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
143
|
+
#{time_select :item, attribute, options, {:disabled => attribute_disabled?(attribute)}}</li>
|
|
144
144
|
HTML
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
-
def typus_tree_field(attribute, items = @resource[:class].roots, attribute_virtual = 'parent_id'
|
|
147
|
+
def typus_tree_field(attribute, items = @resource[:class].roots, attribute_virtual = 'parent_id')
|
|
148
148
|
<<-HTML
|
|
149
|
-
<li><label for="item_#{attribute}">#{
|
|
149
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
|
150
150
|
<select id="item_#{attribute}" #{attribute_disabled?(attribute) ? 'disabled="disabled"' : ''} name="item[#{attribute}]">
|
|
151
151
|
<option value=""></option>
|
|
152
152
|
#{expand_tree_into_select_field(items, attribute_virtual)}
|
|
@@ -154,26 +154,26 @@ module Admin::FormHelper
|
|
|
154
154
|
HTML
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
def typus_string_field(attribute
|
|
157
|
+
def typus_string_field(attribute)
|
|
158
158
|
|
|
159
159
|
# Read only fields.
|
|
160
|
-
if
|
|
160
|
+
if @resource[:class].typus_field_options_for(:read_only).include?(attribute)
|
|
161
161
|
value = 'read_only' if %w( edit ).include?(params[:action])
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
# Auto generated fields.
|
|
165
|
-
if
|
|
165
|
+
if @resource[:class].typus_field_options_for(:auto_generated).include?(attribute)
|
|
166
166
|
value = 'auto_generated' if %w( new edit ).include?(params[:action])
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
comment = %w( read_only auto_generated ).include?(value) ? "<small>#{value} field</small>".humanize : ''
|
|
170
170
|
|
|
171
|
-
attribute_humanized =
|
|
171
|
+
attribute_humanized = @resource[:class].human_attribute_name(attribute)
|
|
172
172
|
attribute_humanized += " (#{attribute})" if attribute.include?('_id')
|
|
173
173
|
|
|
174
174
|
<<-HTML
|
|
175
175
|
<li><label for="item_#{attribute}">#{attribute_humanized}#{comment}</label>
|
|
176
|
-
#{text_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute
|
|
176
|
+
#{text_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute) }</li>
|
|
177
177
|
HTML
|
|
178
178
|
|
|
179
179
|
end
|
|
@@ -332,8 +332,8 @@ module Admin::FormHelper
|
|
|
332
332
|
output || "#{attribute}: Can not find the template '#{template}'"
|
|
333
333
|
end
|
|
334
334
|
|
|
335
|
-
def attribute_disabled?(attribute
|
|
336
|
-
accessible =
|
|
335
|
+
def attribute_disabled?(attribute)
|
|
336
|
+
accessible = @resource[:class].accessible_attributes
|
|
337
337
|
return accessible.nil? ? false : !accessible.include?(attribute)
|
|
338
338
|
end
|
|
339
339
|
|
|
@@ -57,7 +57,7 @@ module Admin::MasterHelper
|
|
|
57
57
|
|
|
58
58
|
template = "app/views/admin/#{resource}/_#{resource.singularize}.html.erb"
|
|
59
59
|
|
|
60
|
-
if File.
|
|
60
|
+
if File.exist?(template)
|
|
61
61
|
render :partial => template.gsub('/_', '/'), :collection => items, :as => :item
|
|
62
62
|
else
|
|
63
63
|
build_typus_table(model, fields, items, link_options, association)
|
|
@@ -2,18 +2,21 @@ module Admin
|
|
|
2
2
|
|
|
3
3
|
module PublicHelper
|
|
4
4
|
|
|
5
|
+
##
|
|
6
|
+
# Quick edit usage:
|
|
7
|
+
#
|
|
8
|
+
# <%= quick_edit(:message => "Edit this article", :path => "articles/edit/#{@article.id}") %>
|
|
9
|
+
#
|
|
10
|
+
# If user is logged in Typus, a link will appear on the top/right of
|
|
11
|
+
# the pages where you insert this helper.
|
|
12
|
+
#
|
|
5
13
|
def quick_edit(*args)
|
|
6
14
|
|
|
7
15
|
options = args.extract_options!
|
|
8
|
-
options[:color] ||= '#000'
|
|
9
|
-
options[:link] ||= admin_quick_edit_path
|
|
10
|
-
|
|
11
|
-
query = options.dup
|
|
12
|
-
[ :color, :link ].each { |o| query.delete(o) }
|
|
13
16
|
|
|
14
17
|
<<-HTML
|
|
15
18
|
<script type="text/javascript">
|
|
16
|
-
document.write('<script type="text/javascript" src="#{
|
|
19
|
+
document.write('<script type="text/javascript" src="#{admin_quick_edit_path}?#{options.to_query}" />');
|
|
17
20
|
</script>
|
|
18
21
|
HTML
|
|
19
22
|
|
data/app/helpers/typus_helper.rb
CHANGED
|
@@ -88,12 +88,22 @@ module TypusHelper
|
|
|
88
88
|
def typus_block(*args)
|
|
89
89
|
|
|
90
90
|
options = args.extract_options!
|
|
91
|
-
template = [ 'admin', options[:resource], options[:location], "_#{options[:partial]}.html.erb" ].compact.join('/')
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
partials_path = "admin/#{options[:location]}"
|
|
93
|
+
resources_partials_path = 'admin/resources'
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
partials = ActionController::Base.view_paths.map do |view_path|
|
|
96
|
+
Dir["#{Rails.root}/#{view_path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
|
|
97
|
+
end.flatten
|
|
98
|
+
resources_partials = Dir["#{Rails.root}/app/views/#{resources_partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
|
|
99
|
+
|
|
100
|
+
partial = "_#{options[:partial]}"
|
|
101
|
+
|
|
102
|
+
path = if partials.include?(partial) then partials_path
|
|
103
|
+
elsif resources_partials.include?(partial) then resources_partials_path
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
render :partial => "#{path}/#{options[:partial]}" if path
|
|
97
107
|
|
|
98
108
|
end
|
|
99
109
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<h2>Welcome to Typus!</h2>
|
|
2
2
|
|
|
3
|
-
<p>Documentation is available
|
|
3
|
+
<p>Documentation is available <%= link_to 'here', 'http://intraducibles.com/projects/typus', :rel => 'external' %>.</p>
|
|
4
4
|
|
|
5
|
-
<p>If you need help don't hesitate in joining the
|
|
5
|
+
<p>If you need help don't hesitate in joining the <%= link_to 'Typus', 'http://groups.google.com/group/typus', :rel => 'external' %> mailing list.</p>
|
|
6
6
|
|
|
7
7
|
<p>Replace this message adding a <code>_sidebar.html.erb</code> file on the <code>app/views/admin/dashboard</code> folder.</p>
|
|
8
8
|
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
<% content_for :sidebar do %>
|
|
2
|
-
<%= typus_block :
|
|
2
|
+
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
|
|
3
3
|
<%= actions %>
|
|
4
4
|
<% end %>
|
|
5
5
|
|
|
6
|
-
<%= typus_block :resource => @resource[:self], :partial => :edit %>
|
|
7
|
-
|
|
8
6
|
<%= display_link_to_previous if params[:back_to] %>
|
|
9
7
|
|
|
10
8
|
<h2><%= link_to _('Dashboard'), admin_dashboard_path %> ›
|
|
11
9
|
<%= link_to _(@resource[:class].human_name.pluralize), :action => 'index' %> ›
|
|
12
10
|
<%= _('Edit') %></h2>
|
|
13
11
|
|
|
14
|
-
<%= typus_block :
|
|
12
|
+
<%= typus_block :location => @resource[:self], :partial => 'edit' %>
|
|
15
13
|
|
|
16
14
|
<% form_for @item,
|
|
17
15
|
:url => { :action => 'update',
|
|
@@ -24,6 +22,4 @@
|
|
|
24
22
|
<p><%= submit_tag _('Update entry'), :class => 'button' %></p>
|
|
25
23
|
<% end %>
|
|
26
24
|
|
|
27
|
-
<%= typus_relationships %>
|
|
28
|
-
|
|
29
|
-
<%= typus_block :resource => @resource[:self], :partial => :edit_bottom %>
|
|
25
|
+
<%= typus_relationships %>
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
<% content_for :sidebar do %>
|
|
2
|
-
<%= typus_block :
|
|
2
|
+
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
|
|
3
3
|
<%= actions %>
|
|
4
4
|
<%= search %>
|
|
5
5
|
<%= filters %>
|
|
6
6
|
<% end %>
|
|
7
7
|
|
|
8
|
-
<%= typus_block :resource => @resource[:self], :partial => :index %>
|
|
9
|
-
|
|
10
8
|
<h2><%= link_to _('Dashboard'), admin_dashboard_path %> ›
|
|
11
9
|
<%= _(@resource[:class].human_name.pluralize) %> <%= remove_filter_link %></h2>
|
|
12
10
|
|
|
13
|
-
<%= typus_block :
|
|
11
|
+
<%= typus_block :location => @resource[:self], :partial => 'index' %>
|
|
14
12
|
|
|
15
13
|
<% unless @items.count.zero? -%>
|
|
16
14
|
<%= build_list(@resource[:class], @fields, @items) %>
|
|
@@ -23,6 +21,4 @@
|
|
|
23
21
|
<p><%= _("There are no {{records}} under this filter.", :records => @resource[:class].human_name.pluralize.downcase) %></p>
|
|
24
22
|
<% end %>
|
|
25
23
|
</div>
|
|
26
|
-
<% end %>
|
|
27
|
-
|
|
28
|
-
<%= typus_block :resource => @resource[:self], :partial => :index_bottom %>
|
|
24
|
+
<% end %>
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
<% content_for :sidebar do %>
|
|
2
|
-
<%= typus_block :
|
|
2
|
+
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
|
|
3
3
|
<%= actions %>
|
|
4
4
|
<% end %>
|
|
5
5
|
|
|
6
|
-
<%= typus_block :resource => @resource[:self], :partial => :new %>
|
|
7
|
-
|
|
8
6
|
<%= display_link_to_previous if params[:back_to] %>
|
|
9
7
|
|
|
10
8
|
<h2><%= link_to _('Dashboard'), admin_dashboard_path %> ›
|
|
11
9
|
<%= link_to _(@resource[:class].human_name.pluralize), :action => 'index' %> ›
|
|
12
10
|
<%= _('New') %></h2>
|
|
13
11
|
|
|
14
|
-
<%= typus_block :
|
|
12
|
+
<%= typus_block :location => @resource[:self], :partial => 'new' %>
|
|
15
13
|
|
|
16
14
|
<% form_for @item,
|
|
17
15
|
:url => { :action => 'create',
|
|
@@ -22,6 +20,4 @@
|
|
|
22
20
|
:html => { :multipart => true } do |f| %>
|
|
23
21
|
<%= build_form(@fields) %>
|
|
24
22
|
<p><%= submit_tag _('Create entry'), :class => 'button' %></p>
|
|
25
|
-
<% end %>
|
|
26
|
-
|
|
27
|
-
<%= typus_block :resource => @resource[:self], :partial => :new_bottom %>
|
|
23
|
+
<% end %>
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
<% content_for :sidebar do %>
|
|
2
|
-
<%= typus_block :
|
|
2
|
+
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
|
|
3
3
|
<%= actions %>
|
|
4
4
|
<% end %>
|
|
5
5
|
|
|
6
|
-
<%= typus_block :resource => @resource[:self], :partial => :show %>
|
|
7
|
-
|
|
8
6
|
<h2><%= link_to _('Dashboard'), admin_dashboard_path %> ›
|
|
9
7
|
<%= link_to _(@resource[:class].human_name.pluralize), :action => 'index' %> ›
|
|
10
8
|
<%= _('Show') %></h2>
|
|
11
9
|
|
|
12
|
-
<%= typus_block :
|
|
10
|
+
<%= typus_block :location => @resource[:self], :partial => 'show' %>
|
|
13
11
|
|
|
14
12
|
<dl>
|
|
15
13
|
<%- @fields.map { |u| u.first }.each do |column| -%>
|
|
16
14
|
<dt><%=h @resource[:class].human_attribute_name(column) %></dt>
|
|
17
15
|
<dd><%=h (!@item.send(column).blank?) ? @item.send(column) : 'nil' %></dd>
|
|
18
16
|
<%- end -%>
|
|
19
|
-
</dl>
|
|
20
|
-
|
|
21
|
-
<%= typus_block :resource => @resource[:self], :partial => :show_bottom %>
|
|
17
|
+
</dl>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<p
|
|
1
|
+
<p><%= link_to 'Typus', 'http://intraducibles.com/projects/typus', :rel => 'external' %> is the effortless backend interface for <%= link_to 'Ruby on Rails', 'http://rubyonrails.org/', :rel => 'external' %> applications.</p>
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
<%= typus_block :location => 'dashboard', :partial => 'sidebar' %>
|
|
3
3
|
<% end %>
|
|
4
4
|
|
|
5
|
-
<h2><%= _(
|
|
6
|
-
|
|
7
|
-
<%= typus_block :location => 'dashboard', :partial => 'top' %>
|
|
5
|
+
<h2><%= _('Dashboard') %></h2>
|
|
8
6
|
|
|
9
7
|
<%= resources %>
|
|
10
8
|
|
|
11
|
-
<%= applications %>
|
|
12
|
-
|
|
13
|
-
<%= typus_block :location => 'dashboard', :partial => 'bottom' %>
|
|
9
|
+
<%= applications %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<% form_tag admin_recover_password_path do %>
|
|
2
2
|
<ul>
|
|
3
|
-
<li><label for="email"><%= _(
|
|
4
|
-
<%= text_field :user, :email, :size =>
|
|
5
|
-
<li><%= submit_tag _(
|
|
3
|
+
<li><label for="email"><%= _('Email') %></label>
|
|
4
|
+
<%= text_field :user, :email, :size => 20, :class => 'text' %></li>
|
|
5
|
+
<li><%= submit_tag _('Recover password'), :class => 'button' %> <%= link_to _('I remember my password'), admin_sign_in_path %></li>
|
|
6
6
|
</ul>
|
|
7
7
|
<% end %>
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<%= hidden_field_tag :token, @user.token %>
|
|
4
4
|
|
|
5
5
|
<ul>
|
|
6
|
-
<li><label for="password"><%= _(
|
|
6
|
+
<li><label for="password"><%= _('Password') %></label>
|
|
7
7
|
<%= password_field :user, :password, :size => 20, :class => 'text' %></li>
|
|
8
|
-
<li><label for="password"><%= _(
|
|
8
|
+
<li><label for="password"><%= _('Password confirm') %></label>
|
|
9
9
|
<%= password_field :user, :password_confirmation, :size => 20, :class => 'text' %></li>
|
|
10
|
-
<li><%= submit_tag _(
|
|
10
|
+
<li><%= submit_tag _('Change password'), :class => 'button' %> <%= link_to _('I remember my password'), admin_sign_in_path %></li>
|
|
11
11
|
</ul>
|
|
12
12
|
|
|
13
13
|
<% end %>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<% form_tag admin_sign_in_path(:back_to => params[:back_to]) do %>
|
|
2
2
|
<ul>
|
|
3
|
-
<li><label for="email"><%= _(
|
|
3
|
+
<li><label for="email"><%= _('Email') %></label>
|
|
4
4
|
<%= text_field :user, :email, :size => 20, :class => 'text' %></li>
|
|
5
|
-
<li><label for="password"><%= _(
|
|
5
|
+
<li><label for="password"><%= _('Password') %></label>
|
|
6
6
|
<%= password_field :user, :password, :size => 20, :class => 'text' %></li>
|
|
7
|
-
<li><%= submit_tag _(
|
|
7
|
+
<li><%= submit_tag _('Sign in'), :class => 'button' %> <%= link_to _('Recover password'), admin_recover_password_path if Typus::Configuration.options[:recover_password] %></li>
|
|
8
8
|
</ul>
|
|
9
9
|
<% end %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<% form_tag admin_sign_up_path do %>
|
|
2
2
|
<ul>
|
|
3
|
-
<li><label for="email"><%= _(
|
|
3
|
+
<li><label for="email"><%= _('Email') %></label>
|
|
4
4
|
<%= text_field :user, :email, :size => 20, :class => 'text' %></li>
|
|
5
|
-
<li><%= submit_tag _(
|
|
5
|
+
<li><%= submit_tag _('Sign up'), :class => 'button' %></li>
|
|
6
6
|
</ul>
|
|
7
7
|
<% end %>
|
data/config/locales/es.yml
CHANGED
|
@@ -9,7 +9,6 @@ es:
|
|
|
9
9
|
"That doesn't seem like a valid email address": "Eso no parecia una dirección válida de correo electrónico."
|
|
10
10
|
"I remember my password": "Recuerdo mi contraseña"
|
|
11
11
|
"Password recovery link sent to your email": "Enlace de recuperación de contraseña enviado a tu correo electrónico."
|
|
12
|
-
"You can login with your new password": "Puedes acceder con tu nueva contraseña."
|
|
13
12
|
"Passwords don't match": "Las Contraseñas no coinciden."
|
|
14
13
|
"A valid token is required": "Se requiere un token válido."
|
|
15
14
|
"The email and/or password you entered is invalid": "El correo y/o la contraseña proporcionadas no son válidas."
|
data/config/locales/pt-BR.yml
CHANGED
|
@@ -9,7 +9,6 @@ pt-BR:
|
|
|
9
9
|
"That doesn't seem like a valid email address": "Este não parece um email válido"
|
|
10
10
|
"I remember my password": "Lembro minha senha"
|
|
11
11
|
"Password recovery link sent to your email": "Link para recuperar senha enviado para seu email."
|
|
12
|
-
"You can login with your new password": "Você já pode entrar com sua nova senha."
|
|
13
12
|
"Passwords don't match": "As senhas não conferem."
|
|
14
13
|
"A valid token is required": "É necessário um token válido."
|
|
15
14
|
"The email and/or password you entered is invalid": "O email e/ou a senha que você colocou são inválidos."
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
ru:
|
|
2
|
+
"Email": "E-Mail"
|
|
3
|
+
"Password": "Пароль"
|
|
4
|
+
"Password confirmation": "Подтверждение пароля"
|
|
5
|
+
"Sign in": "Войти"
|
|
6
|
+
"Recover password": "Восстановить пароль"
|
|
7
|
+
"Sign up": "Зарегистрироваться"
|
|
8
|
+
"Enter your email below to create the first user": "Введите E-Mail для создания первого пользователя"
|
|
9
|
+
"That doesn't seem like a valid email address": "E-Mail некорректен"
|
|
10
|
+
"I remember my password": "Запомнить пароль"
|
|
11
|
+
"Password recovery link sent to your email": "Ссылка для восставновления пароля выслана по указанному E-Mail"
|
|
12
|
+
"Passwords don't match": "Пароли не совпадают"
|
|
13
|
+
"A valid token is required": "Необходим корректный ключ"
|
|
14
|
+
"The email and/or password you entered is invalid": "E-Mail или пароль введены неверно"
|
|
15
|
+
"There are not defined applications in config/typus/*.yml": "Ни одного приложения не определено в config/typus/*.yml"
|
|
16
|
+
"Overview": "Обзор"
|
|
17
|
+
"Options": "Опции"
|
|
18
|
+
"Password confirmation": "Подтверждение пароля"
|
|
19
|
+
"Change password": "Сменить пароль"
|
|
20
|
+
"There are no {{records}}": "{{records}} не найдены"
|
|
21
|
+
"There are no {{records}} under this filter": "{{records}} по такому фильтру не найдены"
|
|
22
|
+
"Dashboard": "Обзор"
|
|
23
|
+
"Create entry": "Создать запись"
|
|
24
|
+
"Update entry": "Изменить запись"
|
|
25
|
+
"New": "Новый"
|
|
26
|
+
"Show": "Показать"
|
|
27
|
+
"Edit": "Editar"
|
|
28
|
+
"Login": "Редактировать"
|
|
29
|
+
"Setup": "Установки"
|
|
30
|
+
"Create": "Создать"
|
|
31
|
+
"Sign out": "Выйти"
|
|
32
|
+
"Update": "Обновить"
|
|
33
|
+
"View site": "Перейти к сайту"
|
|
34
|
+
"Logged as": "Вы вошли как"
|
|
35
|
+
"Remove filter": "Удалить фильтр"
|
|
36
|
+
"Back to list": "Назад к списку"
|
|
37
|
+
"Actions": "Действия"
|
|
38
|
+
"Add": "Добавить"
|
|
39
|
+
"← Previous": "← Предыдущая"
|
|
40
|
+
"Next →": "Следующая →"
|
|
41
|
+
"Previous": "Предыдующий"
|
|
42
|
+
"Next": "Следующий"
|
|
43
|
+
"Search": "Поиск"
|
|
44
|
+
"Search by": "Искать по"
|
|
45
|
+
"{{model}} successfully updated": "{{model}} успешно обновлен"
|
|
46
|
+
"{{model}} successfully created": "{{model}} создан"
|
|
47
|
+
"{{model}} successfully removed": "{{model}} удален"
|
|
48
|
+
"{{model}} {{attribute}} changed": "{{model}} {{attribute}} изменен"
|
|
49
|
+
"You're adding a new {{resource_from}} to {{resource_to}}": "Вы добавляете новый {{resource_from}} для {{resource_to}}."
|
|
50
|
+
"You're adding a new {{resource_from}}": "Вы добавляете новый {{resource_from}}."
|
|
51
|
+
"You're updating a {{resource_from}} for {{resource_to}}": "Вы редактируете {{resource_from}} для {{resource_to}}."
|
|
52
|
+
"You're updating a {{resource_from}}": "Вы редактируете {{resource_from}}."
|
|
53
|
+
"Toggle is disabled": "Переключение отключено"
|
|
54
|
+
"Record moved {{to}}": "Запись перемещена в {{to}}."
|
|
55
|
+
"{{model_a}} related to {{model_b}}": "{{model_a}} присоединен с {{model_b}}."
|
|
56
|
+
"{{model_a}} successfully assigned to {{model_b}}": "{{model_a}} добавлен к {{model_b}}."
|
|
57
|
+
"{{model_a}} unrelated from {{model_b}}": "{{model_a}} отсоединен от {{model_b}}."
|
|
58
|
+
"{{model_a}} removed from {{model_b}}": "{{model_a}} удален из {{model_b}}."
|
|
59
|
+
"Your new password is {{password}}": "Ваш новый пароль: {{password}}."
|
|
60
|
+
"Add entry": "Добавить запись"
|
|
61
|
+
"Go to": "Перейти к"
|
|
62
|
+
"First name": "Имя"
|
|
63
|
+
"Last name": "Фамлия"
|
|
64
|
+
"Roles": "Роли"
|
|
65
|
+
"Status": "Статус"
|
|
66
|
+
"Typus User": "Системный пользователь"
|
|
67
|
+
"System Users Administration": "Администрирование системных пользователей"
|
|
68
|
+
"Resources": "Ресурсы"
|
|
69
|
+
"Up": "Вверх"
|
|
70
|
+
"Down": "Вниз"
|
|
71
|
+
"filter by": "фильтр по"
|
|
72
|
+
"Checked if active": "Отмечено, если активно"
|
|
73
|
+
"As you're not the admin or the owner of this record you cannot edit it": "Вы не администратор и не владелец записи и не можете ее редактировать"
|
|
74
|
+
"You can't change your role": "Вы не можете менять свою собственную роль"
|
|
75
|
+
"Error! Typus User or role doesn't exist": "Ошибка! Пользователь или роль не существует"
|
|
76
|
+
"You can't toggle your status": "Вы не можете менять свой статус"
|
|
77
|
+
"You're not allowed to toggle status": "Вам не позволено менять статус"
|
|
78
|
+
"You can't remove yourself": "Вы не можете удалить себя"
|
|
79
|
+
"You're not allowed to remove Typus Users": "Вам не позволено удалять системных пользователей"
|
|
80
|
+
"{{current_user_role}} can't perform action. ({{action}})": "{{current_user_role}} не может выполнить действие. ({{action}})"
|
|
81
|
+
"{{current_user_role}} can't go to {{action}} on {{controller}}": "{{current_user_role}} не может перейти к {{action}} в {{controller}}."
|
|
82
|
+
"{{current_user_role}} can't delete this item": "{{current_user_role}} не может удалить эту запись"
|
|
83
|
+
"{{current_user_role}} can't perform action ({{action}})": "{{current_user_role}} не может выполнить действие ({{action}})"
|
|
84
|
+
"Record owned by another user": "Запись принадлежит другому пользователю."
|
|
85
|
+
"{{current_user_role}} can't display items": "{{current_user_role}} не может отобразить записи"
|
|
86
|
+
"Submodules": "Подмодули"
|
|
87
|
+
"Parent module": "Дочерний модуль"
|
|
88
|
+
"You can update your password at": "Вы можете установить свой пароль на"
|
|
89
|
+
"If you didn't request a password update, you can ignore this message": "Если Вы не запрашивали обновление пароля, Вы можете проигнорировать это сообщение."
|
|
90
|
+
"Have a nice day": "Добрый день."
|
|
91
|
+
"Reset password": "Сбросить пароль"
|
|
92
|
+
"Add new": "Добавить новый"
|
|
93
|
+
"Do you want to cancel it?": "Вы хотите отменить это?"
|
|
94
|
+
"Click here": "Кликните сюда"
|
|
95
|
+
"Are you sure you want to leave this page?": "Вы уверены, что хотите покинуть страницу?"
|
|
96
|
+
"If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost": "Если вы сделали какие-то изменения, не кликая на Обновить/Сохранить, то они будут утеряны."
|
|
97
|
+
"Click OK to continue, or click Cancel to stay on this page": "нажмите Ок, чтобы продолжить или Отмена, чтобы остаться на этой странице."
|
|
98
|
+
"Remove entry?": "Удалить запись?"
|
|
99
|
+
"Unrelate {{unrelate_model}} from {{unrelate_model_from}}?": "Отсоединить {{unrelate_model}} от {{unrelate_model_from}}?"
|
|
100
|
+
"Change {{attribute}}?": "Изменить {{attribute}}?"
|
|
101
|
+
"Set language": "Установить язык"
|
|
102
|
+
"Today": "Сегодня"
|
|
103
|
+
"Past 7 days": "Последние 7 дней"
|
|
104
|
+
"This month": "Этот месяц"
|
|
105
|
+
"This year": "Этот год"
|
|
106
|
+
"Created at": "Создано"
|
|
107
|
+
"Updated at": "Обновлено"
|
data/lib/typus/active_record.rb
CHANGED
|
@@ -212,7 +212,7 @@ module Typus
|
|
|
212
212
|
# If a search is performed.
|
|
213
213
|
if query_params[:search]
|
|
214
214
|
search = typus_defaults_for(:search).map do |s|
|
|
215
|
-
["LOWER(#{s}) LIKE '%#{query_params[:search].downcase}%'"]
|
|
215
|
+
["LOWER(#{s}) LIKE '%#{ActiveRecord::Base.connection.quote_string(query_params[:search].downcase)}%'"]
|
|
216
216
|
end
|
|
217
217
|
conditions = merge_conditions(conditions, search.join(' OR '))
|
|
218
218
|
end
|
data/lib/typus/generator.rb
CHANGED
|
@@ -64,7 +64,7 @@ end
|
|
|
64
64
|
view_folder = "#{admin_views_folder}/#{resource.underscore}"
|
|
65
65
|
view_filename = "index.html.erb"
|
|
66
66
|
|
|
67
|
-
if !File.
|
|
67
|
+
if !File.exist?("#{view_folder}/#{view_filename}")
|
|
68
68
|
Dir.mkdir(view_folder) unless File.directory?(view_folder)
|
|
69
69
|
view = File.open("#{view_folder}/#{view_filename}", "w+")
|
|
70
70
|
content = <<-RAW
|
data/lib/typus/quick_edit.rb
CHANGED
|
@@ -6,25 +6,32 @@ module Typus
|
|
|
6
6
|
|
|
7
7
|
render :text => '' and return unless session[:typus_user_id]
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
links = [[ "Dashboard", admin_dashboard_path ] ]
|
|
10
|
+
links << [ params[:message], "/admin/#{params[:path]}" ] if params[:message] && params[:path]
|
|
11
|
+
|
|
12
|
+
options = links.reverse.map do |link|
|
|
13
|
+
"<li><a href=\"#{link.last}\">#{link.first}</a></li>"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
content = <<-HTML
|
|
17
|
+
var links = '';
|
|
18
|
+
links += '<div id="quick_edit">';
|
|
19
|
+
links += '<ul>';
|
|
20
|
+
links += '#{options}';
|
|
21
|
+
links += '</ul>';
|
|
22
|
+
links += '</div>';
|
|
23
|
+
links += '<style type="text/css">';
|
|
24
|
+
links += '<!--';
|
|
25
|
+
links += '#quick_edit { font-size: 12px; font-family: sans-serif; position: absolute; top: 0px; right: 0px; margin: 10px; }';
|
|
26
|
+
links += '#quick_edit a { color: #FFF; font-weight: bold; text-decoration: none; }'
|
|
27
|
+
links += '#quick_edit ul { margin: 0; padding: 0; }';
|
|
28
|
+
links += '#quick_edit li { display: inline; background: #000; margin: 0 0 0 5px; padding: 3px 5px; }';
|
|
29
|
+
links += '-->';
|
|
30
|
+
links += '</style>';
|
|
31
|
+
document.write(links);
|
|
32
|
+
HTML
|
|
33
|
+
|
|
34
|
+
render :text => content
|
|
28
35
|
|
|
29
36
|
end
|
|
30
37
|
|
data/lib/typus.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_edit.html.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_index.html.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_new.html.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_show.html.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_sidebar.html.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_content.html.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
_sidebar.html.erb
|
|
@@ -11,24 +11,31 @@ class Admin::CommentsControllerTest < ActionController::TestCase
|
|
|
11
11
|
@comment = comments(:first)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def test_should_render_comments_partials_on_index
|
|
15
15
|
get :index
|
|
16
16
|
assert_response :success
|
|
17
|
-
partials = %w(
|
|
17
|
+
partials = %w( _index.html.erb _sidebar.html.erb )
|
|
18
18
|
partials.each { |p| assert_match p, @response.body }
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def
|
|
21
|
+
def test_should_render_comments_partials_on_new
|
|
22
|
+
get :new
|
|
23
|
+
assert_response :success
|
|
24
|
+
partials = %w( _new.html.erb _sidebar.html.erb )
|
|
25
|
+
partials.each { |p| assert_match p, @response.body }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_should_render_comments_partials_on_edit
|
|
22
29
|
get :edit, { :id => @comment.id }
|
|
23
30
|
assert_response :success
|
|
24
|
-
partials = %w(
|
|
31
|
+
partials = %w( _edit.html.erb _sidebar.html.erb )
|
|
25
32
|
partials.each { |p| assert_match p, @response.body }
|
|
26
33
|
end
|
|
27
34
|
|
|
28
|
-
def
|
|
35
|
+
def test_should_render_comments_partials_on_show
|
|
29
36
|
get :show, { :id => @comment.id }
|
|
30
37
|
assert_response :success
|
|
31
|
-
partials = %w(
|
|
38
|
+
partials = %w( _show.html.erb _sidebar.html.erb )
|
|
32
39
|
partials.each { |p| assert_match p, @response.body }
|
|
33
40
|
end
|
|
34
41
|
|
|
@@ -117,6 +117,13 @@ class TypusControllerTest < ActionController::TestCase
|
|
|
117
117
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
def test_should_sign_in_user_after_password_change
|
|
121
|
+
typus_user = typus_users(:admin)
|
|
122
|
+
post :reset_password, { :token => typus_user.token, :user => { :password => '12345678', :password_confirmation => '12345678' } }
|
|
123
|
+
assert_response :redirect
|
|
124
|
+
assert_redirected_to admin_dashboard_path
|
|
125
|
+
end
|
|
126
|
+
|
|
120
127
|
def test_should_be_redirected_if_password_does_not_match_confirmation
|
|
121
128
|
typus_user = typus_users(:admin)
|
|
122
129
|
post :reset_password, { :token => typus_user.token, :user => { :password => 'drowssap', :password_confirmation => 'drowssap2' } }
|
|
@@ -308,7 +315,7 @@ class TypusControllerTest < ActionController::TestCase
|
|
|
308
315
|
@request.session[:typus_user_id] = admin.id
|
|
309
316
|
get :dashboard
|
|
310
317
|
assert_response :success
|
|
311
|
-
partials = %w( _sidebar.html.erb
|
|
318
|
+
partials = %w( _sidebar.html.erb )
|
|
312
319
|
partials.each { |p| assert_match p, @response.body }
|
|
313
320
|
end
|
|
314
321
|
|
|
@@ -22,6 +22,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
22
22
|
|
|
23
23
|
@current_user = mock()
|
|
24
24
|
@current_user.expects(:can_perform?).with(Post, 'create').returns(false)
|
|
25
|
+
@resource = { :class => Comment }
|
|
25
26
|
|
|
26
27
|
expected = <<-HTML
|
|
27
28
|
<li><label for="item_post">Post
|
|
@@ -34,7 +35,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
34
35
|
<option value="2">Post#2</option></select></li>
|
|
35
36
|
HTML
|
|
36
37
|
|
|
37
|
-
assert_equal expected, typus_belongs_to_field('post'
|
|
38
|
+
assert_equal expected, typus_belongs_to_field('post')
|
|
38
39
|
|
|
39
40
|
end
|
|
40
41
|
|
|
@@ -47,6 +48,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
47
48
|
|
|
48
49
|
@current_user = mock()
|
|
49
50
|
@current_user.expects(:can_perform?).with(Comment, 'create').returns(true)
|
|
51
|
+
@resource = { :class => Post }
|
|
50
52
|
|
|
51
53
|
expected = <<-HTML
|
|
52
54
|
<li><label for="item_favorite_comment">Favorite comment
|
|
@@ -58,13 +60,15 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
58
60
|
<option value="3">John</option>
|
|
59
61
|
<option value="4">Me</option></select></li>
|
|
60
62
|
HTML
|
|
61
|
-
assert_equal expected, typus_belongs_to_field('favorite_comment'
|
|
63
|
+
assert_equal expected, typus_belongs_to_field('favorite_comment')
|
|
62
64
|
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
def test_typus_boolean_field
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
@resource = { :class => Post }
|
|
70
|
+
|
|
71
|
+
output = typus_boolean_field('test')
|
|
68
72
|
|
|
69
73
|
expected = <<-HTML
|
|
70
74
|
<li><label for="item_test">Test</label>
|
|
@@ -77,7 +81,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
77
81
|
|
|
78
82
|
def test_typus_date_field
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
@resource = { :class => Post }
|
|
85
|
+
|
|
86
|
+
output = typus_date_field('test', {})
|
|
81
87
|
expected = <<-HTML
|
|
82
88
|
<li><label for="item_test">Test</label>
|
|
83
89
|
HTML
|
|
@@ -88,7 +94,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
88
94
|
|
|
89
95
|
def test_typus_datetime_field
|
|
90
96
|
|
|
91
|
-
|
|
97
|
+
@resource = { :class => Post }
|
|
98
|
+
|
|
99
|
+
output = typus_datetime_field('test', {})
|
|
92
100
|
expected = <<-HTML
|
|
93
101
|
<li><label for="item_test">Test</label>
|
|
94
102
|
HTML
|
|
@@ -99,7 +107,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
99
107
|
|
|
100
108
|
def test_typus_file_field
|
|
101
109
|
|
|
102
|
-
|
|
110
|
+
@resource = { :class => Post }
|
|
111
|
+
|
|
112
|
+
output = typus_file_field('asset_file_name')
|
|
103
113
|
expected = <<-HTML
|
|
104
114
|
<li><label for="item_asset_file_name">Asset</label>
|
|
105
115
|
<input id="item_asset" name="item[asset]" size="30" type="file" /></li>
|
|
@@ -111,7 +121,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
111
121
|
|
|
112
122
|
def test_typus_password_field
|
|
113
123
|
|
|
114
|
-
|
|
124
|
+
@resource = { :class => Post }
|
|
125
|
+
|
|
126
|
+
output = typus_password_field('test')
|
|
115
127
|
expected = <<-HTML
|
|
116
128
|
<li><label for="item_test">Test</label>
|
|
117
129
|
<input class="text" id="item_test" name="item[test]" size="30" type="password" /></li>
|
|
@@ -146,7 +158,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
146
158
|
|
|
147
159
|
def test_typus_text_field
|
|
148
160
|
|
|
149
|
-
|
|
161
|
+
@resource = { :class => Post }
|
|
162
|
+
|
|
163
|
+
output = typus_text_field('test')
|
|
150
164
|
expected = <<-HTML
|
|
151
165
|
<li><label for="item_test">Test</label>
|
|
152
166
|
<textarea class="text" cols="40" id="item_test" name="item[test]" rows="10"></textarea></li>
|
|
@@ -158,7 +172,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
158
172
|
|
|
159
173
|
def test_typus_time_field
|
|
160
174
|
|
|
161
|
-
|
|
175
|
+
@resource = { :class => Post }
|
|
176
|
+
|
|
177
|
+
output = typus_time_field('test', {})
|
|
162
178
|
expected = <<-HTML
|
|
163
179
|
<li><label for="item_test">Test</label>
|
|
164
180
|
HTML
|
|
@@ -191,7 +207,9 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
191
207
|
|
|
192
208
|
def test_typus_string_field
|
|
193
209
|
|
|
194
|
-
|
|
210
|
+
@resource = { :class => Post }
|
|
211
|
+
|
|
212
|
+
output = typus_string_field('test')
|
|
195
213
|
expected = <<-HTML
|
|
196
214
|
<li><label for="item_test">Test</label>
|
|
197
215
|
<input class="text" id="item_test" name="item[test]" size="30" type="text" /></li>
|
|
@@ -267,13 +285,15 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
267
285
|
|
|
268
286
|
def test_attribute_disabled
|
|
269
287
|
|
|
270
|
-
|
|
288
|
+
@resource = { :class => Post }
|
|
289
|
+
|
|
290
|
+
assert !attribute_disabled?('test')
|
|
271
291
|
|
|
272
292
|
Post.expects(:accessible_attributes).returns(['test'])
|
|
273
|
-
assert !attribute_disabled?('test'
|
|
293
|
+
assert !attribute_disabled?('test')
|
|
274
294
|
|
|
275
295
|
Post.expects(:accessible_attributes).returns(['no_test'])
|
|
276
|
-
assert attribute_disabled?('test'
|
|
296
|
+
assert attribute_disabled?('test')
|
|
277
297
|
|
|
278
298
|
end
|
|
279
299
|
|
|
@@ -49,7 +49,7 @@ class Admin::MasterHelperTest < ActiveSupport::TestCase
|
|
|
49
49
|
resource = 'typus_users'
|
|
50
50
|
|
|
51
51
|
self.stubs(:render).returns('a_template')
|
|
52
|
-
File.stubs(:
|
|
52
|
+
File.stubs(:exist?).returns(true)
|
|
53
53
|
|
|
54
54
|
output = build_list(model, fields, items, resource)
|
|
55
55
|
expected = 'a_template'
|
|
@@ -6,12 +6,12 @@ class Admin::PublicHelperTest < ActiveSupport::TestCase
|
|
|
6
6
|
|
|
7
7
|
def test_quick_edit
|
|
8
8
|
|
|
9
|
-
options = { :
|
|
9
|
+
options = { :path => 'articles/edit/1', :message => 'Edit this article' }
|
|
10
10
|
output = quick_edit(options)
|
|
11
11
|
|
|
12
12
|
html = <<-HTML
|
|
13
13
|
<script type="text/javascript">
|
|
14
|
-
document.write('<script type="text/javascript" src="quick_edit?
|
|
14
|
+
document.write('<script type="text/javascript" src="quick_edit?message=Edit+this+article&path=articles%2Fedit%2F1" />');
|
|
15
15
|
</script>
|
|
16
16
|
HTML
|
|
17
17
|
|
|
@@ -19,4 +19,8 @@ class Admin::PublicHelperTest < ActiveSupport::TestCase
|
|
|
19
19
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def admin_quick_edit_path
|
|
23
|
+
'quick_edit'
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
end
|
|
@@ -8,7 +8,7 @@ class ConfigurationTest < ActiveSupport::TestCase
|
|
|
8
8
|
|
|
9
9
|
def test_should_verify_application_wide_configuration_options
|
|
10
10
|
initializer = "#{Rails.root}/config/initializers/typus.rb"
|
|
11
|
-
return if File.
|
|
11
|
+
return if File.exist?(initializer)
|
|
12
12
|
assert_equal 'Typus', Typus::Configuration.options[:app_name]
|
|
13
13
|
assert_equal 'vendor/plugins/typus/test/config/working', Typus::Configuration.options[:config_folder]
|
|
14
14
|
assert_equal 'admin@example.com', Typus::Configuration.options[:email]
|
|
@@ -23,7 +23,7 @@ class ConfigurationTest < ActiveSupport::TestCase
|
|
|
23
23
|
|
|
24
24
|
def test_should_verify_model_configuration_options
|
|
25
25
|
initializer = "#{Rails.root}/config/initializers/typus.rb"
|
|
26
|
-
return if File.
|
|
26
|
+
return if File.exist?(initializer)
|
|
27
27
|
assert_equal 'edit', Typus::Configuration.options[:default_action_on_item]
|
|
28
28
|
assert_equal nil, Typus::Configuration.options[:end_year]
|
|
29
29
|
assert_equal 10, Typus::Configuration.options[:form_rows]
|
data/test/lib/typus_test.rb
CHANGED
|
@@ -14,7 +14,7 @@ class TypusTest < ActiveSupport::TestCase
|
|
|
14
14
|
|
|
15
15
|
def test_should_return_locales
|
|
16
16
|
initializer = "#{Rails.root}/config/initializers/typus.rb"
|
|
17
|
-
return if File.
|
|
17
|
+
return if File.exist?(initializer)
|
|
18
18
|
assert Typus.respond_to?(:locales)
|
|
19
19
|
assert Typus.locales.kind_of?(Array)
|
|
20
20
|
assert_equal [["English", :en]], Typus.locales
|
|
@@ -18,6 +18,12 @@ class TypusUserTest < ActiveSupport::TestCase
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def test_should_verify_definition_on_instance_methods
|
|
22
|
+
%w( is_root? authenticated? ).each do |instance_method|
|
|
23
|
+
assert TypusUser.instance_methods.include?(instance_method)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
def test_should_verify_email_format
|
|
22
28
|
@typus_user.email = 'admin'
|
|
23
29
|
assert @typus_user.invalid?
|
data/typus.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{typus}
|
|
5
|
-
s.version = "0.9.
|
|
5
|
+
s.version = "0.9.7"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Francesc Esplugas"]
|
|
9
|
-
s.date = %q{2009-
|
|
9
|
+
s.date = %q{2009-06-07}
|
|
10
10
|
s.description = %q{Effortless backend interface for Ruby on Rails applications. (Admin scaffold generator.)}
|
|
11
11
|
s.email = %q{francesc@intraducibles.com}
|
|
12
12
|
s.extra_rdoc_files = [
|
|
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
|
|
|
45
45
|
"app/views/typus_mailer/reset_password_link.erb",
|
|
46
46
|
"config/locales/es.yml",
|
|
47
47
|
"config/locales/pt-BR.yml",
|
|
48
|
+
"config/locales/ru.yml",
|
|
48
49
|
"config/locales/typus_hacks.yml",
|
|
49
50
|
"config/routes.rb",
|
|
50
51
|
"generators/typus/templates/config/initializers/typus.rb",
|
|
@@ -112,21 +113,14 @@ Gem::Specification.new do |s|
|
|
|
112
113
|
"test/fixtures/app/controllers/admin/status_controller.rb",
|
|
113
114
|
"test/fixtures/app/controllers/admin/typus_users_controller.rb",
|
|
114
115
|
"test/fixtures/app/controllers/admin/watch_dog_controller.rb",
|
|
115
|
-
"test/fixtures/app/views/admin/comments/
|
|
116
|
-
"test/fixtures/app/views/admin/comments/
|
|
117
|
-
"test/fixtures/app/views/admin/comments/
|
|
118
|
-
"test/fixtures/app/views/admin/comments/
|
|
119
|
-
"test/fixtures/app/views/admin/comments/
|
|
120
|
-
"test/fixtures/app/views/admin/
|
|
121
|
-
"test/fixtures/app/views/admin/comments/_new_bottom.html.erb",
|
|
122
|
-
"test/fixtures/app/views/admin/comments/_new_sidebar.html.erb",
|
|
123
|
-
"test/fixtures/app/views/admin/comments/_new_top.html.erb",
|
|
124
|
-
"test/fixtures/app/views/admin/comments/_show_bottom.html.erb",
|
|
125
|
-
"test/fixtures/app/views/admin/comments/_show_sidebar.html.erb",
|
|
126
|
-
"test/fixtures/app/views/admin/comments/_show_top.html.erb",
|
|
127
|
-
"test/fixtures/app/views/admin/dashboard/_bottom.html.erb",
|
|
116
|
+
"test/fixtures/app/views/admin/comments/_edit.html.erb",
|
|
117
|
+
"test/fixtures/app/views/admin/comments/_index.html.erb",
|
|
118
|
+
"test/fixtures/app/views/admin/comments/_new.html.erb",
|
|
119
|
+
"test/fixtures/app/views/admin/comments/_show.html.erb",
|
|
120
|
+
"test/fixtures/app/views/admin/comments/_sidebar.html.erb",
|
|
121
|
+
"test/fixtures/app/views/admin/dashboard/_content.html.erb",
|
|
128
122
|
"test/fixtures/app/views/admin/dashboard/_sidebar.html.erb",
|
|
129
|
-
"test/fixtures/app/views/admin/
|
|
123
|
+
"test/fixtures/app/views/admin/resources/_sidebar.html.erb",
|
|
130
124
|
"test/fixtures/app/views/admin/shared/_footer.html.erb",
|
|
131
125
|
"test/fixtures/app/views/admin/status/index.html.erb",
|
|
132
126
|
"test/fixtures/app/views/admin/templates/_datepicker.html.erb",
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fesplugas-typus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Francesc Esplugas
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-06-07 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- app/views/typus_mailer/reset_password_link.erb
|
|
55
55
|
- config/locales/es.yml
|
|
56
56
|
- config/locales/pt-BR.yml
|
|
57
|
+
- config/locales/ru.yml
|
|
57
58
|
- config/locales/typus_hacks.yml
|
|
58
59
|
- config/routes.rb
|
|
59
60
|
- generators/typus/templates/config/initializers/typus.rb
|
|
@@ -121,21 +122,14 @@ files:
|
|
|
121
122
|
- test/fixtures/app/controllers/admin/status_controller.rb
|
|
122
123
|
- test/fixtures/app/controllers/admin/typus_users_controller.rb
|
|
123
124
|
- test/fixtures/app/controllers/admin/watch_dog_controller.rb
|
|
124
|
-
- test/fixtures/app/views/admin/comments/
|
|
125
|
-
- test/fixtures/app/views/admin/comments/
|
|
126
|
-
- test/fixtures/app/views/admin/comments/
|
|
127
|
-
- test/fixtures/app/views/admin/comments/
|
|
128
|
-
- test/fixtures/app/views/admin/comments/
|
|
129
|
-
- test/fixtures/app/views/admin/
|
|
130
|
-
- test/fixtures/app/views/admin/comments/_new_bottom.html.erb
|
|
131
|
-
- test/fixtures/app/views/admin/comments/_new_sidebar.html.erb
|
|
132
|
-
- test/fixtures/app/views/admin/comments/_new_top.html.erb
|
|
133
|
-
- test/fixtures/app/views/admin/comments/_show_bottom.html.erb
|
|
134
|
-
- test/fixtures/app/views/admin/comments/_show_sidebar.html.erb
|
|
135
|
-
- test/fixtures/app/views/admin/comments/_show_top.html.erb
|
|
136
|
-
- test/fixtures/app/views/admin/dashboard/_bottom.html.erb
|
|
125
|
+
- test/fixtures/app/views/admin/comments/_edit.html.erb
|
|
126
|
+
- test/fixtures/app/views/admin/comments/_index.html.erb
|
|
127
|
+
- test/fixtures/app/views/admin/comments/_new.html.erb
|
|
128
|
+
- test/fixtures/app/views/admin/comments/_show.html.erb
|
|
129
|
+
- test/fixtures/app/views/admin/comments/_sidebar.html.erb
|
|
130
|
+
- test/fixtures/app/views/admin/dashboard/_content.html.erb
|
|
137
131
|
- test/fixtures/app/views/admin/dashboard/_sidebar.html.erb
|
|
138
|
-
- test/fixtures/app/views/admin/
|
|
132
|
+
- test/fixtures/app/views/admin/resources/_sidebar.html.erb
|
|
139
133
|
- test/fixtures/app/views/admin/shared/_footer.html.erb
|
|
140
134
|
- test/fixtures/app/views/admin/status/index.html.erb
|
|
141
135
|
- test/fixtures/app/views/admin/templates/_datepicker.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_edit_bottom.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_edit_sidebar.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_edit_top.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_index_bottom.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_index_sidebar.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_index_top.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_new_bottom.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_new_sidebar.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_new_top.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_show_bottom.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_show_sidebar.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_show_top.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_bottom.html.erb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
_top.html.erb
|