lockdown 0.3.4 → 0.3.5
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/History.txt +3 -0
- data/app_generators/lockdown/templates/init.rb +2 -0
- data/lib/lockdown/version.rb +1 -1
- data/rails_generators/lockdown_all/lockdown_all_generator.rb +41 -0
- data/rails_generators/lockdown_all/templates/app/helpers/user_groups_helper.rb +1 -1
- data/rails_generators/lockdown_all/templates/app/helpers/users_helper.rb +1 -1
- data/rails_generators/lockdown_all/templates/app/views/user_groups/_data.html.erb +30 -1
- data/rails_generators/lockdown_all/templates/app/views/users/_data.html.erb +30 -0
- metadata +1 -1
data/History.txt
CHANGED
data/lib/lockdown/version.rb
CHANGED
@@ -118,6 +118,9 @@ class LockdownAllGenerator < Rails::Generator::Base
|
|
118
118
|
rescue
|
119
119
|
puts "Admin User Group... migration exists"
|
120
120
|
end
|
121
|
+
|
122
|
+
add_standard_routes(m)
|
123
|
+
add_permissions(m)
|
121
124
|
end
|
122
125
|
end
|
123
126
|
|
@@ -140,4 +143,42 @@ EOS
|
|
140
143
|
m.file "app/views/#{vw}/edit.html.erb", "app/views/#{vw}/edit.html.erb"
|
141
144
|
m.file "app/views/#{vw}/new.html.erb", "app/views/#{vw}/new.html.erb"
|
142
145
|
end
|
146
|
+
|
147
|
+
def add_standard_routes(m)
|
148
|
+
home = %Q(map.home '', :controller => 'sessions', :action => 'new')
|
149
|
+
login = %Q(map.login '/login', :controller => 'sessions', :action => 'new')
|
150
|
+
logout =%Q(map.logout '/logout', :controller => 'sessions', :action => 'destroy')
|
151
|
+
|
152
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
153
|
+
|
154
|
+
m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
155
|
+
"#{match}\n #{home}\n #{login}\n #{logout}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def add_permissions(m)
|
160
|
+
perms = <<-PERMS
|
161
|
+
|
162
|
+
set_permission :sessions_management, all_methods(:sessions)
|
163
|
+
|
164
|
+
set_permission :users_management, all_methods(:users)
|
165
|
+
|
166
|
+
set_permission :user_groups_management, all_methods(:user_groups)
|
167
|
+
|
168
|
+
set_permission :permissions_management, all_methods(:permissions)
|
169
|
+
|
170
|
+
set_permission :my_account, only_methods(:users, :edit, :update, :show)
|
171
|
+
|
172
|
+
|
173
|
+
set_public_access :sessions_management
|
174
|
+
|
175
|
+
set_protected_access :my_account
|
176
|
+
PERMS
|
177
|
+
|
178
|
+
sentinel = '# Add your configuration below:'
|
179
|
+
|
180
|
+
m.gsub_file 'lib/lockdown/init.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
181
|
+
"#{match}\n#{perms}"
|
182
|
+
end
|
183
|
+
end
|
143
184
|
end
|
@@ -13,7 +13,7 @@ module UserGroupsHelper
|
|
13
13
|
else
|
14
14
|
rvalue = %{<ul id="all_permissions" class="checklist">}
|
15
15
|
@all_permissions.each_with_index do |perm,i|
|
16
|
-
bg =
|
16
|
+
bg = ( i % 2 == 0 ) ? "even" : "odd"
|
17
17
|
input_id = "perm_#{perm.id}"
|
18
18
|
checked = (@user_group.permission_ids.include?(perm.id) ? "checked" : "")
|
19
19
|
bg << "_" << checked if checked.length > 0
|
@@ -58,7 +58,7 @@ module UsersHelper
|
|
58
58
|
# him/herself.
|
59
59
|
#
|
60
60
|
@user_groups_for_user.each_with_index do |ug,i|
|
61
|
-
bg =
|
61
|
+
bg = ( i % 2 == 0 ) ? "even" : "odd"
|
62
62
|
input_id = "ug_#{ug.id}"
|
63
63
|
checked = (@user.user_group_ids.include?(ug.id) ? "checked" : "")
|
64
64
|
bg << "_" << checked if checked.length > 0
|
@@ -1,3 +1,33 @@
|
|
1
|
+
<!--
|
2
|
+
take the style block out. this is duplicated in users/_data.html.erb
|
3
|
+
without this, the user group selection is just no good
|
4
|
+
-->
|
5
|
+
<style>
|
6
|
+
.checklist{
|
7
|
+
overflow: auto;
|
8
|
+
border: 1px solid #ccc;
|
9
|
+
list-style: none;
|
10
|
+
height: 300px;
|
11
|
+
text-align: left;
|
12
|
+
list-style: none;
|
13
|
+
margin-left: 12px;
|
14
|
+
}
|
15
|
+
|
16
|
+
.checklist li{
|
17
|
+
padding-left: 6px;
|
18
|
+
}
|
19
|
+
|
20
|
+
li.even_checked,
|
21
|
+
li.even{
|
22
|
+
background: #DFDFDF;
|
23
|
+
}
|
24
|
+
|
25
|
+
li.even_checked,
|
26
|
+
li.odd_checked{
|
27
|
+
color: red;
|
28
|
+
}
|
29
|
+
</style>
|
30
|
+
|
1
31
|
<p>
|
2
32
|
<b>Name</b><br />
|
3
33
|
<%= user_group_name_value %>
|
@@ -12,4 +42,3 @@
|
|
12
42
|
<%= user_group_users_value %>
|
13
43
|
</p>
|
14
44
|
<% end%>
|
15
|
-
|
@@ -1,3 +1,33 @@
|
|
1
|
+
<!--
|
2
|
+
take the style block out. this is duplicated in users/_data.html.erb
|
3
|
+
without this, the user group selection is just no good
|
4
|
+
-->
|
5
|
+
<style>
|
6
|
+
.checklist{
|
7
|
+
overflow: auto;
|
8
|
+
border: 1px solid #ccc;
|
9
|
+
list-style: none;
|
10
|
+
height: 300px;
|
11
|
+
text-align: left;
|
12
|
+
list-style: none;
|
13
|
+
margin-left: 12px;
|
14
|
+
}
|
15
|
+
|
16
|
+
.checklist li{
|
17
|
+
padding-left: 6px;
|
18
|
+
}
|
19
|
+
|
20
|
+
li.even_checked,
|
21
|
+
li.even{
|
22
|
+
background: #DFDFDF;
|
23
|
+
}
|
24
|
+
|
25
|
+
li.even_checked,
|
26
|
+
li.odd_checked{
|
27
|
+
color: red;
|
28
|
+
}
|
29
|
+
</style>
|
30
|
+
|
1
31
|
<p>
|
2
32
|
<b>First name</b><br />
|
3
33
|
<%= profile_first_name_value %>
|