refinerycms-admin-locales 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/Gemfile +24 -3
- data/Gemfile.lock +249 -0
- data/Rakefile +5 -2
- data/app/controllers/refinery/admin_locales/admin/admin_locales_controller.rb +24 -0
- data/app/views/refinery/admin_locales/admin/admin_locales/_form.html.erb +14 -0
- data/app/views/{admin → refinery/admin_locales/admin}/admin_locales/_records.html.erb +0 -0
- data/app/views/{admin → refinery/admin_locales/admin}/admin_locales/_user.html.erb +2 -2
- data/app/views/{admin → refinery/admin_locales/admin}/admin_locales/_users.html.erb +0 -0
- data/app/views/refinery/admin_locales/admin/admin_locales/edit.html.erb +2 -0
- data/app/views/refinery/admin_locales/admin/admin_locales/index.html.erb +3 -0
- data/config/locales/en.yml +15 -13
- data/config/locales/es.yml +15 -13
- data/config/routes.rb +6 -3
- data/db/migrate/1_add_locale_to_user.rb +4 -6
- data/db/seeds.rb +8 -0
- data/lib/generators/refinery/admin_locales_generator.rb +19 -0
- data/lib/refinery/admin_locales.rb +21 -0
- data/lib/refinery/admin_locales/engine.rb +36 -0
- data/lib/refinery/admin_locales/version.rb +5 -4
- data/lib/refinerycms-admin-locales.rb +1 -44
- data/lib/tasks/refinery/admin_locales.rake +13 -0
- data/readme.md +11 -3
- data/refinerycms-admin-locales.gemspec +3 -3
- data/spec/controllers/refinery/admin_locales/admin/admin_locales_spec.rb +47 -0
- data/spec/factories/refinery/admin_locales.rb +10 -0
- data/spec/requests/refinery/admin_locales/admin/admin_locales_spec.rb +66 -81
- data/spec/spec_helper.rb +2 -8
- metadata +39 -22
- data/app/controllers/admin/admin_locales_controller.rb +0 -20
- data/app/views/admin/admin_locales/_form.html.erb +0 -20
- data/app/views/admin/admin_locales/edit.html.erb +0 -2
- data/app/views/admin/admin_locales/index.html.erb +0 -3
- data/db/seeds/refinerycms_admin_locales.rb +0 -6
- data/lib/generators/refinerycms_admin_locales_generator.rb +0 -8
- data/spec/support/factories/refinery/admin_locales.rb +0 -11
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -1,7 +1,28 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'refinerycms', '~> 2.0.0'
|
6
|
+
gem 'refinerycms-i18n', '~> 2.0.0'
|
7
|
+
gem 'refinerycms-settings', '~> 2.0.0'
|
8
|
+
|
3
9
|
group :development, :test do
|
4
|
-
|
5
|
-
gem '
|
6
|
-
gem '
|
10
|
+
|
11
|
+
gem 'therubyracer'
|
12
|
+
gem 'refinerycms-testing', '~> 2.0.0'
|
13
|
+
|
14
|
+
unless defined?(JRUBY_VERSION)
|
15
|
+
gem 'sqlite3'
|
16
|
+
gem 'mysql2'
|
17
|
+
gem 'pg'
|
18
|
+
end
|
7
19
|
end
|
20
|
+
|
21
|
+
# Refinery/rails should pull in the proper versions of these
|
22
|
+
group :assets do
|
23
|
+
gem 'sass-rails'
|
24
|
+
gem 'coffee-rails'
|
25
|
+
gem 'uglifier'
|
26
|
+
end
|
27
|
+
|
28
|
+
gem 'jquery-rails'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
refinerycms-admin-locales (2.1.0.dev)
|
5
|
+
refinerycms-core (~> 2.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.2.8)
|
11
|
+
actionpack (= 3.2.8)
|
12
|
+
mail (~> 2.4.4)
|
13
|
+
actionpack (3.2.8)
|
14
|
+
activemodel (= 3.2.8)
|
15
|
+
activesupport (= 3.2.8)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.4)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.3)
|
23
|
+
activemodel (3.2.8)
|
24
|
+
activesupport (= 3.2.8)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activerecord (3.2.8)
|
27
|
+
activemodel (= 3.2.8)
|
28
|
+
activesupport (= 3.2.8)
|
29
|
+
arel (~> 3.0.2)
|
30
|
+
tzinfo (~> 0.3.29)
|
31
|
+
activeresource (3.2.8)
|
32
|
+
activemodel (= 3.2.8)
|
33
|
+
activesupport (= 3.2.8)
|
34
|
+
activesupport (3.2.8)
|
35
|
+
i18n (~> 0.6)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
acts_as_indexed (0.7.8)
|
38
|
+
arel (3.0.2)
|
39
|
+
awesome_nested_set (2.1.6)
|
40
|
+
activerecord (>= 3.0.0)
|
41
|
+
babosa (0.3.10)
|
42
|
+
bcrypt-ruby (3.0.1)
|
43
|
+
builder (3.0.0)
|
44
|
+
capybara (1.1.4)
|
45
|
+
mime-types (>= 1.16)
|
46
|
+
nokogiri (>= 1.3.3)
|
47
|
+
rack (>= 1.0.0)
|
48
|
+
rack-test (>= 0.5.4)
|
49
|
+
selenium-webdriver (~> 2.0)
|
50
|
+
xpath (~> 0.1.4)
|
51
|
+
childprocess (0.3.9)
|
52
|
+
ffi (~> 1.0, >= 1.0.11)
|
53
|
+
coffee-rails (3.2.2)
|
54
|
+
coffee-script (>= 2.2.0)
|
55
|
+
railties (~> 3.2.0)
|
56
|
+
coffee-script (2.2.0)
|
57
|
+
coffee-script-source
|
58
|
+
execjs
|
59
|
+
coffee-script-source (1.3.3)
|
60
|
+
database_cleaner (0.7.2)
|
61
|
+
devise (2.0.5)
|
62
|
+
bcrypt-ruby (~> 3.0)
|
63
|
+
orm_adapter (~> 0.0.3)
|
64
|
+
railties (~> 3.1)
|
65
|
+
warden (~> 1.1.1)
|
66
|
+
diff-lcs (1.2.4)
|
67
|
+
dragonfly (0.9.15)
|
68
|
+
multi_json (~> 1.0)
|
69
|
+
rack
|
70
|
+
erubis (2.7.0)
|
71
|
+
execjs (1.4.0)
|
72
|
+
multi_json (~> 1.0)
|
73
|
+
factory_girl (2.6.4)
|
74
|
+
activesupport (>= 2.3.9)
|
75
|
+
factory_girl_rails (1.7.0)
|
76
|
+
factory_girl (~> 2.6.0)
|
77
|
+
railties (>= 3.0.0)
|
78
|
+
ffi (1.8.1)
|
79
|
+
friendly_id (4.0.9)
|
80
|
+
globalize3 (0.2.0)
|
81
|
+
activemodel (>= 3.0.0)
|
82
|
+
activerecord (>= 3.0.0)
|
83
|
+
paper_trail (~> 2)
|
84
|
+
hike (1.2.1)
|
85
|
+
i18n (0.6.0)
|
86
|
+
journey (1.0.4)
|
87
|
+
jquery-rails (2.0.2)
|
88
|
+
railties (>= 3.2.0, < 5.0)
|
89
|
+
thor (~> 0.14)
|
90
|
+
json (1.7.4)
|
91
|
+
libv8 (3.11.8.13)
|
92
|
+
mail (2.4.4)
|
93
|
+
i18n (>= 0.4.0)
|
94
|
+
mime-types (~> 1.16)
|
95
|
+
treetop (~> 1.4.8)
|
96
|
+
mime-types (1.23)
|
97
|
+
multi_json (1.3.6)
|
98
|
+
mysql2 (0.3.11)
|
99
|
+
nokogiri (1.5.9)
|
100
|
+
orm_adapter (0.0.7)
|
101
|
+
paper_trail (2.7.2)
|
102
|
+
activerecord (~> 3.0)
|
103
|
+
railties (~> 3.0)
|
104
|
+
pg (0.15.1)
|
105
|
+
polyglot (0.3.3)
|
106
|
+
rack (1.4.1)
|
107
|
+
rack-cache (1.2)
|
108
|
+
rack (>= 0.4)
|
109
|
+
rack-ssl (1.3.2)
|
110
|
+
rack
|
111
|
+
rack-test (0.6.1)
|
112
|
+
rack (>= 1.0)
|
113
|
+
rails (3.2.8)
|
114
|
+
actionmailer (= 3.2.8)
|
115
|
+
actionpack (= 3.2.8)
|
116
|
+
activerecord (= 3.2.8)
|
117
|
+
activeresource (= 3.2.8)
|
118
|
+
activesupport (= 3.2.8)
|
119
|
+
bundler (~> 1.0)
|
120
|
+
railties (= 3.2.8)
|
121
|
+
railties (3.2.8)
|
122
|
+
actionpack (= 3.2.8)
|
123
|
+
activesupport (= 3.2.8)
|
124
|
+
rack-ssl (~> 1.3.2)
|
125
|
+
rake (>= 0.8.7)
|
126
|
+
rdoc (~> 3.4)
|
127
|
+
thor (>= 0.14.6, < 2.0)
|
128
|
+
rake (0.9.2.2)
|
129
|
+
rdoc (3.12)
|
130
|
+
json (~> 1.4)
|
131
|
+
ref (1.0.2)
|
132
|
+
refinerycms (2.0.9)
|
133
|
+
bundler (~> 1.0)
|
134
|
+
refinerycms-authentication (= 2.0.9)
|
135
|
+
refinerycms-core (= 2.0.9)
|
136
|
+
refinerycms-dashboard (= 2.0.9)
|
137
|
+
refinerycms-images (= 2.0.9)
|
138
|
+
refinerycms-pages (= 2.0.9)
|
139
|
+
refinerycms-resources (= 2.0.9)
|
140
|
+
refinerycms-authentication (2.0.9)
|
141
|
+
devise (~> 2.0.0)
|
142
|
+
orm_adapter (~> 0.0.7)
|
143
|
+
refinerycms-core (= 2.0.9)
|
144
|
+
refinerycms-core (2.0.9)
|
145
|
+
acts_as_indexed (~> 0.7.7)
|
146
|
+
awesome_nested_set (~> 2.1.3)
|
147
|
+
coffee-rails (~> 3.2.1)
|
148
|
+
friendly_id (~> 4.0.1)
|
149
|
+
globalize3 (~> 0.2.0)
|
150
|
+
jquery-rails (~> 2.0.0)
|
151
|
+
rails (>= 3.1.3, < 3.3)
|
152
|
+
sass-rails (~> 3.2.3)
|
153
|
+
truncate_html (~> 0.5)
|
154
|
+
uglifier (>= 1.0.3)
|
155
|
+
will_paginate (~> 3.0.2)
|
156
|
+
refinerycms-dashboard (2.0.9)
|
157
|
+
refinerycms-core (= 2.0.9)
|
158
|
+
refinerycms-i18n (2.0.2)
|
159
|
+
refinerycms-core (~> 2.0.0)
|
160
|
+
routing-filter (>= 0.2.3)
|
161
|
+
refinerycms-images (2.0.9)
|
162
|
+
dragonfly (~> 0.9.8)
|
163
|
+
rack-cache (>= 0.5.3)
|
164
|
+
refinerycms-core (= 2.0.9)
|
165
|
+
refinerycms-pages (2.0.9)
|
166
|
+
awesome_nested_set (~> 2.1.3)
|
167
|
+
babosa (!= 0.3.6)
|
168
|
+
refinerycms-core (= 2.0.9)
|
169
|
+
seo_meta (~> 1.3.0)
|
170
|
+
refinerycms-resources (2.0.9)
|
171
|
+
dragonfly (~> 0.9.8)
|
172
|
+
rack-cache (>= 0.5.3)
|
173
|
+
refinerycms-core (= 2.0.9)
|
174
|
+
refinerycms-settings (2.0.2)
|
175
|
+
refinerycms-core (~> 2.0.1)
|
176
|
+
refinerycms-testing (2.0.9)
|
177
|
+
capybara (~> 1.1.2)
|
178
|
+
database_cleaner (~> 0.7.2)
|
179
|
+
factory_girl_rails (~> 1.7.0)
|
180
|
+
refinerycms-core (= 2.0.9)
|
181
|
+
rspec-rails (~> 2.11)
|
182
|
+
routing-filter (0.3.1)
|
183
|
+
actionpack
|
184
|
+
rspec-core (2.13.1)
|
185
|
+
rspec-expectations (2.13.0)
|
186
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
187
|
+
rspec-mocks (2.13.1)
|
188
|
+
rspec-rails (2.13.2)
|
189
|
+
actionpack (>= 3.0)
|
190
|
+
activesupport (>= 3.0)
|
191
|
+
railties (>= 3.0)
|
192
|
+
rspec-core (~> 2.13.0)
|
193
|
+
rspec-expectations (~> 2.13.0)
|
194
|
+
rspec-mocks (~> 2.13.0)
|
195
|
+
rubyzip (0.9.9)
|
196
|
+
sass (3.2.0)
|
197
|
+
sass-rails (3.2.5)
|
198
|
+
railties (~> 3.2.0)
|
199
|
+
sass (>= 3.1.10)
|
200
|
+
tilt (~> 1.3)
|
201
|
+
selenium-webdriver (2.33.0)
|
202
|
+
childprocess (>= 0.2.5)
|
203
|
+
multi_json (~> 1.0)
|
204
|
+
rubyzip
|
205
|
+
websocket (~> 1.0.4)
|
206
|
+
seo_meta (1.3.0)
|
207
|
+
railties (>= 3.0.0)
|
208
|
+
sprockets (2.1.3)
|
209
|
+
hike (~> 1.2)
|
210
|
+
rack (~> 1.0)
|
211
|
+
tilt (~> 1.1, != 1.3.0)
|
212
|
+
sqlite3 (1.3.6)
|
213
|
+
therubyracer (0.11.2)
|
214
|
+
libv8 (~> 3.11.8.12)
|
215
|
+
ref
|
216
|
+
thor (0.15.4)
|
217
|
+
tilt (1.3.3)
|
218
|
+
treetop (1.4.12)
|
219
|
+
polyglot
|
220
|
+
polyglot (>= 0.3.1)
|
221
|
+
truncate_html (0.9.2)
|
222
|
+
tzinfo (0.3.37)
|
223
|
+
uglifier (1.2.7)
|
224
|
+
execjs (>= 0.3.0)
|
225
|
+
multi_json (~> 1.3)
|
226
|
+
warden (1.1.1)
|
227
|
+
rack (>= 1.0)
|
228
|
+
websocket (1.0.7)
|
229
|
+
will_paginate (3.0.4)
|
230
|
+
xpath (0.1.4)
|
231
|
+
nokogiri (~> 1.3)
|
232
|
+
|
233
|
+
PLATFORMS
|
234
|
+
ruby
|
235
|
+
|
236
|
+
DEPENDENCIES
|
237
|
+
coffee-rails
|
238
|
+
jquery-rails
|
239
|
+
mysql2
|
240
|
+
pg
|
241
|
+
refinerycms (~> 2.0.0)
|
242
|
+
refinerycms-admin-locales!
|
243
|
+
refinerycms-i18n (~> 2.0.0)
|
244
|
+
refinerycms-settings (~> 2.0.0)
|
245
|
+
refinerycms-testing (~> 2.0.1)
|
246
|
+
sass-rails
|
247
|
+
sqlite3
|
248
|
+
therubyracer
|
249
|
+
uglifier
|
data/Rakefile
CHANGED
@@ -8,11 +8,14 @@ end
|
|
8
8
|
ENGINE_PATH = File.dirname(__FILE__)
|
9
9
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
10
10
|
|
11
|
-
|
11
|
+
if File.exists?(APP_RAKEFILE)
|
12
|
+
load 'rails/tasks/engine.rake'
|
13
|
+
end
|
12
14
|
|
13
15
|
require "refinerycms-testing"
|
14
16
|
Refinery::Testing::Railtie.load_tasks
|
15
17
|
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
|
16
18
|
|
17
|
-
load File.expand_path('../tasks/testing.rake', __FILE__)
|
18
19
|
load File.expand_path('../tasks/rspec.rake', __FILE__)
|
20
|
+
|
21
|
+
task :default => :spec
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Refinery
|
2
|
+
module AdminLocales
|
3
|
+
module Admin
|
4
|
+
class AdminLocalesController < ::Refinery::AdminController
|
5
|
+
|
6
|
+
crudify :'refinery/user',
|
7
|
+
:order => 'username ASC',
|
8
|
+
:title_attribute => 'username',
|
9
|
+
:xhr_paging => true
|
10
|
+
|
11
|
+
def update
|
12
|
+
locale = params[:user][:locale]
|
13
|
+
@user.locale = locale if params[:user][:locale]
|
14
|
+
if locale && @user.save
|
15
|
+
redirect_to refinery.admin_locales_admin_admin_locales_path,
|
16
|
+
:notice => t('updated', :what => @user.username, :scope => 'refinery.crudify')
|
17
|
+
else
|
18
|
+
render :edit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= form_for @user, :url => refinery.admin_locales_admin_admin_locale_path(@user), :method => :put do |f| %>
|
2
|
+
|
3
|
+
<%= render '/refinery/admin/error_messages', :object => @user, :include_object_name => true %>
|
4
|
+
|
5
|
+
<div class='field'>
|
6
|
+
<%= f.label :locale %>
|
7
|
+
<%= f.select :locale, options_for_select(Refinery::I18n.locales.map(&:reverse), @user.locale) %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
|
11
|
+
<%= render '/refinery/admin/form_actions', :f => f,
|
12
|
+
:continue_editing => false,
|
13
|
+
:hide_delete => true %>
|
14
|
+
<% end %>
|
File without changes
|
@@ -7,7 +7,7 @@
|
|
7
7
|
</span>
|
8
8
|
<span class='actions'>
|
9
9
|
<%= link_to refinery_icon_tag('application_edit.png'),
|
10
|
-
|
11
|
-
:title => t('
|
10
|
+
refinery.edit_admin_locales_admin_admin_locale_path(user),
|
11
|
+
:title => t('edit', :scope => 'refinery.admin.users') if current_refinery_user.can_edit?(user) %>
|
12
12
|
</span>
|
13
13
|
</li>
|
File without changes
|
data/config/locales/en.yml
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
en:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
admin:
|
6
|
-
admin_locales:
|
7
|
-
records:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
admin_locales:
|
8
5
|
title: User locales
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
admin_locales:
|
7
|
+
admin:
|
8
|
+
admin_locales:
|
9
|
+
records:
|
10
|
+
title: User locales
|
11
|
+
sorry_no_results: No results, sorry.
|
12
|
+
no_items_yet: There are not users yet
|
13
|
+
user:
|
14
|
+
default: Default
|
15
|
+
edit: Editar this locale
|
16
|
+
locale: Locale
|
15
17
|
activerecord:
|
16
18
|
attributes:
|
17
|
-
|
19
|
+
'refinery/admin_locales/admin_locale':
|
18
20
|
locale: Locale
|
data/config/locales/es.yml
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
es:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
admin:
|
6
|
-
admin_locales:
|
7
|
-
records:
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
admin_locales:
|
8
5
|
title: Idiomas de usuario
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
admin_locales:
|
7
|
+
admin:
|
8
|
+
admin_locales:
|
9
|
+
records:
|
10
|
+
title: Idiomas de usuario
|
11
|
+
sorry_no_results: Lo siento, no hay resultados
|
12
|
+
no_items_yet: No hay usuario todavía.
|
13
|
+
user:
|
14
|
+
default: Por defecto
|
15
|
+
edit: Editar este idioma
|
16
|
+
locale: Idioma
|
15
17
|
activerecord:
|
16
18
|
attributes:
|
17
|
-
|
19
|
+
'refinery/admin_locales/admin_locale':
|
18
20
|
locale: Idioma
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
Refinery::
|
2
|
-
|
3
|
-
|
1
|
+
Refinery::Core::Engine.routes.draw do
|
2
|
+
namespace :admin_locales, :path => '' do
|
3
|
+
namespace :admin, :path => 'refinery' do
|
4
|
+
root :to => "admin_locales#index"
|
5
|
+
resources :admin_locales, :only => [:index, :edit, :update]
|
6
|
+
end
|
4
7
|
end
|
5
8
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
class AddLocaleToUser < ActiveRecord::Migration
|
2
2
|
|
3
|
-
def
|
4
|
-
add_column :
|
5
|
-
|
6
|
-
load(Rails.root.join('db', 'seeds', 'refinerycms_admin_locales.rb').to_s)
|
3
|
+
def up
|
4
|
+
add_column :refinery_users, :locale, :string
|
7
5
|
end
|
8
6
|
|
9
|
-
def
|
10
|
-
remove_column :
|
7
|
+
def down
|
8
|
+
remove_column :refinery_users, :locale
|
11
9
|
end
|
12
10
|
|
13
11
|
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
if defined?(::Refinery::User)
|
2
|
+
::Refinery::User.all.each do |user|
|
3
|
+
if user.plugins.where(:name => 'refinerycms_admin_locales').blank?
|
4
|
+
user.plugins.create(:name => 'refinerycms_admin_locales',
|
5
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Refinery
|
2
|
+
class AdminLocalesGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
def rake_db
|
5
|
+
rake("refinery_admin_locales:install:migrations")
|
6
|
+
end
|
7
|
+
|
8
|
+
def append_load_seed_data
|
9
|
+
create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
|
10
|
+
append_file 'db/seeds.rb', :verbose => true do
|
11
|
+
<<-EOH
|
12
|
+
|
13
|
+
# Added by Refinery CMS Admin Locales extension
|
14
|
+
Refinery::AdminLocales::Engine.load_seed
|
15
|
+
EOH
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'refinerycms-core'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
autoload :AdminLocalesGenerator, 'generators/refinery/admin_locales_generator'
|
5
|
+
|
6
|
+
module AdminLocales
|
7
|
+
require 'refinery/admin_locales/engine'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :root
|
11
|
+
|
12
|
+
def root
|
13
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def factory_paths
|
17
|
+
@factory_paths ||= [ root.join('spec', 'factories').to_s ]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Refinery
|
2
|
+
module AdminLocales
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
include Refinery::Engine
|
5
|
+
isolate_namespace Refinery::AdminLocales
|
6
|
+
|
7
|
+
engine_name :refinery_admin_locales
|
8
|
+
|
9
|
+
initializer "register refinerycms_admin_locales plugin" do
|
10
|
+
Refinery::Plugin.register do |plugin|
|
11
|
+
plugin.name = "admin_locales"
|
12
|
+
plugin.pathname = root
|
13
|
+
plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.admin_locales_admin_admin_locales_path }
|
14
|
+
plugin.menu_match = /refinery\/admin_locales/
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
Refinery.register_engine(Refinery::AdminLocales)
|
20
|
+
|
21
|
+
::Refinery::AdminController.class_eval do
|
22
|
+
def find_or_set_locale_with_default
|
23
|
+
if current_refinery_user && current_refinery_user.locale
|
24
|
+
::Refinery::I18n.current_locale = current_refinery_user.locale
|
25
|
+
::I18n.locale = ::Refinery::I18n.current_locale
|
26
|
+
else
|
27
|
+
find_or_set_locale_without_default
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method_chain :find_or_set_locale, :default
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module Refinery
|
2
2
|
module AdminLocales
|
3
3
|
class Version
|
4
|
-
@major =
|
4
|
+
@major = 2
|
5
5
|
@minor = 0
|
6
|
-
@tiny =
|
6
|
+
@tiny = 0
|
7
|
+
@build = nil
|
7
8
|
|
8
9
|
class << self
|
9
|
-
attr_reader :major, :minor, :tiny
|
10
|
+
attr_reader :major, :minor, :tiny, :build
|
10
11
|
|
11
12
|
def to_s
|
12
|
-
[@major, @minor, @tiny].compact.join('.')
|
13
|
+
[@major, @minor, @tiny, @build].compact.join('.')
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -1,44 +1 @@
|
|
1
|
-
require 'refinery'
|
2
|
-
|
3
|
-
module Refinery
|
4
|
-
module AdminLocales
|
5
|
-
class << self
|
6
|
-
attr_accessor :root
|
7
|
-
|
8
|
-
def root
|
9
|
-
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
10
|
-
end
|
11
|
-
|
12
|
-
def version
|
13
|
-
::Refinery::AdminLocales::Version.to_s
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Engine < Rails::Engine
|
18
|
-
|
19
|
-
config.after_initialize do
|
20
|
-
Refinery::Plugin.register do |plugin|
|
21
|
-
plugin.name = "refinerycms_admin_locales"
|
22
|
-
plugin.pathname = root
|
23
|
-
plugin.url = { :controller => '/admin/admin_locales', :action => 'index' }
|
24
|
-
plugin.menu_match = /(admin|refinery)\/admin_locales$/
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
config.to_prepare do
|
29
|
-
::Admin::BaseController.class_eval do
|
30
|
-
def find_or_set_locale_with_default
|
31
|
-
if current_user && current_user.locale
|
32
|
-
::Refinery::I18n.current_locale = current_user.locale
|
33
|
-
::I18n.locale = ::Refinery::I18n.current_locale
|
34
|
-
else
|
35
|
-
find_or_set_locale_without_default
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
alias_method_chain :find_or_set_locale, :default
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require 'refinery/admin_locales'
|
data/readme.md
CHANGED
@@ -14,15 +14,23 @@ users who need different locales at the same time.
|
|
14
14
|
|
15
15
|
## How to add this extension to your project
|
16
16
|
|
17
|
-
### Refinery
|
17
|
+
### Refinery edge:
|
18
18
|
|
19
19
|
#### Add gem to Gemfile
|
20
|
-
gem
|
20
|
+
gem 'refinerycms-admin-locales', 'git: git://github.com/simplelogica/refinerycms-admin-locales.git'
|
21
21
|
|
22
22
|
#### Install extension
|
23
23
|
rake refinery_admin_locales:install:migrations
|
24
24
|
rake db:migrate
|
25
25
|
|
26
|
+
### Refinery 2.0.*:
|
27
|
+
|
28
|
+
#### Add gem to Gemfile
|
29
|
+
gem 'refinerycms-admin-locales', "~> 2.0.0"
|
30
|
+
|
31
|
+
#### Install extension
|
32
|
+
rake refinery_admin_locales:install:migrations
|
33
|
+
rake db:migrate
|
26
34
|
|
27
35
|
### Refinery 1:
|
28
36
|
|
@@ -33,4 +41,4 @@ users who need different locales at the same time.
|
|
33
41
|
rails generate refinerycms_admin_locales
|
34
42
|
rake db:migrate
|
35
43
|
|
36
|
-
**WARNING: Refinary 1 version, is not
|
44
|
+
**WARNING: Refinary 1 version, is not tested, but it should works**
|
@@ -11,16 +11,16 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = %q{Manage locale for each user in the refinerycms admin.}
|
12
12
|
s.summary = %q{Admin Locales extension for Refinery CMS.}
|
13
13
|
s.email = %q{ruben@simplelogica.net}
|
14
|
+
s.homepage = %q{http://simplelogica.net}
|
14
15
|
s.authors = ['Simplelógica','Rubén Sierra']
|
15
|
-
s.homepage = %q{http://simplelogica.net/}
|
16
16
|
s.require_paths = %w(lib)
|
17
17
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
20
20
|
|
21
21
|
# Runtime dependencies
|
22
|
-
s.add_dependency 'refinerycms-core', '~>
|
22
|
+
s.add_dependency 'refinerycms-core', '~> 2.0.0'
|
23
23
|
|
24
24
|
# Development dependencies (usually used for testing)
|
25
|
-
s.add_development_dependency 'refinerycms-testing'
|
25
|
+
s.add_development_dependency 'refinerycms-testing'
|
26
26
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
module Refinery
|
5
|
+
module AdminLocales
|
6
|
+
module Admin
|
7
|
+
describe AdminLocalesController do
|
8
|
+
render_views
|
9
|
+
refinery_login_with_factory :refinery_user
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
Refinery::User.first.update_attribute(:locale, locale)
|
13
|
+
get :index
|
14
|
+
end
|
15
|
+
|
16
|
+
context "without locale" do
|
17
|
+
let(:locale) { nil }
|
18
|
+
|
19
|
+
it { response.should be_success }
|
20
|
+
it { response.should render_template(:index) }
|
21
|
+
it { response.body.should match("Switch to your website") }
|
22
|
+
it { ::I18n.locale.should eq ::Refinery::I18n.current_locale }
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with en locale" do
|
26
|
+
let(:locale) { :en }
|
27
|
+
|
28
|
+
it { response.should be_success }
|
29
|
+
it { response.should render_template(:index) }
|
30
|
+
it { response.body.should match("Switch to your website") }
|
31
|
+
it { ::Refinery::I18n.current_locale.should eq "en" }
|
32
|
+
it { ::I18n.locale.should eq :en }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with en locale" do
|
36
|
+
let(:locale) { :es }
|
37
|
+
|
38
|
+
it { response.should be_success }
|
39
|
+
it { response.should render_template(:index) }
|
40
|
+
it { response.body.should match("Ver tu web") }
|
41
|
+
it { ::Refinery::I18n.current_locale.should eq "es" }
|
42
|
+
it { ::I18n.locale.should eq :es }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :user_with_locale, :class => Refinery::User do
|
3
|
+
sequence(:username) { |n| "refinery_with_locale#{n}" }
|
4
|
+
sequence(:email) { |n| "refinery_with_locale#{n}@refinerycms.com" }
|
5
|
+
password "refinerycms"
|
6
|
+
password_confirmation "refinerycms"
|
7
|
+
locale :en
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
@@ -1,101 +1,86 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
visit refinery.admin_locales_admin_admin_locales_path
|
18
|
-
page.should have_content("UniqueTitleOne")
|
19
|
-
page.should have_content("UniqueTitleTwo")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "create" do
|
24
|
-
before(:each) do
|
25
|
-
visit refinery.admin_locales_admin_admin_locales_path
|
26
|
-
|
27
|
-
click_link "Add New Admin Locale"
|
28
|
-
end
|
29
|
-
|
30
|
-
context "valid data" do
|
31
|
-
it "should succeed" do
|
32
|
-
fill_in "Locale", :with => "This is a test of the first string field"
|
33
|
-
click_button "Save"
|
34
|
-
|
35
|
-
page.should have_content("'This is a test of the first string field' was successfully added.")
|
36
|
-
Refinery::AdminLocales::AdminLocale.count.should == 1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "invalid data" do
|
41
|
-
it "should fail" do
|
42
|
-
click_button "Save"
|
43
|
-
|
44
|
-
page.should have_content("Locale can't be blank")
|
45
|
-
Refinery::AdminLocales::AdminLocale.count.should == 0
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "duplicate" do
|
50
|
-
before(:each) { FactoryGirl.create(:admin_locale, :locale => "UniqueTitle") }
|
51
|
-
|
52
|
-
it "should fail" do
|
53
|
-
visit refinery.admin_locales_admin_admin_locales_path
|
54
|
-
|
55
|
-
click_link "Add New Admin Locale"
|
4
|
+
describe "admin_locales" do
|
5
|
+
refinery_login_with :refinery_user
|
6
|
+
|
7
|
+
let(:locale) { 'en' }
|
8
|
+
let(:another_locale) { 'es' }
|
9
|
+
let(:user) { Refinery::User.first }
|
10
|
+
let(:user_with_another_locale) { FactoryGirl.create(:user_with_locale, :locale => another_locale) }
|
11
|
+
let(:user_without_locale) { FactoryGirl.create(:user) }
|
12
|
+
before(:each) do
|
13
|
+
user.update_attribute(:locale, locale)
|
14
|
+
user_with_another_locale
|
15
|
+
user_without_locale
|
16
|
+
end
|
56
17
|
|
57
|
-
|
58
|
-
|
18
|
+
context "list" do
|
19
|
+
before { visit refinery.admin_locales_admin_admin_locales_path }
|
59
20
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
21
|
+
it "shows user with locale username" do
|
22
|
+
page.should have_xpath("//span[@class='title']//strong", :text => user.username)
|
23
|
+
end
|
64
24
|
|
65
|
-
|
25
|
+
it "shows user with locale locale" do
|
26
|
+
page.should have_xpath("//span[@class='title']//span[@class='preview']", :text => Refinery::I18n.locales[locale.to_sym])
|
27
|
+
end
|
66
28
|
|
67
|
-
|
68
|
-
|
29
|
+
it "shows user with another locale username" do
|
30
|
+
page.should have_xpath("//span[@class='title']//strong", :text => user_with_another_locale.username)
|
31
|
+
end
|
69
32
|
|
70
|
-
|
71
|
-
|
33
|
+
it "shows user with another locale locale" do
|
34
|
+
page.should have_xpath("//span[@class='title']//span[@class='preview']", :text => Refinery::I18n.locales[another_locale.to_sym])
|
35
|
+
end
|
72
36
|
|
73
|
-
|
74
|
-
|
75
|
-
|
37
|
+
it "shows user without locale username" do
|
38
|
+
page.should have_xpath("//span[@class='title']//strong", :text => user_without_locale.username)
|
39
|
+
end
|
76
40
|
|
77
|
-
|
78
|
-
|
41
|
+
it "shows user with another locale locale" do
|
42
|
+
page.should have_xpath("//span[@class='title']//span[@class='preview']", :text => I18n.t('refinery.admin_locales.admin.admin_locales.user.default'))
|
43
|
+
end
|
44
|
+
end
|
79
45
|
|
80
|
-
|
81
|
-
page.should have_no_content("A locale")
|
82
|
-
end
|
83
|
-
end
|
46
|
+
describe "edit an user" do
|
84
47
|
|
85
|
-
|
86
|
-
|
48
|
+
it "with locale shows a select with the locale selected" do
|
49
|
+
visit refinery.edit_admin_locales_admin_admin_locale_path(user)
|
50
|
+
page.should have_xpath("//div[@class='field']//option[@selected='selected' and @value='#{locale}']")
|
51
|
+
end
|
87
52
|
|
88
|
-
|
89
|
-
|
53
|
+
it "with another locale shows a select with the locale selected" do
|
54
|
+
visit refinery.edit_admin_locales_admin_admin_locale_path(user_with_another_locale)
|
55
|
+
page.should have_xpath("//div[@class='field']//option[@selected='selected' and @value='#{another_locale}']")
|
56
|
+
end
|
90
57
|
|
91
|
-
|
58
|
+
it "without locale shows a select without locale selected" do
|
59
|
+
visit refinery.edit_admin_locales_admin_admin_locale_path(user_without_locale)
|
60
|
+
page.should_not have_xpath("//div[@class='field']//option[@selected='selected']")
|
61
|
+
end
|
92
62
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
63
|
+
context "and change locale" do
|
64
|
+
it "should render user list successfully" do
|
65
|
+
visit refinery.edit_admin_locales_admin_admin_locale_path(user)
|
66
|
+
select(Refinery::I18n.locales[another_locale.to_sym], :from => 'user_locale')
|
67
|
+
click_button 'submit_button'
|
68
|
+
# Flash message should be in previous locale, because locale is set acter the flash
|
69
|
+
page.should have_content("#{user.username} was successfully updated.")
|
70
|
+
# But content should be in new locale
|
71
|
+
page.should have_xpath("//span[@class='title']//span[@class='preview']", :text => 'Idioma: Español')
|
72
|
+
end
|
97
73
|
|
74
|
+
it "should change user locale" do
|
75
|
+
visit refinery.edit_admin_locales_admin_admin_locale_path(user)
|
76
|
+
expect{
|
77
|
+
select(Refinery::I18n.locales[another_locale.to_sym], :from => 'user_locale')
|
78
|
+
click_button 'submit_button'
|
79
|
+
user.reload
|
80
|
+
}.to change(user,:locale).from(locale).to(another_locale)
|
98
81
|
end
|
99
82
|
end
|
83
|
+
|
84
|
+
|
100
85
|
end
|
101
86
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,17 +2,11 @@ def setup_environment
|
|
2
2
|
# Configure Rails Environment
|
3
3
|
ENV["RAILS_ENV"] ||= 'test'
|
4
4
|
|
5
|
-
|
6
|
-
require dummy_path
|
7
|
-
elsif File.dirname(__FILE__) =~ %r{vendor/extensions}
|
8
|
-
# Require the path to the refinerycms application this is vendored inside.
|
9
|
-
require File.expand_path('../../../../../config/environment', __FILE__)
|
10
|
-
else
|
11
|
-
raise "Could not find a config/environment.rb file to require. Please specify this in spec/spec_helper.rb"
|
12
|
-
end
|
5
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
13
6
|
|
14
7
|
require 'rspec/rails'
|
15
8
|
require 'capybara/rspec'
|
9
|
+
require 'factory_girl_rails'
|
16
10
|
|
17
11
|
Rails.backtrace_cleaner.remove_silencers!
|
18
12
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-admin-locales
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,30 +10,40 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: refinerycms-core
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 2.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.0.0
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: refinerycms-testing
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
|
-
- -
|
36
|
+
- - ! '>='
|
32
37
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
38
|
+
version: '0'
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
37
47
|
description: Manage locale for each user in the refinerycms admin.
|
38
48
|
email: ruben@simplelogica.net
|
39
49
|
executables: []
|
@@ -41,32 +51,38 @@ extensions: []
|
|
41
51
|
extra_rdoc_files: []
|
42
52
|
files:
|
43
53
|
- .gitignore
|
54
|
+
- .rspec
|
44
55
|
- Gemfile
|
56
|
+
- Gemfile.lock
|
45
57
|
- Rakefile
|
46
|
-
- app/controllers/admin/admin_locales_controller.rb
|
47
|
-
- app/views/admin/admin_locales/_form.html.erb
|
48
|
-
- app/views/admin/admin_locales/_records.html.erb
|
49
|
-
- app/views/admin/admin_locales/_user.html.erb
|
50
|
-
- app/views/admin/admin_locales/_users.html.erb
|
51
|
-
- app/views/admin/admin_locales/edit.html.erb
|
52
|
-
- app/views/admin/admin_locales/index.html.erb
|
58
|
+
- app/controllers/refinery/admin_locales/admin/admin_locales_controller.rb
|
59
|
+
- app/views/refinery/admin_locales/admin/admin_locales/_form.html.erb
|
60
|
+
- app/views/refinery/admin_locales/admin/admin_locales/_records.html.erb
|
61
|
+
- app/views/refinery/admin_locales/admin/admin_locales/_user.html.erb
|
62
|
+
- app/views/refinery/admin_locales/admin/admin_locales/_users.html.erb
|
63
|
+
- app/views/refinery/admin_locales/admin/admin_locales/edit.html.erb
|
64
|
+
- app/views/refinery/admin_locales/admin/admin_locales/index.html.erb
|
53
65
|
- config/locales/en.yml
|
54
66
|
- config/locales/es.yml
|
55
67
|
- config/routes.rb
|
56
68
|
- db/migrate/1_add_locale_to_user.rb
|
57
|
-
- db/seeds
|
58
|
-
- lib/generators/
|
69
|
+
- db/seeds.rb
|
70
|
+
- lib/generators/refinery/admin_locales_generator.rb
|
71
|
+
- lib/refinery/admin_locales.rb
|
72
|
+
- lib/refinery/admin_locales/engine.rb
|
59
73
|
- lib/refinery/admin_locales/version.rb
|
60
74
|
- lib/refinerycms-admin-locales.rb
|
75
|
+
- lib/tasks/refinery/admin_locales.rake
|
61
76
|
- readme.md
|
62
77
|
- refinerycms-admin-locales.gemspec
|
63
78
|
- script/rails
|
79
|
+
- spec/controllers/refinery/admin_locales/admin/admin_locales_spec.rb
|
80
|
+
- spec/factories/refinery/admin_locales.rb
|
64
81
|
- spec/requests/refinery/admin_locales/admin/admin_locales_spec.rb
|
65
82
|
- spec/spec_helper.rb
|
66
|
-
- spec/support/factories/refinery/admin_locales.rb
|
67
83
|
- tasks/rspec.rake
|
68
84
|
- tasks/testing.rake
|
69
|
-
homepage: http://simplelogica.net
|
85
|
+
homepage: http://simplelogica.net
|
70
86
|
licenses: []
|
71
87
|
post_install_message:
|
72
88
|
rdoc_options: []
|
@@ -86,11 +102,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
102
|
version: '0'
|
87
103
|
requirements: []
|
88
104
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.8.
|
105
|
+
rubygems_version: 1.8.25
|
90
106
|
signing_key:
|
91
107
|
specification_version: 3
|
92
108
|
summary: Admin Locales extension for Refinery CMS.
|
93
109
|
test_files:
|
110
|
+
- spec/controllers/refinery/admin_locales/admin/admin_locales_spec.rb
|
111
|
+
- spec/factories/refinery/admin_locales.rb
|
94
112
|
- spec/requests/refinery/admin_locales/admin/admin_locales_spec.rb
|
95
113
|
- spec/spec_helper.rb
|
96
|
-
- spec/support/factories/refinery/admin_locales.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Admin
|
2
|
-
class AdminLocalesController < Admin::BaseController
|
3
|
-
|
4
|
-
crudify :user,
|
5
|
-
:order => 'username ASC',
|
6
|
-
:title_attribute => :username,
|
7
|
-
:xhr_paging => true
|
8
|
-
|
9
|
-
def update
|
10
|
-
locale = params[:user][:locale]
|
11
|
-
@user.locale = locale if params[:user][:locale]
|
12
|
-
if locale && @user.save
|
13
|
-
redirect_to admin_admin_locales_path,
|
14
|
-
:notice => t('updated', :what => @user.username, :scope => 'refinery.crudify')
|
15
|
-
else
|
16
|
-
render :edit
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<%= form_for @user, :url => admin_admin_locale_path(@user), :method => :put do |f| %>
|
2
|
-
|
3
|
-
<%= render :partial => "/shared/admin/error_messages",
|
4
|
-
:locals => {
|
5
|
-
:object => @user,
|
6
|
-
:include_object_name => true
|
7
|
-
} %>
|
8
|
-
|
9
|
-
<div class='field'>
|
10
|
-
<%= f.label :locale %>
|
11
|
-
<%= f.select :locale, options_for_select(Refinery::I18n.locales.map(&:reverse), @user.locale) %>
|
12
|
-
</div>
|
13
|
-
|
14
|
-
<%= render :partial => "/shared/admin/form_actions",
|
15
|
-
:locals => {
|
16
|
-
:f => f,
|
17
|
-
:continue_editing => false,
|
18
|
-
:hide_delete => true
|
19
|
-
} %>
|
20
|
-
<% end %>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
|
2
|
-
FactoryGirl.define do
|
3
|
-
factory :user, :class => Refinery::User do
|
4
|
-
sequence(:username) { |n| "refinery#{n}" }
|
5
|
-
sequence(:email) { |n| "refinery#{n}@refinerycms.com" }
|
6
|
-
password "refinerycms"
|
7
|
-
password_confirmation "refinerycms"
|
8
|
-
locale :en
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|