active_leonardo 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/active_template.rb +18 -9
- data/lib/generators/active_leonardo.rb +13 -4
- data/lib/generators/leolay/leolay_generator.rb +13 -10
- data/lib/generators/leolay/templates/app/admin/users.rb +25 -16
- data/lib/generators/leolay/templates/config/initializers/activeadmin_cancan.rb +114 -0
- data/lib/generators/leolay/templates/config/initializers/activeadmin_leonardo.rb +30 -0
- data/lib/generators/leolay/templates/config/locales/devise.it.yml +57 -0
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +10 -20
- metadata +41 -8
- data/lib/generators/leolay/templates/app/views/admin/users/_form.html.erb +0 -21
- data/lib/generators/leolay/templates/lib/upd_activeadmin.rb +0 -65
data/CHANGELOG
CHANGED
@@ -1,2 +1,9 @@
|
|
1
|
+
0.0.3 (May 23th, 2012) Marco Mastrodonato
|
2
|
+
* Improved cancan integration
|
3
|
+
* Localization yaml file cleaned from some previous leonardo stuff
|
4
|
+
|
5
|
+
0.0.2 (May 23th, 2012) Marco Mastrodonato
|
6
|
+
* Minor changement
|
7
|
+
|
1
8
|
0.0.1 (May 23th, 2012) Marco Mastrodonato
|
2
9
|
* First release
|
data/active_template.rb
CHANGED
@@ -44,33 +44,42 @@ gem "active_leonardo"
|
|
44
44
|
|
45
45
|
gem 'state_machine' if yes?("Do you have to handle states ?")
|
46
46
|
|
47
|
-
authorization = yes?("Authorization ?")
|
48
|
-
gem 'cancan' if authorization
|
49
|
-
|
50
47
|
authentication = yes?("Authentication ?")
|
48
|
+
model_name = authorization = nil
|
49
|
+
if authentication
|
50
|
+
default_model_name = "User"
|
51
|
+
model_name = ask(" Insert model name: [#{default_model_name}] (Other names are not tested yet)")
|
52
|
+
model_name = default_model_name if model_name.empty?
|
53
|
+
|
54
|
+
authorization = yes?("Authorization ?")
|
55
|
+
gem 'cancan' if authorization
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
home =
|
58
|
+
dashboard_root = yes?("Would you use dashboard as root ? (recommended)")
|
59
|
+
home = yes?("Ok. Would you create home controller as root ?") unless dashboard_root
|
54
60
|
|
55
61
|
if yes?("Bundle install ?")
|
56
62
|
dir = ask(" Insert folder name to install locally: [blank=default gems path]")
|
57
63
|
run "bundle install #{"--path=#{dir}" unless dir.empty?}"
|
58
64
|
end
|
59
65
|
|
60
|
-
generate "active_admin:install #{authentication ?
|
66
|
+
generate "active_admin:install #{authentication ? model_name : "--skip-users"}"
|
61
67
|
|
62
68
|
if authorization
|
63
69
|
generate "cancan:ability"
|
64
|
-
generate "migration", "
|
70
|
+
generate "migration", "AddRolesMaskTo#{model_name}", "roles_mask:integer"
|
65
71
|
end
|
66
72
|
|
67
73
|
generate "leolay",
|
68
74
|
"active", #specify theme
|
75
|
+
"--auth_class=#{model_name}",
|
69
76
|
(authorization ? "" : "--skip-authorization"),
|
70
|
-
(authentication ? "" : "--skip-authentication")
|
77
|
+
(authentication ? "" : "--skip-authentication")
|
71
78
|
|
72
79
|
|
73
|
-
if
|
80
|
+
if dashboard_root
|
81
|
+
route "root :to => 'admin/dashboard#index'"
|
82
|
+
elsif home
|
74
83
|
generate "controller", "home", "index"
|
75
84
|
route "root :to => 'home#index'"
|
76
85
|
end
|
@@ -1,15 +1,24 @@
|
|
1
1
|
module ActiveLeonardo
|
2
2
|
module Base
|
3
3
|
protected
|
4
|
+
def authorization_file
|
5
|
+
"app/models/ability.rb"
|
6
|
+
end
|
4
7
|
def authorization?
|
5
|
-
File.exists?
|
8
|
+
File.exists? authorization_file
|
9
|
+
end
|
10
|
+
def authentication_file auth_class="User"
|
11
|
+
"app/models/#{auth_class.downcase}.rb"
|
6
12
|
end
|
7
|
-
def authentication?
|
8
|
-
return true if File.exists?
|
13
|
+
def authentication? auth_class="User"
|
14
|
+
return true if File.exists? authentication_file(auth_class)
|
9
15
|
File.exists? "config/initializers/devise.rb"
|
10
16
|
end
|
17
|
+
def activeadmin_file
|
18
|
+
"config/initializers/active_admin.rb"
|
19
|
+
end
|
11
20
|
def activeadmin?
|
12
|
-
File.exists?
|
21
|
+
File.exists? activeadmin_file
|
13
22
|
end
|
14
23
|
#def formtastic?
|
15
24
|
# return false unless options.formtastic?
|
@@ -1,4 +1,8 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../active_leonardo')
|
2
|
+
|
1
3
|
class LeolayGenerator < Rails::Generators::Base
|
4
|
+
include ::ActiveLeonardo::Base
|
5
|
+
|
2
6
|
source_root File.expand_path('../templates', __FILE__)
|
3
7
|
argument :style, :type => :string, :default => "active"
|
4
8
|
#class_option :pagination, :type => :boolean, :default => true, :desc => "Include pagination files"
|
@@ -7,7 +11,7 @@ class LeolayGenerator < Rails::Generators::Base
|
|
7
11
|
class_option :authentication, :type => :boolean, :default => true, :desc => "Add code to manage authentication with devise"
|
8
12
|
class_option :authorization, :type => :boolean, :default => true, :desc => "Add code to manage authorization with cancan"
|
9
13
|
class_option :activeadmin, :type => :boolean, :default => true, :desc => "Add code to manage activeadmin gem"
|
10
|
-
class_option :auth_class, :type => :
|
14
|
+
class_option :auth_class, :type => :string, :default => 'User', :desc => "Set the authentication class name"
|
11
15
|
#class_option :formtastic, :type => :boolean, :default => true, :desc => "Copy formtastic files into leosca custom folder (inside project)"
|
12
16
|
#class_option :jquery_ui, :type => :boolean, :default => true, :desc => "To use jQuery ui improvement"
|
13
17
|
#class_option :rspec, :type => :boolean, :default => true, :desc => "Include custom rspec generator and custom templates"
|
@@ -125,7 +129,6 @@ class LeolayGenerator < Rails::Generators::Base
|
|
125
129
|
end
|
126
130
|
I18n.locale = session[:lang]
|
127
131
|
end
|
128
|
-
require "upd_activeadmin"
|
129
132
|
FILE
|
130
133
|
end
|
131
134
|
end
|
@@ -154,7 +157,7 @@ class LeolayGenerator < Rails::Generators::Base
|
|
154
157
|
#puts "File #{file} #{File.exists?(file) ? "" : "does not"} exists!"
|
155
158
|
return unless options.authentication? and File.exists?(file)
|
156
159
|
|
157
|
-
inject_into_class file,
|
160
|
+
inject_into_class file, options[:auth_class] do
|
158
161
|
<<-FILE.gsub(/^ /, '')
|
159
162
|
ROLES = %w[admin manager user guest]
|
160
163
|
scope :with_role, lambda { |role| {:conditions => "roles_mask & \#{2**ROLES.index(role.to_s)} > 0 "} }
|
@@ -174,6 +177,7 @@ class LeolayGenerator < Rails::Generators::Base
|
|
174
177
|
def admin?
|
175
178
|
self.role? 'admin'
|
176
179
|
end
|
180
|
+
attr_accessible :roles
|
177
181
|
FILE
|
178
182
|
end
|
179
183
|
|
@@ -196,13 +200,13 @@ class LeolayGenerator < Rails::Generators::Base
|
|
196
200
|
file = "db/seeds.rb"
|
197
201
|
append_file file do
|
198
202
|
<<-FILE.gsub(/^ /, '')
|
199
|
-
user
|
203
|
+
user=#{options[:auth_class]}.new :email => 'admin@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
|
200
204
|
#{"user.roles=['admin']" if options.authorization?}
|
201
205
|
user.save
|
202
|
-
user
|
206
|
+
user=#{options[:auth_class]}.new :email => 'manager@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
|
203
207
|
#{"user.roles=['manager']" if options.authorization?}
|
204
208
|
user.save
|
205
|
-
user
|
209
|
+
user=#{options[:auth_class]}.new :email => 'user@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
|
206
210
|
#{"user.roles=['user']" if options.authorization?}
|
207
211
|
user.save
|
208
212
|
FILE
|
@@ -338,14 +342,13 @@ class LeolayGenerator < Rails::Generators::Base
|
|
338
342
|
|
339
343
|
def setup_extras
|
340
344
|
copy_file "lib/upd_array.rb", "lib/extras/upd_array.rb"
|
341
|
-
template "lib/upd_activeadmin.rb", "lib/extras/upd_activeadmin.rb"
|
342
345
|
end
|
343
346
|
|
344
347
|
def setup_activeadmin
|
345
|
-
|
346
|
-
|
348
|
+
return unless options.activeadmin? and activeadmin?
|
349
|
+
template "config/initializers/activeadmin_leonardo.rb", "config/initializers/activeadmin_leonardo.rb"
|
350
|
+
copy_file "config/initializers/activeadmin_cancan.rb", "config/initializers/activeadmin_cancan.rb" if options.authorization?
|
347
351
|
template "app/admin/users.rb", "app/admin/#{options[:auth_class].downcase.pluralize}.rb"
|
348
|
-
template "app/views/admin/users/_form.html.erb", "app/views/admin/#{options[:auth_class].downcase.pluralize}/_form.html.erb"
|
349
352
|
|
350
353
|
file = "app/assets/stylesheets/active_admin.css.scss"
|
351
354
|
append_file file do
|
@@ -1,10 +1,11 @@
|
|
1
|
-
ActiveAdmin.register <%= options[:auth_class]
|
2
|
-
menu :if => proc{ can?(:manage, <%= options[:auth_class]
|
3
|
-
controller.authorize_resource
|
1
|
+
ActiveAdmin.register <%= options[:auth_class] %> do
|
2
|
+
menu :if => proc{ can?(:manage, <%= options[:auth_class] %>) }
|
4
3
|
|
5
|
-
config.sort_order = '
|
4
|
+
config.sort_order = 'email_asc'
|
6
5
|
|
7
6
|
controller do
|
7
|
+
load_resource :except => :index
|
8
|
+
authorize_resource
|
8
9
|
def update
|
9
10
|
unless params[:<%= options[:auth_class].downcase %>]['password'] && params[:<%= options[:auth_class].downcase %>]['password'].size > 0
|
10
11
|
params[:<%= options[:auth_class].downcase %>].delete 'password'
|
@@ -18,26 +19,36 @@ ActiveAdmin.register <%= options[:auth_class].capitalize %> do
|
|
18
19
|
|
19
20
|
index do
|
20
21
|
id_column
|
21
|
-
#column :name
|
22
22
|
column :email
|
23
|
-
#column :
|
24
|
-
|
23
|
+
#column :group, :sortable => :group_id
|
24
|
+
column :roles do |user|
|
25
|
+
user.roles.join ", "
|
26
|
+
end
|
25
27
|
column :current_sign_in_at
|
26
28
|
column :current_sign_in_ip
|
27
|
-
|
29
|
+
column :created_at
|
28
30
|
default_actions
|
29
31
|
end
|
30
32
|
|
31
|
-
form
|
33
|
+
form do |f|
|
34
|
+
input_roles = "<li>" <<
|
35
|
+
f.label(:roles) <<
|
36
|
+
<%= options[:auth_class] %>::ROLES.map{|role| check_box_tag("<%= options[:auth_class].downcase %>[roles][]", role, f.object.roles.include?(role)) << ' ' << role.humanize.html_safe }.join(" ") <<
|
37
|
+
hidden_field_tag("<%= options[:auth_class].downcase %>[roles][]") <<
|
38
|
+
"</li>"
|
39
|
+
f.inputs "Account" do
|
40
|
+
f.input :email
|
41
|
+
f.input :password
|
42
|
+
f.input(:password_confirmation) <<
|
43
|
+
input_roles.html_safe
|
44
|
+
end
|
45
|
+
f.buttons
|
46
|
+
end
|
32
47
|
|
33
48
|
show do
|
34
49
|
attributes_table do
|
35
|
-
#row :gruppo do |<%= options[:auth_class].downcase %>|
|
36
|
-
# <%= options[:auth_class].downcase %>.gruppo ? <%= options[:auth_class].downcase %>.gruppo.try(:name) : "Unknown"
|
37
|
-
#end
|
38
|
-
#row :name
|
39
50
|
row :email
|
40
|
-
#row :
|
51
|
+
#row :group
|
41
52
|
row :current_sign_in_at
|
42
53
|
row :last_sign_in_at
|
43
54
|
row :sign_in_count
|
@@ -48,14 +59,12 @@ ActiveAdmin.register <%= options[:auth_class].capitalize %> do
|
|
48
59
|
row :created_at
|
49
60
|
row :updated_at
|
50
61
|
end
|
51
|
-
|
52
62
|
end
|
53
63
|
|
54
64
|
csv do
|
55
65
|
column :email
|
56
66
|
#column("Name") { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.name }
|
57
67
|
#column("Group") { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.group.try(:name) }
|
58
|
-
#column :login_ldap
|
59
68
|
column(I18n.t('attributes.<%= options[:auth_class].downcase %>.roles')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.roles.join ", " }
|
60
69
|
column(I18n.t('attributes.created_at')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.created_at.strftime("%d/%m/%Y") }
|
61
70
|
column(I18n.t('attributes.<%= options[:auth_class].downcase %>.last_sign_in_at')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.last_sign_in_at.strftime("%d/%m/%Y") if <%= options[:auth_class].downcase %>.last_sign_in_at }
|
@@ -0,0 +1,114 @@
|
|
1
|
+
|
2
|
+
module ActiveAdmin
|
3
|
+
module Views
|
4
|
+
#Integrate cancan in default_actions
|
5
|
+
#\lib\active_admin\views\index_as_table.rb
|
6
|
+
class IndexAsTable
|
7
|
+
class IndexTableFor
|
8
|
+
# Adds links to View, Edit and Delete
|
9
|
+
def default_actions(options = {})
|
10
|
+
options = {
|
11
|
+
:name => "",
|
12
|
+
:auth => nil
|
13
|
+
}.merge(options)
|
14
|
+
column options[:name] do |resource|
|
15
|
+
links = ''.html_safe
|
16
|
+
if controller.action_methods.include?('show') && (options[:auth] ? can?(:read, resource) : true)
|
17
|
+
links += link_to I18n.t('active_admin.view'), resource_path(resource), :class => "member_link view_link"
|
18
|
+
end
|
19
|
+
if controller.action_methods.include?('edit') && (options[:auth] ? can?(:update, resource) : true)
|
20
|
+
links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link"
|
21
|
+
end
|
22
|
+
if controller.action_methods.include?('destroy') && (options[:auth] ? can?(:update, resource) : true)
|
23
|
+
links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link"
|
24
|
+
end
|
25
|
+
links
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module ViewHelpers
|
33
|
+
# lib/active_admin/view_helpers/auto_link_helper.rb
|
34
|
+
def auto_link(resource, link_content = nil)
|
35
|
+
content = link_content || display_name(resource)
|
36
|
+
if can?(:read, resource) && registration = active_admin_resource_for(resource.class)
|
37
|
+
begin
|
38
|
+
content = link_to(content, send(registration.route_instance_path, resource))
|
39
|
+
rescue
|
40
|
+
end
|
41
|
+
end
|
42
|
+
content
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Resource
|
47
|
+
module ActionItems
|
48
|
+
private
|
49
|
+
|
50
|
+
# Adds the default action items to each resource
|
51
|
+
def add_default_action_items
|
52
|
+
# New Link on all actions except :new and :show
|
53
|
+
add_action_item :except => [:new, :show] do
|
54
|
+
if controller.action_methods.include?('new') && can?(:create, active_admin_config.resource_class)
|
55
|
+
link_to(I18n.t('active_admin.new_model', :model => active_admin_config.resource_name), new_resource_path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Edit link on show
|
60
|
+
add_action_item :only => :show do
|
61
|
+
if controller.action_methods.include?('edit') && can?(:edit, resource)
|
62
|
+
link_to(I18n.t('active_admin.edit_model', :model => active_admin_config.resource_name), edit_resource_path(resource))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Destroy link on show
|
67
|
+
add_action_item :only => :show do
|
68
|
+
if controller.action_methods.include?("destroy") && can?(:destroy, resource)
|
69
|
+
link_to(I18n.t('active_admin.delete_model', :model => active_admin_config.resource_name),
|
70
|
+
resource_path(resource),
|
71
|
+
:method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# lib/active_admin/resource/menu.rb
|
78
|
+
module Menu
|
79
|
+
# The :if block is evaluated by TabbedNavigation#display_item?
|
80
|
+
def default_menu_options
|
81
|
+
klass = resource_class # avoid variable capture
|
82
|
+
super.merge(:if => proc{ can? :read, klass })
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class ResourceController
|
88
|
+
# lib/active_admin/resource_controller/collection.rb
|
89
|
+
|
90
|
+
# The following doesn't work (see https://github.com/ryanb/cancan/pull/683):
|
91
|
+
#
|
92
|
+
# load_and_authorize_resource
|
93
|
+
# skip_load_resource :only => :index
|
94
|
+
#
|
95
|
+
# If you don't skip loading on #index you will get the exception:
|
96
|
+
#
|
97
|
+
# "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection."
|
98
|
+
#
|
99
|
+
# Add to your activeadmin file:
|
100
|
+
#
|
101
|
+
# controller.load_resource :except => :index
|
102
|
+
# controller.authorize_resource
|
103
|
+
|
104
|
+
# https://github.com/gregbell/active_admin/wiki/Enforce-CanCan-constraints
|
105
|
+
# https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_resource.rb#L80
|
106
|
+
module Collection
|
107
|
+
module BaseCollection
|
108
|
+
def scoped_collection
|
109
|
+
end_of_association_chain.accessible_by(current_ability)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
module Views
|
3
|
+
module Pages
|
4
|
+
#Custom footer
|
5
|
+
#\lib\active_admin\views\pages\base.rb
|
6
|
+
class Base < Arbre::HTML::Document
|
7
|
+
private
|
8
|
+
def build_footer
|
9
|
+
div :id => "footer" do
|
10
|
+
para "#{CONFIG[:application][:name]} #{Rails.env} #{CONFIG[:application][:version]} <%= Time.now.year %>.".html_safe
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#Avoid xml and json from download
|
18
|
+
#\lib\active_admin\views\components\paginated_collection.rb
|
19
|
+
#class PaginatedCollection
|
20
|
+
# def build_download_format_links(formats = [:csv])
|
21
|
+
# links = formats.collect do |format|
|
22
|
+
# link_to format.to_s.upcase, { :format => format}.merge(request.query_parameters.except(:commit, :format))
|
23
|
+
# end
|
24
|
+
# div :class => "download_links" do
|
25
|
+
# text_node [I18n.t('active_admin.download'), links].flatten.join(" ").html_safe
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
#end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
it:
|
4
|
+
errors:
|
5
|
+
messages:
|
6
|
+
expired: "è scaduto ed è necessario richiederne uno nuovo"
|
7
|
+
not_found: "non trovato"
|
8
|
+
already_confirmed: "è già stato confermato, riprova a collegarti"
|
9
|
+
not_locked: "non era bloccato"
|
10
|
+
not_saved:
|
11
|
+
one: "un errore ha impedito il salvataggio di %{resource}:"
|
12
|
+
other: "%{count} errori hanno impedito il salvataggio di %{resource}:"
|
13
|
+
|
14
|
+
devise:
|
15
|
+
failure:
|
16
|
+
already_authenticated: "Sei già autenticato"
|
17
|
+
unauthenticated: "Devi accedere o registrarti per continuare."
|
18
|
+
unconfirmed: "Devi confermare il tuo account per continuare."
|
19
|
+
locked: "Il tuo account è bloccato."
|
20
|
+
invalid: "Indirizzo email o password non validi."
|
21
|
+
invalid_token: "Codice di autenticazione non valido."
|
22
|
+
timeout: "Sessione scaduta, accedere nuovamente per continuare."
|
23
|
+
inactive: "Il tuo account non è stato ancora attivato."
|
24
|
+
sessions:
|
25
|
+
signed_in: "Accesso effettuato con successo."
|
26
|
+
signed_out: "Sei uscito correttamente."
|
27
|
+
passwords:
|
28
|
+
send_instructions: "Riceverai un messaggio email con le istruzioni per reimpostare la tua password entro qualche minuto."
|
29
|
+
updated: "La tua password è stata cambiata. Ora sei collegato."
|
30
|
+
updated_not_active: "La tua password è stata cambiata."
|
31
|
+
send_paranoid_instructions: "Se il tuo indirizzo e-mail esiste nel nostro database, riceverai un link per il recupero della password."
|
32
|
+
confirmations:
|
33
|
+
send_instructions: "Riceverai un messaggio email con le istruzioni per confermare il tuo account entro qualche minuto."
|
34
|
+
send_paranoid_instructions: "Se il tuo indirizzo e-mail esiste nel nostro database, fra pochi minuti riceverai un link con le istruzioni per confermare il tuo account."
|
35
|
+
confirmed: "Il tuo account è stato correttamente confermato. Ora sei collegato."
|
36
|
+
registrations:
|
37
|
+
signed_up: "Iscrizione correttamente eseguita."
|
38
|
+
signed_up_but_unconfirmed: "Un messaggio con il link di conferma è stato inviato al tuo indirizzo email. Dovresti cliccare su quel link per attivare il tuo account."
|
39
|
+
signed_up_but_inactive: "Ti sei registrato con successo. Tuttavia, non è stato possibile effettuare il login perché il tuo account non è ancora stato attivato."
|
40
|
+
signed_up_but_locked: "Ti sei registrato con successo. Tuttavia, non è stato possibile effettuare il login perché il tuo account è bloccato."
|
41
|
+
updated: "Il tuo account è stato aggiornato."
|
42
|
+
update_needs_confirmation: "È stato aggiornato il tuo account con successo, ma abbiamo bisogno di verificare il tuo nuovo indirizzo email. Controlla la tua email e clicca sul link per confermare il nuovo indirizzo email."
|
43
|
+
destroyed: "Arrivederci! L'account è stato cancellato. Speriamo di rivederti presto."
|
44
|
+
unlocks:
|
45
|
+
send_instructions: "Riceverai un messaggio email con le istruzioni per sbloccare il tuo account entro qualche minuto."
|
46
|
+
unlocked: "Il tuo account è stato correttamente sbloccato. Ora sei collegato."
|
47
|
+
send_paranoid_instructions: "Se il tuo indirizzo e-mail esiste nel nostro database, fra pochi minuti riceverai un link con le istruzioni per sbloccare il tuo account."
|
48
|
+
omniauth_callbacks:
|
49
|
+
success: "Sei stato autorizzato dall'account di %{kind}."
|
50
|
+
failure: "Non siamo riusciti ad autoruzzarti da %{kind} perchè '%{reason}'."
|
51
|
+
mailer:
|
52
|
+
confirmation_instructions:
|
53
|
+
subject: "Istruzioni per la conferma"
|
54
|
+
reset_password_instructions:
|
55
|
+
subject: "Istruzioni per reimpostare la password"
|
56
|
+
unlock_instructions:
|
57
|
+
subject: "Istruzioni per sbloccare l'account"
|
@@ -20,7 +20,7 @@ module Rails
|
|
20
20
|
#class_option :remote, :type => :boolean, :default => true, :desc => "Enable ajax. You can also do later set remote to true into index view."
|
21
21
|
#class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
22
22
|
#class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
23
|
-
class_option :auth_class, :type => :
|
23
|
+
class_option :auth_class, :type => :string, :default => 'User', :desc => "Set the authentication class name"
|
24
24
|
class_option :activeadmin, :type => :boolean, :default => true, :desc => "Add code to manage activeadmin gem"
|
25
25
|
|
26
26
|
#Override
|
@@ -46,15 +46,11 @@ module Rails
|
|
46
46
|
attributes.each do |attribute|
|
47
47
|
content << " #{attribute.name}: \"#{attribute.name.humanize}\"#{CRLF}"
|
48
48
|
end
|
49
|
-
content << " op_new: \"New #{singular_table_name}\"#{CRLF}"
|
50
|
-
content << " op_edit: \"Editing #{singular_table_name}\"#{CRLF}"
|
51
|
-
content << " op_edit_multiple: \"Editing #{plural_table_name}\"#{CRLF}"
|
52
|
-
content << " op_copy: \"Creating new #{plural_table_name}\"#{CRLF}"
|
53
|
-
#
|
54
|
-
# content << " op_index: \"Listing #{plural_table_name} belongings to %{parent} %{name}\"#{CRLF}"
|
55
|
-
#else
|
56
|
-
content << " op_index: \"Listing #{plural_table_name}\"#{CRLF}"
|
57
|
-
#end
|
49
|
+
#content << " op_new: \"New #{singular_table_name}\"#{CRLF}"
|
50
|
+
#content << " op_edit: \"Editing #{singular_table_name}\"#{CRLF}"
|
51
|
+
#content << " op_edit_multiple: \"Editing #{plural_table_name}\"#{CRLF}"
|
52
|
+
#content << " op_copy: \"Creating new #{plural_table_name}\"#{CRLF}"
|
53
|
+
#content << " op_index: \"Listing #{plural_table_name}\"#{CRLF}"
|
58
54
|
content
|
59
55
|
end
|
60
56
|
|
@@ -91,9 +87,8 @@ module Rails
|
|
91
87
|
end
|
92
88
|
|
93
89
|
def update_ability_model
|
94
|
-
|
95
|
-
|
96
|
-
inject_into_file file, :before => " end\nend" do
|
90
|
+
return unless authorization?
|
91
|
+
inject_into_file authorization_file, :before => " end\nend" do
|
97
92
|
<<-FILE.gsub(/^ /, '')
|
98
93
|
#can :read, #{class_name} if #{options[:auth_class].downcase}.new_record? #Guest
|
99
94
|
can :read, #{class_name} if #{options[:auth_class].downcase}.role? :guest #Registered guest
|
@@ -145,15 +140,10 @@ module Rails
|
|
145
140
|
<<-FILE.gsub(/^ /, '')
|
146
141
|
|
147
142
|
menu :if => proc{ can?(:read, #{class_name}) }
|
148
|
-
controller.authorize_resource
|
149
143
|
|
150
144
|
controller do
|
151
|
-
|
152
|
-
|
153
|
-
actions_abilities = {'show' => :read, 'new' => :create, 'edit' => :update, 'destroy' => :destroy}
|
154
|
-
prohibited_methods = actions_abilities.keys.select{|m| !can? actions_abilities[m], #{class_name}}
|
155
|
-
super - prohibited_methods
|
156
|
-
end
|
145
|
+
load_resource :except => :index
|
146
|
+
authorize_resource
|
157
147
|
end
|
158
148
|
FILE
|
159
149
|
end if authorization? && File.exists?(file)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_leonardo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Mastrodonato
|
@@ -15,12 +15,28 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-08-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: rails
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
version: 3.1.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activeadmin
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
24
40
|
none: false
|
25
41
|
requirements:
|
26
42
|
- - ">="
|
@@ -32,7 +48,23 @@ dependencies:
|
|
32
48
|
- 0
|
33
49
|
version: 0.4.0
|
34
50
|
type: :runtime
|
35
|
-
version_requirements: *
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: cancan
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 5
|
64
|
+
- 0
|
65
|
+
version: 1.5.0
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
36
68
|
description: This generator help you to create new Rails applications to combine with active admin gem. It generates application structure to easily get the internationalization and authorization.
|
37
69
|
email:
|
38
70
|
- m.mastrodonato@gmail.com
|
@@ -50,12 +82,13 @@ files:
|
|
50
82
|
- lib/generators/leolay/templates/app/admin/users.rb
|
51
83
|
- lib/generators/leolay/templates/app/assets/javascripts/custom.js
|
52
84
|
- lib/generators/leolay/templates/app/helpers/layout_helper.rb
|
53
|
-
- lib/generators/leolay/templates/
|
85
|
+
- lib/generators/leolay/templates/config/initializers/activeadmin_cancan.rb
|
86
|
+
- lib/generators/leolay/templates/config/initializers/activeadmin_leonardo.rb
|
87
|
+
- lib/generators/leolay/templates/config/locales/devise.it.yml
|
54
88
|
- lib/generators/leolay/templates/config/locales/en.yml
|
55
89
|
- lib/generators/leolay/templates/config/locales/it.yml
|
56
90
|
- lib/generators/leolay/templates/config.rb
|
57
91
|
- lib/generators/leolay/templates/lib/development_mail_interceptor.rb
|
58
|
-
- lib/generators/leolay/templates/lib/upd_activeadmin.rb
|
59
92
|
- lib/generators/leolay/templates/lib/upd_array.rb
|
60
93
|
- lib/generators/leolay/templates/styles/active/images/logo.png
|
61
94
|
- lib/generators/leolay/templates/styles/active/images/style/ico_v.png
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<%%= semantic_form_for [:admin, @<%= options[:auth_class].downcase %>] do |f| %>
|
2
|
-
<%%= f.inputs do %>
|
3
|
-
<%%#= f.input :group %>
|
4
|
-
<%%= f.input :email, :input_html => { :maxlength => 100 } %>
|
5
|
-
<%%= f.input :password %>
|
6
|
-
<%%= f.input :password_confirmation %>
|
7
|
-
<li>
|
8
|
-
<%%= f.label :roles %>
|
9
|
-
<%% for role in <%= options[:auth_class].downcase.classify %>::ROLES %>
|
10
|
-
<%%= check_box_tag "<%= options[:auth_class].downcase %>[roles][]", role, @<%= options[:auth_class].downcase %>.roles.include?(role) %>
|
11
|
-
<%%= h role.humanize %>
|
12
|
-
<%% end %>
|
13
|
-
<%%= hidden_field_tag "<%= options[:auth_class].downcase %>[roles][]"%>
|
14
|
-
</li>
|
15
|
-
<%% end %>
|
16
|
-
<%%#= f.inputs "Optional informations" do %>
|
17
|
-
<%%#= f.input :name %>
|
18
|
-
<%%#= f.input :login_ldap %>
|
19
|
-
<%%# end %>
|
20
|
-
<%%= f.buttons :commit %>
|
21
|
-
<%% end %>
|
@@ -1,65 +0,0 @@
|
|
1
|
-
|
2
|
-
module ActiveAdmin
|
3
|
-
module Views
|
4
|
-
module Pages
|
5
|
-
|
6
|
-
#Custom footer
|
7
|
-
#\lib\active_admin\views\pages\base.rb
|
8
|
-
class Base < Arbre::HTML::Document
|
9
|
-
private
|
10
|
-
def build_footer
|
11
|
-
div :id => "footer" do
|
12
|
-
para "#{CONFIG[:application][:name]} #{Rails.env} #{CONFIG[:application][:version]} <%= Time.now.year %>.".html_safe
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
#Avoid xml and json from download
|
20
|
-
#\lib\active_admin\views\components\paginated_collection.rb
|
21
|
-
#class PaginatedCollection
|
22
|
-
# def build_download_format_links(formats = [:csv])
|
23
|
-
# links = formats.collect do |format|
|
24
|
-
# link_to format.to_s.upcase, { :format => format}.merge(request.query_parameters.except(:commit, :format))
|
25
|
-
# end
|
26
|
-
# div :class => "download_links" do
|
27
|
-
# text_node [I18n.t('active_admin.download'), links].flatten.join(" ").html_safe
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
#end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
#class Resource
|
35
|
-
# module ActionItems
|
36
|
-
# private
|
37
|
-
#
|
38
|
-
# # Adds the default action items to each resource
|
39
|
-
# def add_default_action_items
|
40
|
-
# # New Link on all actions except :new and :show
|
41
|
-
# add_action_item :except => [:new, :show] do
|
42
|
-
# if controller.action_methods.include?('new') && can?(:create, eval(active_admin_config.resource_name.classify))
|
43
|
-
# link_to(I18n.t('active_admin.new_model', :model => active_admin_config.resource_name), new_resource_path)
|
44
|
-
# end
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# # Edit link on show
|
48
|
-
# add_action_item :only => :show do
|
49
|
-
# if controller.action_methods.include?('edit') && can?(:edit, resource)
|
50
|
-
# link_to(I18n.t('active_admin.edit_model', :model => active_admin_config.resource_name), edit_resource_path(resource))
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# # Destroy link on show
|
55
|
-
# add_action_item :only => :show do
|
56
|
-
# if controller.action_methods.include?("destroy") && can?(:destroy, resource)
|
57
|
-
# link_to(I18n.t('active_admin.delete_model', :model => active_admin_config.resource_name),
|
58
|
-
# resource_path(resource),
|
59
|
-
# :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'))
|
60
|
-
# end
|
61
|
-
# end
|
62
|
-
# end
|
63
|
-
# end
|
64
|
-
#end
|
65
|
-
end
|