lockdown 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.3.5 2008-04-30
2
+ * Added: Basic configuations to config/lockdown/init.rb when using the generator
3
+
1
4
  == 0.3.4 2008-04-30
2
5
  * Fixed: Addition of require 'lockdown/init' to config file
3
6
 
@@ -78,4 +78,6 @@ Lockdown::System.configure do |c|
78
78
  # :catalog_management is the name of the user group
79
79
  # :category_management and :product_management refer to permission names
80
80
  #
81
+
82
+ # Add your configuration below:
81
83
  end
@@ -2,7 +2,7 @@ module Lockdown #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -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 = row_class(i)
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 = row_class(i)
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 %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone