typus 0.9.22 → 0.9.23
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +20 -2
- data/VERSION +1 -1
- data/app/controllers/admin/master_controller.rb +7 -7
- data/app/controllers/typus_controller.rb +19 -2
- data/app/helpers/admin/form_helper.rb +17 -17
- data/app/helpers/admin/sidebar_helper.rb +9 -9
- data/app/helpers/admin/table_helper.rb +25 -8
- data/app/helpers/typus_helper.rb +7 -1
- data/app/views/admin/dashboard/_sidebar.html.erb +1 -3
- data/app/views/typus_mailer/reset_password_link.erb +1 -6
- data/config/locales/typus/de.yml +3 -4
- data/config/locales/typus/es.yml +3 -4
- data/config/locales/typus/language.yml.template +3 -4
- data/config/locales/typus/pt-BR.yml +3 -4
- data/config/locales/typus/ru.yml +4 -5
- data/generators/typus/templates/config/initializers/typus.rb +0 -1
- data/generators/typus/templates/db/create_typus_users.rb +1 -0
- data/generators/typus_update_schema_to_02/templates/migration.rb +11 -0
- data/generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb +11 -0
- data/lib/typus/active_record.rb +18 -4
- data/lib/typus/authentication.rb +0 -4
- data/lib/typus/locale.rb +12 -2
- data/lib/typus/preview.rb +2 -2
- data/lib/typus/user.rb +7 -0
- data/test/helpers/admin/form_helper_test.rb +4 -1
- data/test/helpers/admin/sidebar_helper_test.rb +6 -6
- data/test/lib/active_record_test.rb +10 -11
- data/test/lib/configuration_test.rb +0 -1
- data/test/models.rb +3 -0
- data/test/unit/typus_mailer_test.rb +0 -4
- data/typus.gemspec +4 -2
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -26,6 +26,25 @@ Step 3: Go to the admin area and enjoy it!
|
|
26
26
|
|
27
27
|
http://0.0.0.0:3000/admin
|
28
28
|
|
29
|
+
== Want to see a demo working?
|
30
|
+
|
31
|
+
There's an application running at Heroku.
|
32
|
+
|
33
|
+
http://typus.heroku.com/
|
34
|
+
|
35
|
+
Use the following credentials to log in.
|
36
|
+
|
37
|
+
Email: userdemo@intraducibles.com
|
38
|
+
Password: userdemo
|
39
|
+
|
40
|
+
Notes on the application demo:
|
41
|
+
|
42
|
+
- Runs under SSL.
|
43
|
+
- Has an Assets model to show how assets can work.
|
44
|
+
- User can only edit the posts they have generated.
|
45
|
+
- User cannot edit Categories, just view them.
|
46
|
+
- Shows how TinyMCE is integrated with Pages.
|
47
|
+
|
29
48
|
== Installing
|
30
49
|
|
31
50
|
Install from GitHub the latest version which it's compatible with Rails 2.3.2.
|
@@ -58,8 +77,7 @@ Typus and blog about Typus.
|
|
58
77
|
|
59
78
|
== Fancyzoom for assets
|
60
79
|
|
61
|
-
This feature is a work in progress.
|
62
|
-
named asset and only previews images.
|
80
|
+
This feature is a work in progress. Only previews images.
|
63
81
|
|
64
82
|
# db/migrate/create_photos.rb
|
65
83
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.23
|
@@ -88,7 +88,7 @@ class Admin::MasterController < ApplicationController
|
|
88
88
|
@item = @resource[:class].new(params[:item])
|
89
89
|
|
90
90
|
if @item.attributes.include?(Typus.user_fk)
|
91
|
-
@item.attributes = { Typus.user_fk =>
|
91
|
+
@item.attributes = { Typus.user_fk => @current_user.id }
|
92
92
|
end
|
93
93
|
|
94
94
|
if @item.valid?
|
@@ -147,7 +147,7 @@ class Admin::MasterController < ApplicationController
|
|
147
147
|
def destroy
|
148
148
|
@item.destroy
|
149
149
|
flash[:success] = _("{{model}} successfully removed.", :model => @resource[:class].typus_human_name)
|
150
|
-
redirect_to
|
150
|
+
redirect_to request.referer || admin_dashboard_path
|
151
151
|
rescue Exception => error
|
152
152
|
error_handler(error, params.merge(:action => 'index', :id => nil))
|
153
153
|
end
|
@@ -161,7 +161,7 @@ class Admin::MasterController < ApplicationController
|
|
161
161
|
else
|
162
162
|
flash[:notice] = _("Toggle is disabled.")
|
163
163
|
end
|
164
|
-
redirect_to
|
164
|
+
redirect_to request.referer || admin_dashboard_path
|
165
165
|
end
|
166
166
|
|
167
167
|
##
|
@@ -176,7 +176,7 @@ class Admin::MasterController < ApplicationController
|
|
176
176
|
def position
|
177
177
|
@item.send(params[:go])
|
178
178
|
flash[:success] = _("Record moved {{to}}.", :to => params[:go].gsub(/move_/, '').humanize.downcase)
|
179
|
-
redirect_to
|
179
|
+
redirect_to request.referer || admin_dashboard_path
|
180
180
|
end
|
181
181
|
|
182
182
|
##
|
@@ -256,9 +256,9 @@ private
|
|
256
256
|
|
257
257
|
# OPTIMIZE: `typus_users` is currently hard-coded. We should find a good name for this option.
|
258
258
|
if @item.respond_to?('typus_users') && !@item.send('typus_users').include?(@current_user) ||
|
259
|
-
@item.respond_to?(Typus.user_fk) &&
|
259
|
+
@item.respond_to?(Typus.user_fk) && !@item.owned_by?(@current_user)
|
260
260
|
flash[:notice] = _("You don't have permission to access this item.")
|
261
|
-
redirect_to
|
261
|
+
redirect_to request.referer || admin_dashboard_path
|
262
262
|
end
|
263
263
|
|
264
264
|
end
|
@@ -271,7 +271,7 @@ private
|
|
271
271
|
# If current user is not root and @resource has a foreign_key which
|
272
272
|
# is related to the logged user (Typus.user_fk) we only show the user
|
273
273
|
# related items.
|
274
|
-
if @resource[:class].
|
274
|
+
if @resource[:class].typus_user_id?
|
275
275
|
condition = { Typus.user_fk => @current_user }
|
276
276
|
@conditions = @resource[:class].merge_conditions(@conditions, condition)
|
277
277
|
end
|
@@ -13,12 +13,15 @@ class TypusController < ApplicationController
|
|
13
13
|
include SslRequirement
|
14
14
|
ssl_required :sign_in, :sign_out,
|
15
15
|
:dashboard,
|
16
|
-
:recover_password, :reset_password
|
16
|
+
:recover_password, :reset_password,
|
17
|
+
:set_locale
|
17
18
|
end
|
18
19
|
|
19
20
|
filter_parameter_logging :password
|
20
21
|
|
21
|
-
before_filter :
|
22
|
+
before_filter :verify_typus_users_table_schema
|
23
|
+
|
24
|
+
before_filter :set_default_locale, :except => [ :dashboard ]
|
22
25
|
|
23
26
|
before_filter :reload_config_et_roles
|
24
27
|
before_filter :require_login,
|
@@ -35,6 +38,8 @@ class TypusController < ApplicationController
|
|
35
38
|
before_filter :recover_password_disabled?,
|
36
39
|
:only => [ :recover_password, :reset_password ]
|
37
40
|
|
41
|
+
before_filter :set_locale, :only => [ :dashboard ]
|
42
|
+
|
38
43
|
def dashboard
|
39
44
|
flash[:notice] = _("There are not defined applications in config/typus/*.yml.") if Typus.applications.empty?
|
40
45
|
end
|
@@ -117,6 +122,18 @@ class TypusController < ApplicationController
|
|
117
122
|
|
118
123
|
private
|
119
124
|
|
125
|
+
def verify_typus_users_table_schema
|
126
|
+
|
127
|
+
unless Typus.user_class.model_fields.keys.include?(:roles)
|
128
|
+
raise "Run `script/generate typus_update_schema_to_01 -f && rake db:migrate` to update database schema."
|
129
|
+
end
|
130
|
+
|
131
|
+
unless Typus.user_class.model_fields.keys.include?(:preferences)
|
132
|
+
raise "Run `script/generate typus_update_schema_to_02 -f && rake db:migrate` to update database schema."
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
120
137
|
def recover_password_disabled?
|
121
138
|
redirect_to admin_sign_in_path unless Typus::Configuration.options[:recover_password]
|
122
139
|
end
|
@@ -58,7 +58,7 @@ module Admin::FormHelper
|
|
58
58
|
html << typus_tree_field(related_fk, related.roots, related_fk)
|
59
59
|
else
|
60
60
|
html << <<-HTML
|
61
|
-
<li><label for="item_#{attribute}">#{
|
61
|
+
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}
|
62
62
|
<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>
|
63
63
|
</label>
|
64
64
|
#{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>
|
@@ -93,25 +93,27 @@ module Admin::FormHelper
|
|
93
93
|
HTML
|
94
94
|
end
|
95
95
|
|
96
|
-
#
|
96
|
+
# Optimize
|
97
97
|
def typus_file_field(attribute)
|
98
|
-
|
98
|
+
|
99
|
+
attachment = attribute.split('_file_name').first
|
100
|
+
|
99
101
|
unless @item.send(attribute).blank?
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
102
|
+
item = @item.send(attachment)
|
103
|
+
preview = if @item.send("#{attachment}_content_type") =~ /^image\/.+/ && item.styles.member?(:typus_thumbnail)
|
104
|
+
image_tag item.url(:typus_thumbnail)
|
105
|
+
else
|
106
|
+
link_to @item.send(attribute), item.url
|
107
|
+
end
|
108
108
|
end
|
109
|
+
|
109
110
|
<<-HTML
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
<li><label for="item_#{attribute}">#{_(attachment.humanize)}</label>
|
112
|
+
#{file_field :item, attachment, :disabled => attribute_disabled?(attribute)}
|
113
|
+
#{preview}
|
114
|
+
</li>
|
114
115
|
HTML
|
116
|
+
|
115
117
|
end
|
116
118
|
|
117
119
|
def typus_password_field(attribute)
|
@@ -235,8 +237,6 @@ module Admin::FormHelper
|
|
235
237
|
association = reflection.macro
|
236
238
|
foreign_key = reflection.through_reflection ? reflection.primary_key_name.pluralize : reflection.primary_key_name
|
237
239
|
|
238
|
-
#WEI: Changed link to use type name rather than field:
|
239
|
-
#WEI: link_options = { :controller => "admin/#{field}",
|
240
240
|
link_options = { :controller => "admin/#{model_to_relate_as_resource.pluralize}",
|
241
241
|
:action => 'new',
|
242
242
|
:back_to => "#{@back_to}##{field}",
|
@@ -28,10 +28,17 @@ module Admin::SidebarHelper
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
# OPTIMIZE
|
31
32
|
case params[:action]
|
32
33
|
when 'show'
|
33
34
|
if @current_user.can_perform?(@resource[:class], 'update')
|
34
|
-
|
35
|
+
if @item.typus_user_id?
|
36
|
+
if @item.owned_by?(@current_user)
|
37
|
+
items << (link_to _("Edit entry"), :action => 'edit', :id => @item.id)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
items << (link_to _("Edit entry"), :action => 'edit', :id => @item.id)
|
41
|
+
end
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -194,16 +201,9 @@ function surfto_#{model_pluralized}(form) {
|
|
194
201
|
|
195
202
|
end
|
196
203
|
|
197
|
-
##
|
198
|
-
# Thinking in update datetime_filters to ...
|
199
|
-
#
|
200
|
-
# %w( today last_few_days last_7_days last_30_days )
|
201
|
-
#
|
202
|
-
# ... which are the ones used by 'exception_logger'.
|
203
|
-
#
|
204
204
|
def datetime_filter(request, filter)
|
205
205
|
items = []
|
206
|
-
%w( today
|
206
|
+
%w( today last_few_days last_7_days last_30_days ).each do |timeline|
|
207
207
|
switch = request.include?("#{filter}=#{timeline}") ? 'on' : 'off'
|
208
208
|
options = { filter.to_sym => timeline, :page => nil }
|
209
209
|
items << (link_to _(timeline.humanize), params.merge(options), :class => switch)
|
@@ -31,14 +31,21 @@ module Admin::TableHelper
|
|
31
31
|
else
|
32
32
|
html << typus_table_string_field(key, item, link_options)
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
action = if item.typus_user_id? && !@current_user.is_root?
|
37
|
+
# If there's a typus_user_id column on the table and logged user is not root ...
|
38
|
+
item.owned_by?(@current_user) ? 'edit' : 'show'
|
39
|
+
elsif !@current_user.can_perform?(model, 'edit')
|
40
|
+
'show'
|
41
|
+
else
|
42
|
+
item.class.typus_options_for(:default_action_on_item)
|
43
|
+
end
|
44
|
+
|
45
|
+
content = link_to _(action.capitalize), :controller => "admin/#{item.class.name.tableize}", :action => action, :id => item.id
|
46
|
+
html << <<-HTML
|
40
47
|
<td width="10px">#{content}</td>
|
41
|
-
|
48
|
+
HTML
|
42
49
|
|
43
50
|
##
|
44
51
|
# This controls the action to perform. If we are on a model list we
|
@@ -149,10 +156,20 @@ module Admin::TableHelper
|
|
149
156
|
end
|
150
157
|
|
151
158
|
def typus_table_file_field(attribute, item, link_options = {})
|
152
|
-
|
159
|
+
|
160
|
+
attachment = attribute.split('_file_name').first
|
161
|
+
|
162
|
+
if item.send(attachment).styles.member?(:typus_preview) && item.send("#{attachment}_content_type") =~ /^image\/.+/
|
163
|
+
<<-HTML
|
153
164
|
<td><a href="##{item.to_dom(:suffix => 'zoom')}" id="#{item.to_dom}" title="Click to preview">#{item.send(attribute)}</a></td>
|
154
|
-
<div id
|
155
|
-
|
165
|
+
<div id=\"#{item.to_dom(:suffix => 'zoom')}\">#{item.typus_preview(attachment)}</div>
|
166
|
+
HTML
|
167
|
+
else
|
168
|
+
<<-HTML
|
169
|
+
<td>#{link_to item.send(attribute), item.send(attachment).url}</td>
|
170
|
+
HTML
|
171
|
+
end
|
172
|
+
|
156
173
|
end
|
157
174
|
|
158
175
|
def typus_table_tree_field(attribute, item)
|
data/app/helpers/typus_helper.rb
CHANGED
@@ -149,9 +149,15 @@ module TypusHelper
|
|
149
149
|
|
150
150
|
message = _("Are you sure you want to sign out and end your session?")
|
151
151
|
|
152
|
+
user_details = if user.can_perform?(Typus::Configuration.options[:user_class_name], 'edit')
|
153
|
+
link_to user.name, admin_edit_typus_user_path, :title => "#{user.email} (#{user.role})"
|
154
|
+
else
|
155
|
+
user.name
|
156
|
+
end
|
157
|
+
|
152
158
|
<<-HTML
|
153
159
|
<ul>
|
154
|
-
<li>#{_("Logged as")} #{
|
160
|
+
<li>#{_("Logged as")} #{user_details}</li>
|
155
161
|
<li>#{link_to _("Sign out"), admin_sign_out_path, { :confirm => message } }</li>
|
156
162
|
</ul>
|
157
163
|
HTML
|
@@ -4,6 +4,4 @@
|
|
4
4
|
|
5
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
|
-
<p>
|
8
|
-
|
9
|
-
<p>Have a nice day!</p>
|
7
|
+
<p>Replace this sidebar dropping a file named <code>_sidebar.html.erb</code> on the <code>app/views/admin/dashboard</code> folder.</p>
|
@@ -3,9 +3,4 @@
|
|
3
3
|
|
4
4
|
<%= url_for admin_reset_password_url(:token => @user.token) %>
|
5
5
|
|
6
|
-
<%= _("If you didn't request a password update, you can ignore this message") %>
|
7
|
-
|
8
|
-
<%= _("Have a nice day") %>
|
9
|
-
|
10
|
-
--
|
11
|
-
<%= Typus::Configuration.options[:app_name] %>
|
6
|
+
<%= _("If you didn't request a password update, you can ignore this message") %>
|
data/config/locales/typus/de.yml
CHANGED
@@ -86,7 +86,6 @@ de:
|
|
86
86
|
"{{current_user_role}} can't display items": "{{current_user_role}} kann Einträge nicht anzeigen"
|
87
87
|
"You can update your password at": "Sie k7ouml;nnen Ihr Passwort ändern unter"
|
88
88
|
"If you didn't request a password update, you can ignore this message": "Falls Sie keine Passwort Äderung beantragt haben, können Sie diese nachricht ignorieren"
|
89
|
-
"Have a nice day": "Haben Sie einen guten Tag"
|
90
89
|
"Reset password": "Passwort zurücksetzen"
|
91
90
|
"Add new": "Erstellen"
|
92
91
|
"Do you want to cancel it?": "Wollen Sie abbrechen?"
|
@@ -99,9 +98,9 @@ de:
|
|
99
98
|
"Change {{attribute}}?": "{{attribute}}ändern?"
|
100
99
|
"Set language": "Sprache einstellen"
|
101
100
|
"Today": "Heute"
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
101
|
+
"Last few days": "Letzten Tage"
|
102
|
+
"Last 7 days": "Letzten 7 Tage"
|
103
|
+
"Last 30 days": "Letzten 30 Tage"
|
105
104
|
"{{model}} filtered by {{filtered_by}}": "{{model}} gefiltert nach {{filtered_by}}"
|
106
105
|
"True": "Richtig"
|
107
106
|
"False": "Falsch"
|
data/config/locales/typus/es.yml
CHANGED
@@ -86,7 +86,6 @@ es:
|
|
86
86
|
"{{current_user_role}} can't display items": "{{current_user_role}} no puede mostrar los elementos."
|
87
87
|
"You can update your password at": "Puedes actualizar tu contraseña en"
|
88
88
|
"If you didn't request a password update, you can ignore this message": "Si no pediste una actualización de tu contraseña, puedes ignorar este mensaje."
|
89
|
-
"Have a nice day": "Que tengas un buen dia."
|
90
89
|
"Reset password": "Cambiar contraseña"
|
91
90
|
"Add new": "Añadir nuevo"
|
92
91
|
"Do you want to cancel it?": "¿Quieres cancelarlo?"
|
@@ -99,9 +98,9 @@ es:
|
|
99
98
|
"Change {{attribute}}?": "Change {{attribute}}?"
|
100
99
|
"Set language": "Cambiar idioma"
|
101
100
|
"Today": "Hoy"
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
101
|
+
"Last few days": "Últimos dias"
|
102
|
+
"Last 7 days": "Últimos 7 dias"
|
103
|
+
"Last 30 days": "Últimos 30 dias"
|
105
104
|
"{{model}} filtered by {{filtered_by}}": "{{model}} filtrados por {{filtered_by}}"
|
106
105
|
"True": "Verdadero"
|
107
106
|
"False": "Falso"
|
@@ -90,7 +90,6 @@
|
|
90
90
|
"{{current_user_role}} can't display items":
|
91
91
|
"You can update your password at":
|
92
92
|
"If you didn't request a password update, you can ignore this message":
|
93
|
-
"Have a nice day":
|
94
93
|
"Reset password":
|
95
94
|
"Add new":
|
96
95
|
"Do you want to cancel it?":
|
@@ -103,9 +102,9 @@
|
|
103
102
|
"Change {{attribute}}?":
|
104
103
|
"Set language":
|
105
104
|
"Today":
|
106
|
-
"
|
107
|
-
"
|
108
|
-
"
|
105
|
+
"Last few days":
|
106
|
+
"Last 7 days":
|
107
|
+
"Last 30 days":
|
109
108
|
"{{model}} filtered by {{filtered_by}}":
|
110
109
|
"True":
|
111
110
|
"False":
|
@@ -86,7 +86,6 @@ pt-BR:
|
|
86
86
|
"{{current_user_role}} can't display items": "{{current_user_role}} não pode mostrar os items."
|
87
87
|
"You can update your password at": "Você pode atualizar sua senha em"
|
88
88
|
"If you didn't request a password update, you can ignore this message": "Se você não pediu uma renovação de senha, por favor ignore esta mensagem."
|
89
|
-
"Have a nice day": "Tenha um bom dia."
|
90
89
|
"Reset password": "Trocar senha"
|
91
90
|
"Add new": "Adicionar novo"
|
92
91
|
"Do you want to cancel it?": "Quer cancelar?"
|
@@ -99,9 +98,9 @@ pt-BR:
|
|
99
98
|
"Change {{attribute}}?": "Mudar {{attribute}}?"
|
100
99
|
"Set language": "Mudar idioma"
|
101
100
|
"Today": "Hoje"
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
101
|
+
"Last few days": "Últimos dias"
|
102
|
+
"Last 7 days": "Últimos 7 dias"
|
103
|
+
"Last 30 days": "Últimos 30 dias"
|
105
104
|
"Created at": "Criado em"
|
106
105
|
"Updated at": "Atualizado em"
|
107
106
|
"{{model}} filtered by {{filtered_by}}": "{{model}} filtrados por {{filtered_by}}"
|
data/config/locales/typus/ru.yml
CHANGED
@@ -26,7 +26,7 @@ ru:
|
|
26
26
|
"Update entry": "Изменить запись"
|
27
27
|
"New": "Новый"
|
28
28
|
"Show": "Показать"
|
29
|
-
"Edit":
|
29
|
+
"Edit":
|
30
30
|
"Login": "Редактировать"
|
31
31
|
"Setup": "Установки"
|
32
32
|
"Create": "Создать"
|
@@ -86,7 +86,6 @@ ru:
|
|
86
86
|
"{{current_user_role}} can't display items": "{{current_user_role}} не может отобразить записи"
|
87
87
|
"You can update your password at": "Вы можете установить свой пароль на"
|
88
88
|
"If you didn't request a password update, you can ignore this message": "Если Вы не запрашивали обновление пароля, Вы можете проигнорировать это сообщение."
|
89
|
-
"Have a nice day": "Добрый день."
|
90
89
|
"Reset password": "Сбросить пароль"
|
91
90
|
"Add new": "Добавить новый"
|
92
91
|
"Do you want to cancel it?": "Вы хотите отменить это?"
|
@@ -99,9 +98,9 @@ ru:
|
|
99
98
|
"Change {{attribute}}?": "Изменить {{attribute}}?"
|
100
99
|
"Set language": "Установить язык"
|
101
100
|
"Today": "Сегодня"
|
102
|
-
"
|
103
|
-
"
|
104
|
-
"
|
101
|
+
"Last few days": "Последние дней"
|
102
|
+
"Last 7 days": "Последние 7 дней"
|
103
|
+
"Last 30 days": "Последние 30 дней"
|
105
104
|
"Created at": "Создано"
|
106
105
|
"Updated at": "Обновлено"
|
107
106
|
"{{model}} filtered by {{filtered_by}}":
|
@@ -5,7 +5,6 @@
|
|
5
5
|
Typus::Configuration.options[:app_name] = '<%= application %>'
|
6
6
|
# Typus::Configuration.options[:config_folder] = 'config/typus'
|
7
7
|
# Typus::Configuration.options[:email] = 'admin@example.com'
|
8
|
-
# Typus::Configuration.options[:image_preview_size] = :typus
|
9
8
|
# Typus::Configuration.options[:locales] = [ [ "English", :en ], [ "Español", :es ] ]
|
10
9
|
# Typus::Configuration.options[:recover_password] = true
|
11
10
|
# Typus::Configuration.options[:root] = 'admin'
|
data/lib/typus/active_record.rb
CHANGED
@@ -235,9 +235,11 @@ module Typus
|
|
235
235
|
# Sidebar filters:
|
236
236
|
#
|
237
237
|
# - Booleans: true, false
|
238
|
-
# - Datetime: today,
|
238
|
+
# - Datetime: today, last_few_days, last_7_days, last_30_days
|
239
239
|
# - Integer & String: *_id and "selectors" (p.ej. category_id)
|
240
240
|
#
|
241
|
+
# today last_few_days last_7_days last_30_days
|
242
|
+
#
|
241
243
|
case filter_type
|
242
244
|
when :boolean
|
243
245
|
condition = { key => (value == 'true') ? true : false }
|
@@ -245,9 +247,9 @@ module Typus
|
|
245
247
|
when :datetime
|
246
248
|
interval = case value
|
247
249
|
when 'today' then Time.new.midnight..Time.new.midnight.tomorrow
|
248
|
-
when '
|
249
|
-
when '
|
250
|
-
when '
|
250
|
+
when 'last_few_days' then 3.days.ago.midnight..Time.new.midnight.tomorrow
|
251
|
+
when 'last_7_days' then 6.days.ago.midnight..Time.new.midnight.tomorrow
|
252
|
+
when 'last_30_days' then Time.new.midnight.last_month..Time.new.midnight.tomorrow
|
251
253
|
end
|
252
254
|
condition = ["#{key} BETWEEN ? AND ?", interval.first.to_s(:db), interval.last.to_s(:db)]
|
253
255
|
conditions = merge_conditions(conditions, condition)
|
@@ -266,6 +268,10 @@ module Typus
|
|
266
268
|
|
267
269
|
end
|
268
270
|
|
271
|
+
def typus_user_id?
|
272
|
+
columns.map { |u| u.name }.include?(Typus.user_fk)
|
273
|
+
end
|
274
|
+
|
269
275
|
end
|
270
276
|
|
271
277
|
module InstanceMethods
|
@@ -299,6 +305,14 @@ module Typus
|
|
299
305
|
respond_to?(:name) ? name : "#{self.class}##{id}"
|
300
306
|
end
|
301
307
|
|
308
|
+
def typus_user_id?
|
309
|
+
self.class.typus_user_id?
|
310
|
+
end
|
311
|
+
|
312
|
+
def owned_by?(user)
|
313
|
+
send(Typus.user_fk) == user.id
|
314
|
+
end
|
315
|
+
|
302
316
|
end
|
303
317
|
|
304
318
|
end
|
data/lib/typus/authentication.rb
CHANGED
@@ -27,10 +27,6 @@ module Typus
|
|
27
27
|
|
28
28
|
@current_user = Typus.user_class.find(session[:typus_user_id])
|
29
29
|
|
30
|
-
unless @current_user.respond_to?(:role)
|
31
|
-
raise _("Run 'script/generate typus_update_schema_to_01 -f && rake db:migrate' to update database schema.")
|
32
|
-
end
|
33
|
-
|
34
30
|
unless Typus::Configuration.roles.keys.include?(@current_user.role)
|
35
31
|
raise _("Role does no longer exists.")
|
36
32
|
end
|
data/lib/typus/locale.rb
CHANGED
@@ -6,12 +6,22 @@ module Typus
|
|
6
6
|
if params[:locale]
|
7
7
|
I18n.locale = params[:locale]
|
8
8
|
session[:typus_locale] = params[:locale]
|
9
|
-
|
9
|
+
@current_user.update_attributes :preferences => { :locale => params[:locale] }
|
10
|
+
redirect_to request.referer || admin_dashboard_path
|
10
11
|
else
|
11
|
-
|
12
|
+
begin
|
13
|
+
I18n.locale = @current_user.preferences[:locale]
|
14
|
+
rescue
|
15
|
+
@current_user.update_attributes :preferences => { :locale => params[:locale] }
|
16
|
+
retry
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
|
21
|
+
def set_default_locale
|
22
|
+
I18n.locale = Typus.default_locale
|
23
|
+
end
|
24
|
+
|
15
25
|
end
|
16
26
|
|
17
27
|
end
|
data/lib/typus/preview.rb
CHANGED
@@ -2,8 +2,8 @@ module Typus
|
|
2
2
|
|
3
3
|
module InstanceMethods
|
4
4
|
|
5
|
-
def typus_preview
|
6
|
-
return "<img src=\"#{
|
5
|
+
def typus_preview(attachment)
|
6
|
+
return "<img src=\"#{send(attachment).url(:typus_preview)}\" />"
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
data/lib/typus/user.rb
CHANGED
@@ -25,6 +25,9 @@ module Typus
|
|
25
25
|
validates_presence_of :role
|
26
26
|
|
27
27
|
before_save :initialize_salt, :encrypt_password, :initialize_token
|
28
|
+
before_create :set_preferences
|
29
|
+
|
30
|
+
serialize :preferences
|
28
31
|
|
29
32
|
include InstanceMethods
|
30
33
|
|
@@ -96,6 +99,10 @@ module Typus
|
|
96
99
|
|
97
100
|
protected
|
98
101
|
|
102
|
+
def set_preferences
|
103
|
+
self.preferences = { :locale => Typus.default_locale }
|
104
|
+
end
|
105
|
+
|
99
106
|
def generate_hash(string)
|
100
107
|
Digest::SHA1.hexdigest(string)
|
101
108
|
end
|
@@ -109,11 +109,14 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
109
109
|
def test_typus_file_field
|
110
110
|
|
111
111
|
@resource = { :class => Post }
|
112
|
+
@item = Post.new
|
112
113
|
|
113
114
|
output = typus_file_field('asset_file_name')
|
114
115
|
expected = <<-HTML
|
115
116
|
<li><label for="item_asset_file_name">Asset</label>
|
116
|
-
<input id="item_asset" name="item[asset]" size="30" type="file"
|
117
|
+
<input id="item_asset" name="item[asset]" size="30" type="file" />
|
118
|
+
|
119
|
+
</li>
|
117
120
|
HTML
|
118
121
|
|
119
122
|
assert_equal expected, output
|
@@ -194,9 +194,9 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
194
194
|
<h2>Created at</h2>
|
195
195
|
<ul>
|
196
196
|
<li><a href="http://test.host/admin/typus_users?created_at=today" class="off">Today</a></li>
|
197
|
-
<li><a href="http://test.host/admin/typus_users?created_at=
|
198
|
-
<li><a href="http://test.host/admin/typus_users?created_at=
|
199
|
-
<li><a href="http://test.host/admin/typus_users?created_at=
|
197
|
+
<li><a href="http://test.host/admin/typus_users?created_at=last_few_days" class="off">Last few days</a></li>
|
198
|
+
<li><a href="http://test.host/admin/typus_users?created_at=last_7_days" class="off">Last 7 days</a></li>
|
199
|
+
<li><a href="http://test.host/admin/typus_users?created_at=last_30_days" class="off">Last 30 days</a></li>
|
200
200
|
</ul>
|
201
201
|
HTML
|
202
202
|
assert_equal expected, output
|
@@ -207,9 +207,9 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
207
207
|
<h2>Created at</h2>
|
208
208
|
<ul>
|
209
209
|
<li><a href="http://test.host/admin/typus_users?created_at=today" class="on">Today</a></li>
|
210
|
-
<li><a href="http://test.host/admin/typus_users?created_at=
|
211
|
-
<li><a href="http://test.host/admin/typus_users?created_at=
|
212
|
-
<li><a href="http://test.host/admin/typus_users?created_at=
|
210
|
+
<li><a href="http://test.host/admin/typus_users?created_at=last_few_days" class="off">Last few days</a></li>
|
211
|
+
<li><a href="http://test.host/admin/typus_users?created_at=last_7_days" class="off">Last 7 days</a></li>
|
212
|
+
<li><a href="http://test.host/admin/typus_users?created_at=last_30_days" class="off">Last 30 days</a></li>
|
213
213
|
</ul>
|
214
214
|
HTML
|
215
215
|
assert_equal expected, output
|
@@ -285,33 +285,32 @@ class ActiveRecordTest < ActiveSupport::TestCase
|
|
285
285
|
params = { :created_at => 'today' }
|
286
286
|
assert_equal expected, TypusUser.build_conditions(params).first
|
287
287
|
|
288
|
-
|
289
288
|
expected = case ENV['DB']
|
290
289
|
when /postgresql/
|
291
|
-
"(created_at BETWEEN E'#{
|
290
|
+
"(created_at BETWEEN E'#{3.days.ago.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
292
291
|
else
|
293
|
-
"(created_at BETWEEN '#{
|
292
|
+
"(created_at BETWEEN '#{3.days.ago.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
294
293
|
end
|
295
|
-
params = { :created_at => '
|
294
|
+
params = { :created_at => 'last_few_days' }
|
296
295
|
assert_equal expected, TypusUser.build_conditions(params).first
|
297
296
|
|
298
|
-
|
299
297
|
expected = case ENV['DB']
|
300
298
|
when /postgresql/
|
301
|
-
"(created_at BETWEEN E'#{
|
299
|
+
"(created_at BETWEEN E'#{6.days.ago.midnight.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
302
300
|
else
|
303
|
-
"(created_at BETWEEN '#{
|
301
|
+
"(created_at BETWEEN '#{6.days.ago.midnight.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
304
302
|
end
|
305
|
-
params = { :created_at => '
|
303
|
+
params = { :created_at => 'last_7_days' }
|
306
304
|
assert_equal expected, TypusUser.build_conditions(params).first
|
307
305
|
|
306
|
+
|
308
307
|
expected = case ENV['DB']
|
309
308
|
when /postgresql/
|
310
|
-
"(created_at BETWEEN E'#{Time.new.midnight.
|
309
|
+
"(created_at BETWEEN E'#{Time.new.midnight.last_month.to_s(:db)}' AND E'#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
311
310
|
else
|
312
|
-
"(created_at BETWEEN '#{Time.new.midnight.
|
311
|
+
"(created_at BETWEEN '#{Time.new.midnight.last_month.to_s(:db)}' AND '#{Time.new.midnight.tomorrow.to_s(:db)}')"
|
313
312
|
end
|
314
|
-
params = { :created_at => '
|
313
|
+
params = { :created_at => 'last_30_days' }
|
315
314
|
assert_equal expected, TypusUser.build_conditions(params).first
|
316
315
|
|
317
316
|
end
|
@@ -12,7 +12,6 @@ class ConfigurationTest < ActiveSupport::TestCase
|
|
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]
|
15
|
-
assert_equal 'typus', Typus::Configuration.options[:image_preview_size]
|
16
15
|
assert_equal [ [ "English", :en] ], Typus::Configuration.options[:locales]
|
17
16
|
assert_equal false, Typus::Configuration.options[:recover_password]
|
18
17
|
assert_equal 'admin', Typus::Configuration.options[:root]
|
data/test/models.rb
CHANGED
data/typus.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{typus}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.23"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Francesc Esplugas"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-09-03}
|
13
13
|
s.description = %q{Effortless backend interface for Ruby on Rails applications. (Admin scaffold generator.)}
|
14
14
|
s.email = %q{francesc@intraducibles.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -94,6 +94,8 @@ Gem::Specification.new do |s|
|
|
94
94
|
"generators/typus_update_schema_to_01/templates/config/typus.yml",
|
95
95
|
"generators/typus_update_schema_to_01/templates/migration.rb",
|
96
96
|
"generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb",
|
97
|
+
"generators/typus_update_schema_to_02/templates/migration.rb",
|
98
|
+
"generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb",
|
97
99
|
"lib/typus.rb",
|
98
100
|
"lib/typus/active_record.rb",
|
99
101
|
"lib/typus/authentication.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.23
|
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-09-03 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -100,6 +100,8 @@ files:
|
|
100
100
|
- generators/typus_update_schema_to_01/templates/config/typus.yml
|
101
101
|
- generators/typus_update_schema_to_01/templates/migration.rb
|
102
102
|
- generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb
|
103
|
+
- generators/typus_update_schema_to_02/templates/migration.rb
|
104
|
+
- generators/typus_update_schema_to_02/typus_update_schema_to_02_generator.rb
|
103
105
|
- lib/typus.rb
|
104
106
|
- lib/typus/active_record.rb
|
105
107
|
- lib/typus/authentication.rb
|