padrino-admin 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -146,4 +146,4 @@ module Padrino
146
146
  end # ProjectModule
147
147
  end # AccessControl
148
148
  end # Admin
149
- end # Padrino
149
+ end # Padrino
@@ -38,7 +38,18 @@ module Padrino
38
38
  permission = " role.project_module :#{controller}, \"/#{controller}\"\n"
39
39
  inject_into_file destination_root("/admin/app.rb"), permission, :after => "access_control.roles_for :admin do |role|\n"
40
40
  end
41
+
42
+ ##
43
+ # Remove from access_control permissions
44
+ #
45
+ def remove_project_module(controller)
46
+ path = destination_root("/admin/app.rb")
47
+ say_status :replace, "admin/app.rb", :red
48
+ content = File.binread(path)
49
+ content.gsub!(/^\s+role\.project_module :#{controller}, "\/#{controller}"\n/, '')
50
+ File.open(path, 'wb') { |f| f.write content }
51
+ end
41
52
  end # Actions
42
53
  end # Admin
43
54
  end # Generators
44
- end # Padrino
55
+ end # Padrino
@@ -40,7 +40,7 @@ module Padrino
40
40
  template "templates/#{ext}/page/index.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/index.#{ext}")
41
41
  template "templates/#{ext}/page/new.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/new.#{ext}")
42
42
 
43
- add_project_module(@orm.name_plural) unless options[:destroy]
43
+ options[:destroy] ? remove_project_module(@orm.name_plural) : add_project_module(@orm.name_plural)
44
44
  end
45
45
  else
46
46
  say "You are not at the root of a Padrino application! (config/boot.rb not found)"
@@ -48,4 +48,4 @@ module Padrino
48
48
  end
49
49
  end # AdminPage
50
50
  end # Generators
51
- end # Padrino
51
+ end # Padrino
@@ -9,8 +9,8 @@ module Padrino
9
9
  name = name.to_s
10
10
  @klass_name = name.camelize
11
11
  @klass = @klass_name.constantize rescue nil
