padrino-admin 0.9.18 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/padrino-admin/generators/admin_app.rb +27 -7
- data/lib/padrino-admin/generators/admin_page.rb +3 -1
- data/lib/padrino-admin/generators/orm.rb +1 -0
- data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +7 -14
- data/lib/padrino-admin/generators/templates/account/couchrest.rb.tt +9 -17
- data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +7 -19
- data/lib/padrino-admin/generators/templates/account/mongoid.rb.tt +5 -13
- data/lib/padrino-admin/generators/templates/account/mongomapper.rb.tt +5 -13
- data/lib/padrino-admin/generators/templates/account/seeds.rb.tt +2 -2
- data/lib/padrino-admin/generators/templates/account/sequel.rb.tt +4 -12
- data/lib/padrino-admin/generators/templates/app/controllers/sessions.rb +4 -0
- data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +11 -1
- data/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +1 -1
- data/lib/padrino-admin/generators/templates/haml/app/sessions/new.haml.tt +6 -0
- data/lib/padrino-admin/generators/templates/haml/page/index.haml.tt +1 -1
- data/lib/padrino-admin/locale/admin/no.yml +17 -0
- data/lib/padrino-admin/locale/orm/no.yml +27 -0
- data/test/generators/test_admin_app_generator.rb +19 -0
- data/test/generators/test_admin_page_generator.rb +5 -1
- data/test/helper.rb +1 -0
- metadata +12 -10
|
@@ -43,11 +43,12 @@ module Padrino
|
|
|
43
43
|
|
|
44
44
|
ext = fetch_component_choice(:renderer)
|
|
45
45
|
|
|
46
|
+
empty_directory destination_root("admin")
|
|
46
47
|
directory "templates/app", destination_root("admin")
|
|
47
48
|
directory "templates/assets", destination_root("public", "admin")
|
|
48
49
|
|
|
49
50
|
account_params = [
|
|
50
|
-
"account", "name:string", "surname:string", "email:string", "crypted_password:string", "
|
|
51
|
+
"account", "name:string", "surname:string", "email:string", "crypted_password:string", "role:string",
|
|
51
52
|
"-r=#{options[:root]}"
|
|
52
53
|
]
|
|
53
54
|
|
|
@@ -67,30 +68,49 @@ module Padrino
|
|
|
67
68
|
{ :name => :role, :field_type => :text_field }
|
|
68
69
|
]
|
|
69
70
|
|
|
70
|
-
admin_app = Padrino::Generators::AdminPage.new(["account"], :root => options[:root])
|
|
71
|
+
admin_app = Padrino::Generators::AdminPage.new(["account"], :root => options[:root], :destroy => options[:destroy])
|
|
71
72
|
admin_app.default_orm = Padrino::Admin::Generators::Orm.new(:account, orm, columns, column_fields)
|
|
72
73
|
admin_app.invoke_all
|
|
73
74
|
|
|
74
75
|
template "templates/account/#{orm}.rb.tt", destination_root("app", "models", "account.rb"), :force => true
|
|
75
|
-
|
|
76
|
+
|
|
77
|
+
if File.exist?(destination_root("db/seeds.rb"))
|
|
78
|
+
append_file(destination_root("db/seeds.rb")) { "\n\n" + File.read(self.class.source_root+"/templates/account/seeds.rb.tt") }
|
|
79
|
+
else
|
|
80
|
+
template "templates/account/seeds.rb.tt", destination_root("db/seeds.rb")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
empty_directory destination_root("admin/controllers")
|
|
84
|
+
empty_directory destination_root("admin/views")
|
|
85
|
+
empty_directory destination_root("admin/views/base")
|
|
86
|
+
empty_directory destination_root("admin/views/layouts")
|
|
87
|
+
empty_directory destination_root("admin/views/sessions")
|
|
88
|
+
|
|
76
89
|
template "templates/#{ext}/app/base/_sidebar.#{ext}.tt", destination_root("admin/views/base/_sidebar.#{ext}")
|
|
77
90
|
template "templates/#{ext}/app/base/index.#{ext}.tt", destination_root("admin/views/base/index.#{ext}")
|
|
78
91
|
template "templates/#{ext}/app/layouts/application.#{ext}.tt", destination_root("admin/views/layouts/application.#{ext}")
|
|
79
92
|
template "templates/#{ext}/app/sessions/new.#{ext}.tt", destination_root("admin/views/sessions/new.#{ext}")
|
|
80
93
|
|
|
81
94
|
add_project_module :accounts
|
|
95
|
+
require_dependencies('bcrypt-ruby', :require => 'bcrypt')
|
|
82
96
|
append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"Admin\").to(\"/admin\")"
|
|
83
97
|
gsub_file destination_root("admin/views/accounts/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
|
|
84
98
|
gsub_file destination_root("admin/controllers/accounts.rb"), "if account.destroy", "if account != current_account && account.destroy"
|
|
85
99
|
return if self.behavior == :revoke
|
|
100
|
+
|
|
101
|
+
instructions = []
|
|
102
|
+
instructions << "Run 'padrino rake ar:migrate'" if orm == :activerecord
|
|
103
|
+
instructions << "Run 'padrino rake dm:migrate'" if orm == :datamapper
|
|
104
|
+
instructions << "Run 'padrino rake seed'"
|
|
105
|
+
instructions << "Visit the admin panel in the browser at '/admin'"
|
|
106
|
+
instructions.map! { |i| " #{instructions.index(i) + 1}) #{i}" }
|
|
107
|
+
|
|
86
108
|
say((<<-TEXT).gsub(/ {10}/,''))
|
|
87
109
|
|
|
88
110
|
=================================================================
|
|
89
111
|
The admin panel has been mounted! Next, follow these steps:
|
|
90
112
|
=================================================================
|
|
91
|
-
|
|
92
|
-
2) Run 'padrino rake seed'
|
|
93
|
-
3) Visit the admin panel in the browser at '/admin'
|
|
113
|
+
#{instructions.join("\n")}
|
|
94
114
|
=================================================================
|
|
95
115
|
|
|
96
116
|
TEXT
|
|
@@ -100,4 +120,4 @@ module Padrino
|
|
|
100
120
|
end
|
|
101
121
|
end # AdminApp
|
|
102
122
|
end # Generators
|
|
103
|
-
end # Padrino
|
|
123
|
+
end # Padrino
|
|
@@ -34,13 +34,15 @@ module Padrino
|
|
|
34
34
|
self.behavior = :revoke if options[:destroy]
|
|
35
35
|
ext = fetch_component_choice(:renderer)
|
|
36
36
|
|
|
37
|
+
empty_directory destination_root("/admin/views/#{@orm.name_plural}")
|
|
38
|
+
|
|
37
39
|
template "templates/page/controller.rb.tt", destination_root("/admin/controllers/#{@orm.name_plural}.rb")
|
|
38
40
|
template "templates/#{ext}/page/_form.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/_form.#{ext}")
|
|
39
41
|
template "templates/#{ext}/page/edit.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/edit.#{ext}")
|
|
40
42
|
template "templates/#{ext}/page/index.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/index.#{ext}")
|
|
41
43
|
template "templates/#{ext}/page/new.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/new.#{ext}")
|
|
42
44
|
|
|
43
|
-
add_project_module(@orm.name_plural)
|
|
45
|
+
add_project_module(@orm.name_plural) unless options[:destroy]
|
|
44
46
|
end
|
|
45
47
|
else
|
|
46
48
|
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
|
|
@@ -18,6 +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
22
|
type = type.to_s.demodulize.downcase.to_sym unless type.is_a?(Symbol)
|
|
22
23
|
case type
|
|
23
24
|
when :integer, :float, :decimal then :text_field
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
require 'digest/sha1'
|
|
2
|
-
|
|
3
1
|
class Account < ActiveRecord::Base
|
|
4
|
-
attr_accessor :password
|
|
2
|
+
attr_accessor :password, :password_confirmation
|
|
5
3
|
|
|
6
4
|
# Validations
|
|
7
5
|
validates_presence_of :email, :role
|
|
@@ -15,28 +13,23 @@ class Account < ActiveRecord::Base
|
|
|
15
13
|
validates_format_of :role, :with => /[A-Za-z]/
|
|
16
14
|
|
|
17
15
|
# Callbacks
|
|
18
|
-
before_save :
|
|
16
|
+
before_save :encrypt_password
|
|
19
17
|
|
|
20
18
|
##
|
|
21
19
|
# This method is for authentication purpose
|
|
22
20
|
#
|
|
23
21
|
def self.authenticate(email, password)
|
|
24
22
|
account = first(:conditions => { :email => email }) if email.present?
|
|
25
|
-
account && account.
|
|
23
|
+
account && account.has_password?(password) ? account : nil
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
def password_clean
|
|
32
|
-
crypted_password.decrypt(salt)
|
|
26
|
+
def has_password?(password)
|
|
27
|
+
::BCrypt::Password.new(crypted_password) == password
|
|
33
28
|
end
|
|
34
29
|
|
|
35
30
|
private
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
|
|
39
|
-
self.crypted_password = password.encrypt(self.salt)
|
|
31
|
+
def encrypt_password
|
|
32
|
+
self.crypted_password = ::BCrypt::Password.create(password)
|
|
40
33
|
end
|
|
41
34
|
|
|
42
35
|
def password_required
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'digest/sha1'
|
|
2
|
-
|
|
3
1
|
class Account < CouchRest::ExtendedDocument
|
|
4
2
|
include CouchRest::Validation
|
|
5
3
|
use_database COUCHDB
|
|
@@ -11,7 +9,6 @@ class Account < CouchRest::ExtendedDocument
|
|
|
11
9
|
property :surname
|
|
12
10
|
property :email
|
|
13
11
|
property :crypted_password
|
|
14
|
-
property :salt
|
|
15
12
|
property :role
|
|
16
13
|
|
|
17
14
|
view_by :email
|
|
@@ -30,7 +27,7 @@ class Account < CouchRest::ExtendedDocument
|
|
|
30
27
|
validates_format_of :role, :with => /[A-Za-z]/
|
|
31
28
|
|
|
32
29
|
# Callbacks
|
|
33
|
-
before_save :
|
|
30
|
+
before_save :encrypt_password
|
|
34
31
|
|
|
35
32
|
##
|
|
36
33
|
# This method is for authentication purpose
|
|
@@ -38,14 +35,7 @@ class Account < CouchRest::ExtendedDocument
|
|
|
38
35
|
def self.authenticate(email, password)
|
|
39
36
|
email_array = self.by_email :key => email
|
|
40
37
|
account = email_array[0]
|
|
41
|
-
account && account.
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
##
|
|
45
|
-
# This method is used to retrieve the original password.
|
|
46
|
-
#
|
|
47
|
-
def password_clean
|
|
48
|
-
crypted_password.decrypt(salt)
|
|
38
|
+
account && account.has_password?(password) ? account : nil
|
|
49
39
|
end
|
|
50
40
|
|
|
51
41
|
##
|
|
@@ -56,11 +46,13 @@ class Account < CouchRest::ExtendedDocument
|
|
|
56
46
|
id_array[0]
|
|
57
47
|
end
|
|
58
48
|
|
|
49
|
+
def has_password?(password)
|
|
50
|
+
::BCrypt::Password.new(crypted_password) == password
|
|
51
|
+
end
|
|
52
|
+
|
|
59
53
|
private
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if self.salt.blank?
|
|
63
|
-
self.crypted_password = password.encrypt(self.salt)
|
|
54
|
+
def encrypt_password
|
|
55
|
+
self.crypted_password = ::BCrypt::Password.create(password)
|
|
64
56
|
end
|
|
65
57
|
|
|
66
58
|
def password_required
|
|
@@ -75,6 +67,6 @@ class Account < CouchRest::ExtendedDocument
|
|
|
75
67
|
# there is an id, make sure updates are being applied to same account
|
|
76
68
|
return true if self["_id"] == account["_id"]
|
|
77
69
|
end
|
|
78
|
-
[false, "Email has already been taken"]
|
|
70
|
+
[false, "Email has already been taken"]
|
|
79
71
|
end
|
|
80
72
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'digest/sha1'
|
|
2
|
-
|
|
3
1
|
class Account
|
|
4
2
|
include DataMapper::Resource
|
|
5
3
|
include DataMapper::Validate
|
|
@@ -11,7 +9,6 @@ class Account
|
|
|
11
9
|
property :surname, String
|
|
12
10
|
property :email, String
|
|
13
11
|
property :crypted_password, String
|
|
14
|
-
property :salt, String
|
|
15
12
|
property :role, String
|
|
16
13
|
|
|
17
14
|
# Validations
|
|
@@ -30,7 +27,7 @@ class Account
|
|
|
30
27
|
#
|
|
31
28
|
def self.authenticate(email, password)
|
|
32
29
|
account = first(:conditions => { :email => email }) if email.present?
|
|
33
|
-
account && account.
|
|
30
|
+
account && account.has_password?(password) ? account : nil
|
|
34
31
|
end
|
|
35
32
|
|
|
36
33
|
##
|
|
@@ -40,25 +37,16 @@ class Account
|
|
|
40
37
|
get(id) rescue nil
|
|
41
38
|
end
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
#
|
|
46
|
-
def password_clean
|
|
47
|
-
crypted_password.decrypt(salt)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
###
|
|
51
|
-
# Password setter generates salt and crypted_password
|
|
52
|
-
#
|
|
53
|
-
def password=(val)
|
|
54
|
-
return if val.blank?
|
|
55
|
-
attribute_set(:salt, Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--")) if new?
|
|
56
|
-
attribute_set(:crypted_password, val.encrypt(self.salt))
|
|
40
|
+
def has_password?(password)
|
|
41
|
+
::BCrypt::Password.new(crypted_password) == password
|
|
57
42
|
end
|
|
58
43
|
|
|
59
44
|
private
|
|
60
|
-
|
|
61
45
|
def password_required
|
|
62
46
|
crypted_password.blank? || !password.blank?
|
|
63
47
|
end
|
|
48
|
+
|
|
49
|
+
def encrypt_password
|
|
50
|
+
self.crypted_password = ::BCrypt::Password.create(password)
|
|
51
|
+
end
|
|
64
52
|
end
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
require 'digest/sha1'
|
|
2
|
-
|
|
3
1
|
class Account
|
|
4
2
|
include Mongoid::Document
|
|
5
|
-
attr_accessor :password
|
|
3
|
+
attr_accessor :password, :password_confirmation
|
|
6
4
|
|
|
7
5
|
# Fields
|
|
8
6
|
field :name, :type => String
|
|
9
7
|
field :surname, :type => String
|
|
10
8
|
field :email, :type => String
|
|
11
9
|
field :crypted_password, :type => String
|
|
12
|
-
field :salt, :type => String
|
|
13
10
|
field :role, :type => String
|
|
14
11
|
|
|
15
12
|
# Validations
|
|
@@ -31,7 +28,7 @@ class Account
|
|
|
31
28
|
#
|
|
32
29
|
def self.authenticate(email, password)
|
|
33
30
|
account = first(:conditions => { :email => email }) if email.present?
|
|
34
|
-
account && account.
|
|
31
|
+
account && account.has_password?(password) ? account : nil
|
|
35
32
|
end
|
|
36
33
|
|
|
37
34
|
##
|
|
@@ -41,18 +38,13 @@ class Account
|
|
|
41
38
|
find(id) rescue nil
|
|
42
39
|
end
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
#
|
|
47
|
-
def password_clean
|
|
48
|
-
crypted_password.decrypt(salt)
|
|
41
|
+
def has_password?(password)
|
|
42
|
+
::BCrypt::Password.new(crypted_password) == password
|
|
49
43
|
end
|
|
50
44
|
|
|
51
45
|
private
|
|
52
46
|
def generate_password
|
|
53
|
-
|
|
54
|
-
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
|
|
55
|
-
self.crypted_password = password.encrypt(self.salt)
|
|
47
|
+
self.crypted_password = ::BCrypt::Password.create(self.password)
|
|
56
48
|
end
|
|
57
49
|
|
|
58
50
|
def password_required
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
require 'digest/sha1'
|
|
2
|
-
|
|
3
1
|
class Account
|
|
4
2
|
include MongoMapper::Document
|
|
5
|
-
attr_accessor :password
|
|
3
|
+
attr_accessor :password, :password_confirmation
|
|
6
4
|
|
|
7
5
|
# Keys
|
|
8
6
|
key :name, String
|
|
9
7
|
key :surname, String
|
|
10
8
|
key :email, String
|
|
11
9
|
key :crypted_password, String
|
|
12
|
-
key :salt, String
|
|
13
10
|
key :role, String
|
|
14
11
|
|
|
15
12
|
# Validations
|
|
@@ -31,21 +28,16 @@ class Account
|
|
|
31
28
|
#
|
|
32
29
|
def self.authenticate(email, password)
|
|
33
30
|
account = first(:email => email) if email.present?
|
|
34
|
-
account && account.
|
|
31
|
+
account && account.has_password?(password) ? account : nil
|
|
35
32
|
end
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
#
|
|
40
|
-
def password_clean
|
|
41
|
-
crypted_password.decrypt(salt)
|
|
34
|
+
def has_password?(password)
|
|
35
|
+
::BCrypt::Password.new(crypted_password) == password
|
|
42
36
|
end
|
|
43
37
|
|
|
44
38
|
private
|
|
45
39
|
def generate_password
|
|
46
|
-
|
|
47
|
-
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
|
|
48
|
-
self.crypted_password = password.encrypt(self.salt)
|
|
40
|
+
self.crypted_password = ::BCrypt::Password.create(password)
|
|
49
41
|
end
|
|
50
42
|
|
|
51
43
|
def password_required
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# name = shell.ask("What's your name?")
|
|
6
6
|
# shell.say name
|
|
7
7
|
#
|
|
8
|
-
email = shell.ask "Which email do you want use for
|
|
8
|
+
email = shell.ask "Which email do you want use for logging into admin?"
|
|
9
9
|
password = shell.ask "Tell me the password to use:"
|
|
10
10
|
|
|
11
11
|
shell.say ""
|
|
@@ -20,7 +20,7 @@ if account.valid?
|
|
|
20
20
|
shell.say " password: #{password}"
|
|
21
21
|
shell.say "================================================================="
|
|
22
22
|
else
|
|
23
|
-
shell.say "Sorry but some thing went
|
|
23
|
+
shell.say "Sorry but some thing went wrong!"
|
|
24
24
|
shell.say ""
|
|
25
25
|
account.errors.full_messages.each { |m| shell.say " - #{m}" }
|
|
26
26
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'digest/sha1'
|
|
2
|
-
|
|
3
1
|
class Account < ::Sequel::Model
|
|
4
2
|
|
|
5
3
|
plugin :validation_helpers
|
|
@@ -29,7 +27,7 @@ class Account < ::Sequel::Model
|
|
|
29
27
|
#
|
|
30
28
|
def self.authenticate(email, password)
|
|
31
29
|
account = filter(:email => email).first
|
|
32
|
-
account && account.
|
|
30
|
+
account && account.has_password?(password) ? account : nil
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
##
|
|
@@ -39,19 +37,13 @@ class Account < ::Sequel::Model
|
|
|
39
37
|
self[id] rescue nil
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
def password_clean
|
|
46
|
-
self.crypted_password.decrypt(salt)
|
|
40
|
+
def has_password?(password)
|
|
41
|
+
::BCrypt::Password.new(crypted_password) == password
|
|
47
42
|
end
|
|
48
43
|
|
|
49
44
|
private
|
|
50
|
-
|
|
51
45
|
def generate_password
|
|
52
|
-
|
|
53
|
-
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new?
|
|
54
|
-
self.crypted_password = password.encrypt(self.salt)
|
|
46
|
+
self.crypted_password = ::BCrypt::Password.create(password)
|
|
55
47
|
end
|
|
56
48
|
|
|
57
49
|
def password_required
|
|
@@ -8,6 +8,10 @@ Admin.controllers :sessions do
|
|
|
8
8
|
if account = Account.authenticate(params[:email], params[:password])
|
|
9
9
|
set_current_account(account)
|
|
10
10
|
redirect url(:base, :index)
|
|
11
|
+
elsif Padrino.env == :development && params[:bypass]
|
|
12
|
+
account = Account.first
|
|
13
|
+
set_current_account(account)
|
|
14
|
+
redirect url(:base, :index)
|
|
11
15
|
else
|
|
12
16
|
flash[:warning] = "Login or password wrong."
|
|
13
17
|
redirect url(:sessions, :new)
|
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
<%%= password_field_tag :password, :value => params[:password], :class => 'text_field' %>
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
|
+
<%% if Padrino.env == :development %>
|
|
36
|
+
<div class="group wat-cf">
|
|
37
|
+
<div class="left">
|
|
38
|
+
<label class="label right">Bypass login?</label>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="right">
|
|
41
|
+
<%%= check_box_tag :bypass %>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<%% end %>
|
|
35
45
|
<div class="group navform wat-cf">
|
|
36
46
|
<div class="right">
|
|
37
47
|
<%%= submit_tag "Sign in", :class => :button %>
|
|
@@ -43,4 +53,4 @@
|
|
|
43
53
|
</div>
|
|
44
54
|
</div>
|
|
45
55
|
</body>
|
|
46
|
-
</html>
|
|
56
|
+
</html>
|
|
@@ -21,5 +21,11 @@
|
|
|
21
21
|
.left
|
|
22
22
|
%label.label.right Password
|
|
23
23
|
.right=password_field_tag :password, :value => params[:password], :class => :text_field
|
|
24
|
+
-if Padrino.env == :development
|
|
25
|
+
.group.wat-cf
|
|
26
|
+
.left
|
|
27
|
+
%label.label.right Bypass login?
|
|
28
|
+
.right=check_box_tag :bypass
|
|
29
|
+
|
|
24
30
|
.group.navform.wat-cf
|
|
25
31
|
.right=submit_tag('Sign In', :class => :button)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"no":
|
|
2
|
+
padrino:
|
|
3
|
+
admin:
|
|
4
|
+
save: Lagre
|
|
5
|
+
cancel: Avbryt
|
|
6
|
+
list: Liste
|
|
7
|
+
edit: Rediger
|
|
8
|
+
new: Ny
|
|
9
|
+
show: Vis
|
|
10
|
+
delete: Slett
|
|
11
|
+
confirm: Er du sikker?
|
|
12
|
+
created_at: Opprettet
|
|
13
|
+
all: Alle
|
|
14
|
+
profile: Profil
|
|
15
|
+
settings: Instillinger
|
|
16
|
+
logout: Logg ut
|
|
17
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"no":
|
|
2
|
+
activemodel: &activemodel
|
|
3
|
+
errors:
|
|
4
|
+
messages:
|
|
5
|
+
inclusion: "finnes ikke i listen"
|
|
6
|
+
exclusion: "er reservert"
|
|
7
|
+
invalid: "er ikke gyldig"
|
|
8
|
+
confirmation: "matcher ikke bekreftelsen"
|
|
9
|
+
accepted: "må aksepteres"
|
|
10
|
+
empty: "kan ikke være tom"
|
|
11
|
+
blank: "kan ikke være blank"
|
|
12
|
+
too_long: "er for lang (maksimum er %{count} tegn)"
|
|
13
|
+
too_short: "er for kort (minimum er %{count} tegn)"
|
|
14
|
+
wrong_length: "har ikke den riktige lengden(skal være på %{count} tegn)"
|
|
15
|
+
taken: "er allerede i bruk"
|
|
16
|
+
not_a_number: "er ikke et tall"
|
|
17
|
+
greater_than: "skal være større enn %{count}"
|
|
18
|
+
greater_than_or_equal_to: "skal være større enn eller lik %{count}"
|
|
19
|
+
equal_to: "skal være lik %{count}"
|
|
20
|
+
less_than: "skal være mindre enn %{count}"
|
|
21
|
+
less_than_or_equal_to: "skal være mindre enn eller lik %{count}"
|
|
22
|
+
odd: "skal være ulik"
|
|
23
|
+
even: "skal være lik"
|
|
24
|
+
record_invalid: "Valideringsfeil: %{errors}"
|
|
25
|
+
content_type: "fileformatet er ikke støttet"
|
|
26
|
+
activerecord: *activemodel
|
|
27
|
+
|
|
@@ -90,5 +90,24 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
|
90
90
|
assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
|
|
91
91
|
assert_match_in_file 'role.project_module :accounts, "/accounts"', "#{@apptmp}/sample_project/admin/app.rb"
|
|
92
92
|
end
|
|
93
|
+
|
|
94
|
+
should 'not conflict with existing seeds file' do
|
|
95
|
+
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=erb') } }
|
|
96
|
+
|
|
97
|
+
# Add seeds file
|
|
98
|
+
FileUtils.mkdir_p @apptmp + '/sample_project/db' unless File.exist?(@apptmp + '/sample_project/db')
|
|
99
|
+
File.open(@apptmp + '/sample_project/db/seeds.rb', 'w+') do |seeds_rb|
|
|
100
|
+
seeds_rb.puts "# Old Seeds Content"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
silence_logger do
|
|
104
|
+
$stdout.expects(:print).with { |value| value =~ /Overwrite\s.*?\/db\/seeds.rb/ }.never
|
|
105
|
+
$stdin.stubs(:gets).returns('y')
|
|
106
|
+
generate(:admin_app, "--root=#{@apptmp}/sample_project")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
assert_match_in_file '# Old Seeds Content', "#{@apptmp}/sample_project/db/seeds.rb"
|
|
110
|
+
assert_match_in_file 'Account.create(', "#{@apptmp}/sample_project/db/seeds.rb"
|
|
111
|
+
end
|
|
93
112
|
end
|
|
94
113
|
end
|
|
@@ -52,6 +52,8 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
|
52
52
|
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
|
53
53
|
end
|
|
54
54
|
assert_match_in_file 'role.project_module :people, "/people"', "#{@apptmp}/sample_project/admin/app.rb"
|
|
55
|
+
assert_match_in_file "elsif Padrino.env == :development && params[:bypass]", "#{@apptmp}/sample_project/admin/controllers/sessions.rb"
|
|
56
|
+
assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.haml"
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
should 'correctly generate a new padrino admin application with erb renderer' do
|
|
@@ -69,6 +71,8 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
|
69
71
|
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
|
|
70
72
|
end
|
|
71
73
|
assert_match_in_file 'role.project_module :people, "/people"', "#{@apptmp}/sample_project/admin/app.rb"
|
|
74
|
+
assert_match_in_file "elsif Padrino.env == :development && params[:bypass]", "#{@apptmp}/sample_project/admin/controllers/sessions.rb"
|
|
75
|
+
assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.erb"
|
|
72
76
|
end
|
|
73
77
|
|
|
74
78
|
should 'correctly generate a new padrino admin application with multiple models' do
|
|
@@ -101,4 +105,4 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
|
101
105
|
assert_match_in_file 'role.project_module :pages, "/pages"', "#{@apptmp}/sample_project/admin/app.rb"
|
|
102
106
|
end
|
|
103
107
|
end
|
|
104
|
-
end
|
|
108
|
+
end
|
data/test/helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: padrino-admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 29
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
-
|
|
10
|
-
version: 0.9.
|
|
9
|
+
- 19
|
|
10
|
+
version: 0.9.19
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Padrino Team
|
|
@@ -18,7 +18,7 @@ autorequire:
|
|
|
18
18
|
bindir: bin
|
|
19
19
|
cert_chain: []
|
|
20
20
|
|
|
21
|
-
date: 2010-
|
|
21
|
+
date: 2010-11-17 00:00:00 +01:00
|
|
22
22
|
default_executable:
|
|
23
23
|
dependencies:
|
|
24
24
|
- !ruby/object:Gem::Dependency
|
|
@@ -29,12 +29,12 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
hash:
|
|
32
|
+
hash: 29
|
|
33
33
|
segments:
|
|
34
34
|
- 0
|
|
35
35
|
- 9
|
|
36
|
-
-
|
|
37
|
-
version: 0.9.
|
|
36
|
+
- 19
|
|
37
|
+
version: 0.9.19
|
|
38
38
|
type: :runtime
|
|
39
39
|
version_requirements: *id001
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
@@ -45,12 +45,12 @@ dependencies:
|
|
|
45
45
|
requirements:
|
|
46
46
|
- - "="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
hash:
|
|
48
|
+
hash: 29
|
|
49
49
|
segments:
|
|
50
50
|
- 0
|
|
51
51
|
- 9
|
|
52
|
-
-
|
|
53
|
-
version: 0.9.
|
|
52
|
+
- 19
|
|
53
|
+
version: 0.9.19
|
|
54
54
|
type: :runtime
|
|
55
55
|
version_requirements: *id002
|
|
56
56
|
description: Admin View for Padrino applications
|
|
@@ -123,6 +123,7 @@ files:
|
|
|
123
123
|
- lib/padrino-admin/locale/admin/fr.yml
|
|
124
124
|
- lib/padrino-admin/locale/admin/it.yml
|
|
125
125
|
- lib/padrino-admin/locale/admin/nl.yml
|
|
126
|
+
- lib/padrino-admin/locale/admin/no.yml
|
|
126
127
|
- lib/padrino-admin/locale/admin/pl.yml
|
|
127
128
|
- lib/padrino-admin/locale/admin/pt_br.yml
|
|
128
129
|
- lib/padrino-admin/locale/admin/ru.yml
|
|
@@ -136,6 +137,7 @@ files:
|
|
|
136
137
|
- lib/padrino-admin/locale/orm/fr.yml
|
|
137
138
|
- lib/padrino-admin/locale/orm/it.yml
|
|
138
139
|
- lib/padrino-admin/locale/orm/nl.yml
|
|
140
|
+
- lib/padrino-admin/locale/orm/no.yml
|
|
139
141
|
- lib/padrino-admin/locale/orm/pl.yml
|
|
140
142
|
- lib/padrino-admin/locale/orm/pt_br.yml
|
|
141
143
|
- lib/padrino-admin/locale/orm/ru.yml
|