Skip to content

Commit

Permalink
Release 0.5.4: Modification for Rails 2.1. Bug fix in users controlle…
Browse files Browse the repository at this point in the history
…r template - missing instance var.
  • Loading branch information
Andrew Stone committed Jun 5, 2008
1 parent fa1dd3c commit 326070e
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 37 deletions.
5 changes: 5 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
== 0.5.4 2008-06-05
* Fixed: Issue with helpers in Rails 2.1, @action_name is no longer accessible, must call action_name method.
* Fixed: Issue with users controller, show method not having user_groups_for_user instance variable
* Modified: The end of the lockdown executable now references stonean.com instead of rubyforge site.

== 0.5.3 2008-06-01
* Fixed: Issue with new timestamped based migrations in rails 2.1. Migration templates created were all done within the same second, therefore having the same timestamp, added a sleep call to the next_migration_string to get around the issue.

Expand Down
6 changes: 3 additions & 3 deletions bin/lockdown
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ MSG

puts <<-MSG
\n------------------------------------------------------------
You are now locked down. To open up access to your application
please modify lib/lockdown/init.rb. This is where you'll
add permissions and create user groups.
You are now locked down. To open up access to your
application please modify lib/lockdown/init.rb. This is
where you'll add permissions and create user groups.
To modify the contents of your session and to add access
methods, modify lib/lockdown/session.rb.
Expand Down
2 changes: 1 addition & 1 deletion lib/lockdown/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Lockdown #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 5
TINY = 3
TINY = 4

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down
16 changes: 13 additions & 3 deletions rails_generators/lockdown/lockdown_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ def next_migration_string(padding = 3)

class LockdownGenerator < Rails::Generator::Base
attr_accessor :file_name
attr_accessor :action_name

def initialize(runtime_args, runtime_options = {})
super
if Rails::VERSION::MAJOR >= 2 && Rails::VERSION::MINOR >= 1
@action_name = "action_name"
else
@action_name = "@action_name"
end
end

def manifest
record do |m|
Expand Down Expand Up @@ -47,13 +57,13 @@ def add_management(m)
m.file "app/controllers/user_groups_controller.rb",
"app/controllers/user_groups_controller.rb"

m.file "app/helpers/permissions_helper.rb",
m.template "app/helpers/permissions_helper.rb",
"app/helpers/permissions_helper.rb"

m.file "app/helpers/users_helper.rb",
m.template "app/helpers/users_helper.rb",
"app/helpers/users_helper.rb"

m.file "app/helpers/user_groups_helper.rb",
m.template "app/helpers/user_groups_helper.rb",
"app/helpers/user_groups_helper.rb"

copy_views(m, "users")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def index
# GET /users/1
# GET /users/1.xml
def show
@user_groups_for_user = Lockdown::System.user_groups_assignable_for_user(current_user)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module PermissionsHelper
def permission_name_value
h @permission.name
h @permission.name
end

def permission_access_rights_value
Lockdown::System.access_rights_for_permission(@permission).collect{|r| r}.join("<br/>")
end

def permission_users_value
@permission.all_users.collect{|u| link_to_or_show(u.full_name, u)}.join("<br/>")
def permission_users_value
@permission.all_users.collect{|u| link_to_or_show(u.full_name, u)}.join("<br/>")
end
end
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
module UserGroupsHelper
def user_group_name_value
if @action_name == "show"
if <%= action_name %> == "show"
h @user_group.name
else
text_field_tag "user_group[name]", @user_group.name
end
end
def user_group_permissions_value
if @action_name == "show"
if <%= action_name %> == "show"
@user_group.permissions.collect{|p| p.name + "<br/>"}
else
rvalue = %{<ul id="all_permissions" class="checklist">}
@all_permissions.each_with_index do |perm,i|
bg = ( i % 2 == 0 ) ? "even" : "odd"
input_id = "perm_#{perm.id}"
checked = (@user_group.permission_ids.include?(perm.id) ? "checked" : "")
bg << "_" << checked if checked.length > 0
rvalue << <<-HTML
<li class="#{bg}">
<label id="lbl_#{input_id}" for="#{input_id}" onclick="do_highlight('#{input_id}')">
<input id="#{input_id}" name="#{input_id}" type="checkbox" #{checked}/>&nbsp;&nbsp;#{perm.name}
</label>
</li>
HTML
rvalue = %{<ul id="all_permissions" class="checklist">}
@all_permissions.each_with_index do |perm,i|
bg = ( i % 2 == 0 ) ? "even" : "odd"
input_id = "perm_#{perm.id}"
checked = (@user_group.permission_ids.include?(perm.id) ? "checked" : "")
bg << "_" << checked if checked.length > 0
rvalue << <<-HTML
<li class="#{bg}">
<label id="lbl_#{input_id}" for="#{input_id}" onclick="do_highlight('#{input_id}')">
<input id="#{input_id}" name="#{input_id}" type="checkbox" #{checked}/>&nbsp;&nbsp;#{perm.name}
</label>
</li>
HTML
end
rvalue << "</ul>"
rvalue << "</ul>"
end
end

def user_group_users_value
@user_group.all_users.collect{|u| link_to_or_show(u.full_name, u)}.join("<br/>")
def user_group_users_value
@user_group.all_users.collect{|u| link_to_or_show(u.full_name, u)}.join("<br/>")
end
end
14 changes: 7 additions & 7 deletions rails_generators/lockdown/templates/app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
module UsersHelper
def profile_first_name_value
if @action_name == "show"
if <%= action_name %> == "show"
h @profile.first_name
else
text_field_tag "profile[first_name]", @profile.first_name
end
end
def profile_last_name_value
if @action_name == "show"
if <%= action_name %> == "show"
h @profile.last_name
else
text_field_tag "profile[last_name]", @profile.last_name
end
end

def profile_email_value
if @action_name == "show"
if <%= action_name %> == "show"
h @profile.email
else
text_field_tag "profile[email]", @profile.email
end
end
def user_login_value
if @action_name == "show"
if <%= action_name %> == "show"
h @user.login
else
text_field_tag "user[login]", @user.login
end
end

def user_password_value
if @action_name == "show"
if <%= action_name %> == "show"
h "Hidden for security..."
else
%{<input autocomplete="off" type="password" name="user[password]" id="user_password"/>}
end
end

def user_password_confirmation_value
if @action_name == "show"
if <%= action_name %> == "show"
h "Hidden for security..."
else
%{<input autocomplete="off" type="password" name="user[password_confirmation]" id="user_password_confirmation"/>}
end
end

def user_user_groups_value
if @action_name == "show"
if <%= action_name %> == "show"
@user.user_groups.collect{|ug| ug.name + "<br/>"}
else
rvalue = %{<ul id="all_user_groups" class="checklist">}
Expand Down
2 changes: 1 addition & 1 deletion website/generator.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<h1>Lockdown</h1>
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lockdown"; return false'>
<p>Get Version</p>
<a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.3</a>
<a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.4</a>
</div>
<h2>What</h2>

Expand Down
2 changes: 1 addition & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<h1>Lockdown</h1>
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lockdown"; return false'>
<p>Get Version</p>
<a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.3</a>
<a href="http://rubyforge.org/projects/lockdown" class="numbers">0.5.4</a>
</div>
<h2>What</h2>

Expand Down

0 comments on commit 326070e

Please sign in to comment.