12
- @name_plural = name.underscore.pluralize
13
- @name_singular = name.underscore
12
+ @name_singular = name.underscore.gsub(/^.*\//, '') # convert submodules i.e. FooBar::Jank.all # => jank
13
+ @name_plural = @name_singular.pluralize
14
14
  @orm = orm.to_sym
15
15
  @columns = columns
16
16
  @column_fields = column_fields
@@ -18,7 +18,7 @@ module Padrino
18
18
  end
19
19
 
20
20
  def field_type(type)
21
- type = :string if type.nil? #Couchrest-Hack to avoid the next line to fail
21
+ type = :string if type.nil? # couchrest-Hack to avoid the next line to fail
22
22
  type = type.to_s.demodulize.downcase.to_sym unless type.is_a?(Symbol)
23
23
  case type
24
24
  when :integer, :float, :decimal then :text_field
@@ -42,7 +42,7 @@ module Padrino
42
42
  else raise OrmError, "Adapter #{orm} is not yet supported!"
43
43
  end
44
44
  end
45
-
45
+
46
46
  def dm_column(p)
47
47
  case p
48
48
  when DataMapper::Property::Text
@@ -114,4 +114,4 @@ module Padrino
114
114
  end # Orm
115
115
  end # Generators
116
116
  end # Admin
117
- end # Padrino
117
+ end # Padrino
@@ -40,7 +40,7 @@ Admin.controllers :<%= @orm.name_plural %> do
40
40
  if <%= @orm.destroy %>
41
41
  flash[:notice] = '<%= @orm.klass_name %> was successfully destroyed.'
42
42
  else
43
- flash[:error] = 'Impossible destroy <%= @orm.klass_name %>!'
43
+ flash[:error] = 'Unable to destroy <%= @orm.klass_name %>!'
44
44
  end
45
45
  redirect url(:<%= @orm.name_plural %>, :index)
46
46
  end
@@ -1,4 +1,4 @@
1
- !doctype html
1
+ doctype html
2
2
  html lang="en" xmlns="http://www.w3.org/1999/xhtml"
3
3
  head
4
4
  meta content="text/html; charset=utf-8" http-equiv="Content-Type"
@@ -1,4 +1,4 @@
1
- !doctype html
1
+ doctype html
2
2
  html lang="en" xmlns="http://www.w3.org/1999/xhtml"
3
3
  head
4
4
  meta content="text/html; charset=utf-8" http-equiv="Content-Type"
@@ -1,4 +1,4 @@
1
- cz:
1
+ cs:
2
2
  padrino:
3
3
  admin:
4
4
  save: Uložit
@@ -13,4 +13,4 @@ cz:
13
13
  all: Všichni
14
14
  profile: Profil
15
15
  settings: Nastavení
16
- logout: Odhlásit
16
+ logout: Odhlásit
@@ -1,4 +1,4 @@
1
- cz:
1
+ cs:
2
2
  activemodel: &activemodel
3
3
  errors:
4
4
  messages:
@@ -23,4 +23,4 @@ cz:
23
23
  even: "musí být sudé číslo"
24
24
  record_invalid: "Následující pole obsahují chybně vyplněné údaje: %{errors}"
25
25
  content_type: "nepodporovaný formát souboru"
26
- activerecord: *activemodel
26
+ #activerecord: *activemodel
@@ -10,7 +10,7 @@ ru:
10
10
  empty: "не может быть пустым"
11
11
  blank: "не может быть пустым"
12
12
  too_long: "превышает длину (максимум %{count} символов)"
13
- too_short: "недостатночной длины (минимум %{count} символов)"
13
+ too_short: "недостаточной длины (минимум %{count} символов)"
14
14
  wrong_length: "неправильной длины (должно быть %{count} символов)"
15
15
  taken: "уже занят"
16
16
  not_a_number: "не число"
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
+
3
+ class TestFilters < Test::Unit::TestCase
4
+ Dir[File.expand_path("../../lib/padrino-admin/locale/admin/*.yml", __FILE__)].each do |file|
5
+ name = File.basename(file, '.yml')
6
+ should "have a vaild #{name} locale for admin" do
7
+ base = YAML.load_file(file)
8
+ base = base[name]['padrino']['admin']
9
+ assert base.present?
10
+ assert base['save'].present?
11
+ assert base['cancel'].present?
12
+ assert base['list'].present?
13
+ assert base['edit'].present?
14
+ assert base['new'].present?
15
+ assert base['show'].present?
16
+ assert base['delete'].present?
17
+ assert base['confirm'].present?
18
+ assert base['created_at'].present?
19
+ assert base['all'].present?
20
+ assert base['profile'].present?
21
+ assert base['settings'].present?
22
+ assert base['logout'].present?
23
+ end
24
+ end
25
+
26
+ Dir[File.expand_path("../../lib/padrino-admin/locale/orm/*.yml", __FILE__)].each do |file|
27
+ name = File.basename(file, '.yml')
28
+ should "have a vaild #{name} locale for orm" do
29
+ base = YAML.load_file(file)
30
+ # TODO: some one can know why I can't parse YML aliases?
31
+ %w(activemodel).each do |m|
32
+ base = base[name][m]['errors']['messages']
33
+ assert base.present?
34
+ assert base['inclusion'].present?
35
+ assert base['exclusion'].present?
36
+ assert base['invalid'].present?
37
+ assert base['confirmation'].present?
38
+ assert base['accepted'].present?
39
+ assert base['empty'].present?
40
+ assert base['blank'].present?
41
+ assert base['too_long'].present?
42
+ assert base['too_short'].present?
43
+ assert base['wrong_length'].present?
44
+ assert base['taken'].present?
45
+ assert base['not_a_number'].present?
46
+ assert base['greater_than'].present?
47
+ assert base['greater_than_or_equal_to'].present?
48
+ assert base['equal_to'].present?
49
+ assert base['less_than'].present?
50
+ assert base['less_than_or_equal_to'].present?
51
+ assert base['odd'].present?
52
+ assert base['even'].present?
53
+ assert base['record_invalid'].present?
54
+ assert base['content_type'].present?
55
+ end
56
+ end
57
+ end
58
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: padrino-admin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.0
5
+ version: 0.10.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Padrino Team
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-07-07 00:00:00 -07:00
16
+ date: 2011-08-01 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirements:
25
25
  - - "="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.10.0
27
+ version: 0.10.1
28
28
  type: :runtime
29
29
  version_requirements: *id001
30
30
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - "="
37
37
  - !ruby/object:Gem::Version
38
- version: 0.10.0
38
+ version: 0.10.1
39
39
  type: :runtime
40
40
  version_requirements: *id002
41
41
  description: Admin View for Padrino applications
@@ -108,7 +108,7 @@ files:
108
108
  - lib/padrino-admin/generators/templates/slim/page/new.slim.tt
109
109
  - lib/padrino-admin/helpers/authentication_helpers.rb
110
110
  - lib/padrino-admin/helpers/view_helpers.rb
111
- - lib/padrino-admin/locale/admin/cz.yml
111
+ - lib/padrino-admin/locale/admin/cs.yml
112
112
  - lib/padrino-admin/locale/admin/da.yml
113
113
  - lib/padrino-admin/locale/admin/de.yml
114
114
  - lib/padrino-admin/locale/admin/en.yml
@@ -126,7 +126,7 @@ files:
126
126
  - lib/padrino-admin/locale/admin/uk.yml
127
127
  - lib/padrino-admin/locale/admin/zh_cn.yml
128
128
  - lib/padrino-admin/locale/admin/zh_tw.yml
129
- - lib/padrino-admin/locale/orm/cz.yml
129
+ - lib/padrino-admin/locale/orm/cs.yml
130
130
  - lib/padrino-admin/locale/orm/da.yml
131
131
  - lib/padrino-admin/locale/orm/de.yml
132
132
  - lib/padrino-admin/locale/orm/en.yml
@@ -152,6 +152,7 @@ files:
152
152
  - test/generators/test_admin_page_generator.rb
153
153
  - test/helper.rb
154
154
  - test/test_admin_application.rb
155
+ - test/test_locale.rb
155
156
  has_rdoc: true
156
157
  homepage: http://www.padrinorb.com
157
158
  licenses: []
@@ -187,3 +188,4 @@ test_files:
187
188
  - test/generators/test_admin_page_generator.rb
188
189
  - test/helper.rb
189
190
  - test/test_admin_application.rb
191
+ - test/test_locale.rb