padrino-admin 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/.document +3 -3
  2. data/.yardopts +1 -0
  3. data/{LICENSE → LICENSE.txt} +0 -0
  4. data/lib/padrino-admin/access_control.rb +34 -2
  5. data/lib/padrino-admin/generators/admin_app.rb +10 -11
  6. data/lib/padrino-admin/generators/templates/app.rb.tt +11 -11
  7. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +8 -8
  8. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +5 -5
  9. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +5 -5
  10. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +9 -9
  11. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +1 -1
  12. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +9 -9
  13. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +8 -8
  14. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/orange/style.css +7 -7
  15. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +27 -27
  16. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +9 -9
  17. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +3 -3
  18. data/lib/padrino-admin/helpers/authentication_helpers.rb +1 -2
  19. data/lib/padrino-admin/helpers/view_helpers.rb +23 -6
  20. data/lib/padrino-admin/locale/admin/lv.yml +16 -0
  21. data/lib/padrino-admin/locale/admin/zh_cn.yml +3 -3
  22. data/lib/padrino-admin/locale/orm/lv.yml +26 -0
  23. data/test/generators/test_account_model_generator.rb +9 -9
  24. data/test/generators/test_admin_app_generator.rb +24 -23
  25. data/test/generators/test_admin_page_generator.rb +24 -24
  26. data/test/helper.rb +6 -19
  27. data/test/test_admin_application.rb +1 -1
  28. data/test/test_locale.rb +1 -1
  29. metadata +14 -11
@@ -12,7 +12,7 @@ body {
12
12
  }
13
13
 
14
14
  hr {
15
- background: #f0f0ee;
15
+ background: #f0f0ee;
16
16
  color: #f0f0ee;
17
17
  }
18
18
 
@@ -43,7 +43,7 @@ hr {
43
43
  background: #FFF;
44
44
  }
45
45
 
46
- #sidebar h3 {
46
+ #sidebar h3 {
47
47
  background: #ff7900;
48
48
  color: #FFF;
49
49
  border-bottom: 10px solid #262626;
@@ -118,7 +118,7 @@ hr {
118
118
  background-color: #262626;
119
119
  }
120
120
 
121
- #footer .block {
121
+ #footer .block {
122
122
  color: #FFF;
123
123
  background: #262626;
124
124
  }
@@ -221,24 +221,24 @@ ul.list li .item .avatar {
221
221
  border-color: #F0F0EE;
222
222
  border-width: 1px;
223
223
  border-style: solid;
224
- padding: 2px;
224
+ padding: 2px;
225
225
  }
226
226
 
227
227
  /* box */
228
228
 
229
229
  #box .block {
230
- background: #FFF;
230
+ background: #FFF;
231
231
  }
232
232
 
233
233
  #box .block h2 {
234
- background: #ff7900;
234
+ background: #ff7900;
235
235
  color: #FFF;
236
236
  }
237
237
 
238
238
 
239
239
  /* rounded borders */
240
240
 
241
- #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li,
241
+ #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li,
242
242
  #footer .block, .form input.button, #box .block, #box .block h2 {
243
243
  -moz-border-radius-topleft: 4px;
244
244
  -webkit-border-top-left-radius: 4px;
