Skip to content

Commit

Permalink
initializer code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptepper committed Jul 11, 2012
1 parent 0646d94 commit 6381d74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
10 changes: 4 additions & 6 deletions config/routes.rb
@@ -1,6 +1,4 @@
ActionController::Routing::Routes.draw do |map|
map.connect 'timesheet/index', :controller => 'timesheet', :action => 'index'
map.connect 'timesheet/context_menu', :controller => 'timesheet', :action => 'context_menu'
map.connect 'timesheet/report.:format', :controller => 'timesheet', :action => 'report'
map.connect 'timesheet/reset', :controller => 'timesheet', :action => 'reset', :conditions => { :method => :delete }
end
match "timesheet/index", :to => "timesheet#index"
match "timesheet/context_menu", :to => "timesheet#context_menu"
match "timesheet/report.:format", :to => "timesheet#report"
match "timesheet/reset", :to => "timesheet#reset", :via => :delete
8 changes: 4 additions & 4 deletions init.rb
Expand Up @@ -9,11 +9,11 @@
end

ActionDispatch::Callbacks.to_prepare do
require_dependency 'principal'
require_dependency 'user'
User.send(:include, TimesheetPlugin::Patches::UserPatch)
require_dependency "project"
require_dependency "principal"
require_dependency "user"

require_dependency 'project'
User.send(:include, TimesheetPlugin::Patches::UserPatch)
Project.send(:include, TimesheetPlugin::Patches::ProjectPatch)
# Needed for the compatibility check
begin
Expand Down
6 changes: 3 additions & 3 deletions lib/timesheet_plugin/patches/user_patch.rb
Expand Up @@ -24,11 +24,11 @@ def allowed_to_on_single_potentially_archived_project?(action, context, options=
return false unless context.allows_to?(action)
# Admin users are authorized for anything else
return true if admin?

roles = roles_for_project_with_potentially_archived_project(context)
return false unless roles
roles.detect {|role| (context.is_public? || role.member?) && role.allowed_to?(action)}

else
allowed_to?(action, context, options)
end
Expand All @@ -54,7 +54,7 @@ def roles_for_project_with_potentially_archived_project(project)
end
roles
end

end
end
end
Expand Down

0 comments on commit 6381d74

Please sign in to comment.