@@ -2,7 +2,7 @@
2
2
  .gray { color:#a2b0b6; }
3
3
  .hightlight { background-color:#d6e7c7; }
4
4
 
5
- a:link, a:visited, a:hover, a:active { color: #81B953; }
5
+ a:link, a:visited, a:hover, a:active { color: #81B953; }
6
6
  h1, h2, h3 { color: #3B5526; }
7
7
  a { -moz-outline: none; }
8
8
 
@@ -13,7 +13,7 @@ body {
13
13
  }
14
14
 
15
15
  hr {
16
- background: #f0f0ee;
16
+ background: #f0f0ee;
17
17
  color: #f0f0ee;
18
18
  }
19
19
 
@@ -28,7 +28,7 @@ hr {
28
28
 
29
29
  }
30
30
 
31
- #header h1 a:link, #header h1 a:active,
31
+ #header h1 a:link, #header h1 a:active,
32
32
  #header h1 a:hover, #header h1 a:visited {
33
33
  color: #3B5526;
34
34
  }
@@ -49,7 +49,7 @@ hr {
49
49
  border: none;
50
50
  }
51
51
 
52
- #sidebar h3 {
52
+ #sidebar h3 {
53
53
  padding: 8px 12px;
54
54
  background: #3B5526;
55
55
  color: #FFF;
@@ -58,14 +58,14 @@ hr {
58
58
  }
59
59
 
60
60
 
61
- #sidebar ul li a:link,
61
+ #sidebar ul li a:link,
62
62
  #sidebar ul li a:visited {
63
63
  background: #FFF;
64
64
  border-bottom: 1px solid #F0F0EE;
65
65
  text-decoration: none;
66
66
  }
67
67
 
68
- #sidebar ul li a:hover,
68
+ #sidebar ul li a:hover,
69
69
  #sidebar ul li a:active {
70
70
  background: #D3E8C1;
71
71
  color: #FFF;
@@ -74,7 +74,7 @@ hr {
74
74
  #main-navigation {
75
75
  background: #44721e;
76
76
  margin-right: 20px;
77
- padding: 7px 7px 0 7px;
77
+ padding: 7px 7px 0 7px;
78
78
  }
79
79
 
80
80
  #main-navigation ul li {
@@ -94,26 +94,26 @@ hr {
94
94
  }
95
95
 
96
96
  #main-navigation ul li a:hover,
97
- #main-navigation ul li a:link,
98
- #main-navigation ul li a:visited,
97
+ #main-navigation ul li a:link,
98
+ #main-navigation ul li a:visited,
99
99
  #main-navigation ul li a:active,
100
- .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited,
100
+ .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited,
101
101
  .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active {
102
102
  text-decoration: none;
103
103
  color: #FFF;
104
104
  }
105
105
 
106
- #user-navigation ul li a:link,
107
- #user-navigation ul li a:visited,
106
+ #user-navigation ul li a:link,
107
+ #user-navigation ul li a:visited,
108
108
  #user-navigation ul li a:active {
109
109
  color: #3B5526;
110
110
  }
111
111
 
112
112
  #user-navigation ul li a:hover { color: #fff; }
113
113
 
114
- #main-navigation ul li.active a:link,
115
- #main-navigation ul li.active a:visited,
116
- #main-navigation ul li.active a:hover,
114
+ #main-navigation ul li.active a:link,
115
+ #main-navigation ul li.active a:visited,
116
+ #main-navigation ul li.active a:hover,
117
117
  #main-navigation ul li.active a:active {
118
118
  color: #262626;
119
119
  }
@@ -137,13 +137,13 @@ padding: 8px 12px;
137
137
  background: #81B953;
138
138
  }
139
139
 
140
- #footer .block {
140
+ #footer .block {
141
141
  color: #FFF;
142
142
  background: #3B5526;
143
143
  }
144
144
 
145
- #footer .block p {
146
- margin: 0;
145
+ #footer .block p {
146
+ margin: 0;
147
147
  padding: 5px;
148
148
  }
149
149
 
@@ -241,13 +241,13 @@ ul.list li .item .avatar {
241
241
  border-color: #F0F0EE;
242
242
  border-width: 1px;
243
243
  border-style: solid;
244
- padding: 2px;
244
+ padding: 2px;
245
245
  }
246
246
 
247
247
  /* box */
248
248
 
249
249
  #box .block {
250
- background: #FFF;
250
+ background: #FFF;
251
251
  }
252
252
 
253
253
  #box .block h2 {
@@ -265,9 +265,9 @@ ul.list li .item .avatar {
265
265
 
266
266
  /* rounded borders */
267
267
 
268
- #main, #main-navigation, #main-navigation li,
269
- .secondary-navigation, #main .block, #sidebar .block,
270
- #sidebar h3, ul.list li, #footer .block,
268
+ #main, #main-navigation, #main-navigation li,
269
+ .secondary-navigation, #main .block, #sidebar .block,
270
+ #sidebar h3, ul.list li, #footer .block,
271
271
  .form input.button, #box .block, #box .block h2 {
272
272
  -moz-border-radius-topleft: 4px;
273
273
  -webkit-border-top-left-radius: 4px;
@@ -275,8 +275,8 @@ ul.list li .item .avatar {
275
275
  -webkit-border-top-right-radius: 4px;
276
276
  }
277
277
 
278
- .secondary-navigation li.first a,
279
- .secondary-navigation ul li.first,
278
+ .secondary-navigation li.first a,
279
+ .secondary-navigation ul li.first,
280
280
  .table th.first, .table th.first {
281
281
  -moz-border-radius-topleft: 4px;
282
282
  -webkit-border-top-left-radius: 4px;
@@ -292,8 +292,8 @@ ul.list li .item .avatar {
292
292
  -webkit-border-top-left-radius: 4px;
293
293
  }
294
294
 
295
- #sidebar, #sidebar .block, #main .block,
296
- #sidebar ul.navigation, ul.list li,
295
+ #sidebar, #sidebar .block, #main .block,
296
+ #sidebar ul.navigation, ul.list li,
297
297
  #footer .block, .form input.button, #box .block {
298
298
  -moz-border-radius-bottomleft: 4px;
299
299
  -webkit-border-bottom-left-radius: 4px;
@@ -12,7 +12,7 @@ body {
12
12
  }
13
13
 
14
14
  hr {
15
- background: #f0f0ee;
15
+ background: #f0f0ee;
16
16
  color: #f0f0ee;
17
17
  }
18
18
 
@@ -47,7 +47,7 @@ hr {
47
47
  background: #FFF;
48
48
  }
49
49
 
50
- #sidebar h3 {
50
+ #sidebar h3 {
51
51
  background: #7A1818;
52
52
  color: #FFF;
53
53
  border-bottom: 10px solid #262626;
@@ -129,13 +129,13 @@ hr {
129
129
  background-color: #262626;
130
130
  }
131
131
 
132
- #footer .block {
132
+ #footer .block {
133
133
  color: #FFF;
134
134
  background: #262626;
135
135
  }
136
136
 
137
- #footer .block p {
138
- margin: 0;
137
+ #footer .block p {
138
+ margin: 0;
139
139
  padding: 10px;
140
140
  }
141
141
 
@@ -233,24 +233,24 @@ ul.list li .item .avatar {
233
233
  border-color: #F0F0EE;
234
234
  border-width: 1px;
235
235
  border-style: solid;
236
- padding: 2px;
236
+ padding: 2px;
237
237
  }
238
238
 
239
239
  /* box */
240
240
 
241
241
  #box .block {
242
- background: #FFF;
242
+ background: #FFF;
243
243
  }
244
244
 
245
245
  #box .block h2 {
246
- background: #7A1818;
246
+ background: #7A1818;
247
247
  color: #FFF;
248
248
  }
249
249
 
250
250
 
251
251
  /* rounded borders */
252
252
 
253
- #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li,
253
+ #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li,
254
254
  #footer .block, .form input.button, #box .block, #box .block h2 {
255
255
  -moz-border-radius-topleft: 4px;
256
256
  -webkit-border-top-left-radius: 4px;
@@ -9,7 +9,7 @@ body {
9
9
  }
10
10
 
11
11
  hr {
12
- background: #aaa;
12
+ background: #aaa;
13
13
  }
14
14
 
15
15
  p {
@@ -118,7 +118,7 @@ input.check_box {
118
118
  }
119
119
 
120
120
 
121
- #sidebar h3 {
121
+ #sidebar h3 {
122
122
  background: #fff;
123
123
  border-bottom:1px solid #ccc;
124
124
  border-right:1px solid #ccc;
@@ -384,7 +384,7 @@ ul.list li .left {
384
384
  }
385
385
 
386
386
  #box .block h2 {
387
- background: #576C82;
387
+ background: #576C82;
388
388
  color: #FFF;
389
389
  border-top-left-radius: 5px;
390
390
  border-top-right-radius: 5px;
@@ -19,8 +19,7 @@ module Padrino
19
19
  ##
20
20
  # Override the current_account, you must provide an instance of Account Model
21
21
  #
22
- # ==== Examples:
23
- #
22
+ # @example
24
23
  # set_current_account(Account.authenticate(params[:email], params[:password])
25
24
  #
26
25
  def set_current_account(account=nil)
@@ -3,10 +3,16 @@ module Padrino
3
3
  module Helpers
4
4
  module ViewHelpers
5
5
  ##
6
- # Translate a given word for padrino admin
6
+ # Translates a given word for padrino admin
7
7
  #
8
- # ==== Examples
8
+ # @param [String] word
9
+ # The specified word to admin translate.
10
+ # @param [String] default
11
+ # The default fallback if no word is available for the locale.
9
12
  #
13
+ # @return [String] The translated word for the current locale.
14
+ #
15
+ # @example
10
16
  # # => t("padrino.admin.profile", :default => "Profile")
11
17
  # pat(:profile)
12
18
  #
@@ -19,10 +25,16 @@ module Padrino
19
25
  alias :pat :padrino_admin_translate
20
26
 
21
27
  ##
22
- # Translate attribute name for the given model
28
+ # Translates attribute name for the given model.
29
+ #
30
+ # @param [Symbol] model
31
+ # The model name for the translation.
32
+ # @param [Symbol] attribute
33
+ # The attribute name in the model to translate.
23
34
  #
24
- # ==== Examples
35
+ # @return [String] The translated attribute name for the current locale.
25
36
  #
37
+ # @example
26
38
  # # => t("models.account.email", :default => "Email")
27
39
  # mat(:account, :email)
28
40
  #
@@ -32,10 +44,14 @@ module Padrino
32
44
  alias :mat :model_attribute_translate
33
45
 
34
46
  ##
35
- # Translate model name
47
+ # Translates model name
36
48
  #
37
- # ==== Examples
49
+ # @param [Symbol] attribute
50
+ # The attribute name in the model to translate.
38
51
  #
52
+ # @return [String] The translated model name for the current locale.
53
+ #
54
+ # @example
39
55
  # # => t("models.account.name", :default => "Account")
40
56
  # mt(:account)
41
57
  #
@@ -43,6 +59,7 @@ module Padrino
43
59
  t("models.#{model}.name", :default => model.to_s.humanize)
44
60
  end
45
61
  alias :mt :model_translate
62
+
46
63
  end # ViewHelpers
47
64
  end # Helpers
48
65
  end # Admin
@@ -0,0 +1,16 @@
1
+ lv:
2
+ padrino:
3
+ admin:
4
+ save: Saglabāt
5
+ cancel: Atcelt
6
+ list: Saraksts
7
+ edit: Labot
8
+ new: Jauns
9
+ show: Parādīt
10
+ delete: Dzēst
11
+ confirm: Vai esat pārliecināts?
12
+ created_at: Izveidots
13
+ all: Viss
14
+ profile: Profils
15
+ settings: Uzstādījumi
16
+ logout: Iziet
@@ -1,6 +1,6 @@
1
- zh_cn:
2
- padrino:
3
- admin:
1
+ zh_cn:
2
+ padrino:
3
+ admin:
4
4
  save: 储存
5
5
  cancel: 取消
6
6
  list: 列表
@@ -0,0 +1,26 @@
1
+ lv:
2
+ activemodel: &activemodel
3
+ errors:
4
+ messages:
5
+ inclusion: "nav iekļauts sarakstā"
6
+ exclusion: "nav pieejams"
7
+ invalid: "nav derīgs"
8
+ confirmation: "nesakrīt ar apstiprinājumu"
9
+ accepted: "ir jāpiekrīt"
10
+ empty: "ir jābūt aizpildītam"
11
+ blank: "ir jābūt aizpildītam"
12
+ too_long: "ir par garu (maksimums ir %{count} zīmes)"
13
+ too_short: "ir par īsu (minimums ir %{count} zīmes)"
14
+ wrong_length: "ir nepareizs garums (jābūt %{count} zīmēm)"
15
+ taken: "ir jau aizņemts"
16
+ not_a_number: "nav skaitlis"
17
+ greater_than: "ir jābūt lielākam par %{count}"
18
+ greater_than_or_equal_to: "ir jābūt lielākam vai vienādam ar %{count}"
19
+ equal_to: "ir jābūt vienādam ar %{count}"
20
+ less_than: "ir jābūt mazākam par %{count}"
21
+ less_than_or_equal_to: "ir jābūt mazākam vai vienādam ar %{count}"
22
+ odd: "ir jābūt nepāra skaitlim"
23
+ even: "ir jābūt pāra skaitlim"
24
+ record_invalid: "Pārbaude neizdevās: %{errors}"
25
+ content_type: "faila formāts netiek atblastīts"
26
+ activerecord: *activemodel
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../helper')
2
2
 
3
- class TestAccountModelGenerator < Test::Unit::TestCase
3
+ describe "AccountModelGenerator" do
4
4
  def setup
5
5
  @apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
6
6
  `mkdir -p #{@apptmp}`
@@ -9,28 +9,28 @@ class TestAccountModelGenerator < Test::Unit::TestCase
9
9
  def teardown
10
10
  `rm -rf #{@apptmp}`
11
11
  end
12
-
12
+
13
13
  # COUCHREST
14
14
  context 'account model using couchrest' do
15
15
  setup do
16
- silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=couchrest') }
17
- silence_logger { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
18
-
16
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=couchrest') }
17
+ capture_io { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
18
+
19
19
  @model = "#{@apptmp}/sample_project/admin/models/account.rb"
20
20
  end
21
-
21
+
22
22
  should 'be a couchrest model instance' do
23
23
  assert_match_in_file(/class Account < CouchRest::Model::Base/m, @model)
24
24
  end
25
-
25
+
26
26
  should 'not require additional validations' do
27
27
  assert_no_match_in_file(/include CouchRest::Validation/m, @model)
28
28
  end
29
-
29
+
30
30
  should 'no longer have validates_with_method' do
31
31
  assert_no_match_in_file(/validates_with_method/m, @model)
32
32
  end
33
-
33
+
34
34
  should 'validate report errors using ActiveModel errors method' do
35
35
  assert_match_in_file(/errors\.add\(:email, "is not unique"\)/m, @model)
36
36
  end