Skip to content
Browse files

esp_auth API too different than esp_permissions....

  • Loading branch information...
1 parent 7d0d0d4 commit c5867772dea438bff10036beb8f49f32e53885e5 @lda lda committed
View
2 Gemfile
@@ -12,7 +12,6 @@ group :default do
gem 'default_value_for'
gem 'el_vfs_client'
gem 'esp-auth'
- gem 'esp-commons'
gem 'formtastic'
gem 'formtastic_datepicker-rails3x', :git => 'git://github.com/kristianmandrup/formtastic_datepicker-rails3x.git'
gem 'has_enum'
@@ -21,6 +20,7 @@ group :default do
gem 'inherited_resources'
gem 'jquery-rails'
gem 'kaminari'
+ gem 'esp-commons'
gem 'rails', :require => false
gem 'russian'
gem 'state_machine'
View
2 app/controllers/manage/application_controller.rb
@@ -1,4 +1,4 @@
-class Manage::ApplicationController < ApplicationController
+class Manage::ApplicationController < InheritedResourcesController
esp_load_and_authorize_resource
before_filter proc { |controller| (controller.action_has_layout = false) if controller.request.xhr? }
View
18 app/models/ability.rb
@@ -31,15 +31,27 @@ def initialize(user)
## app specific
can :manage, Paper do |paper|
- user.manager_of? paper.context
+ paper.context && user.manager_of?(paper.context)
+ end
+
+ can :manage, Paper do |paper|
+ !paper.context && user.manager?
end
can :manage, Document do |document|
- user.document_operator_of? document.context
+ document.context && user.document_operator_of?(document.context)
+ end
+
+ can :manage, Document do |document|
+ !document.context && user.document_operator_of?(document.context)
+ end
+
+ can :manage, Project do |project|
+ project.context && user.project_operator_of?(project.context)
end
can :manage, Project do |project|
- user.project_operator_of? project.context
+ !project.context && user.project_operator_of?(project.context)
end
end
end
View
4 app/views/manage/documents/_fields.html.erb
@@ -1,8 +1,8 @@
<%= form.inputs do %>
<%= form.input :kind, :collection => form.object.class.values_for_select_tag(:kind) %>
- <%= form.input :context, :collection => current_user.available_contexts_for(:document_operator),
+ <%= form.input :context, :collection => current_user.context_tree,
:member_label => ->(c) { ('&nbsp;' * 2 * c.depth + c.title).html_safe },
- :include_blank => t('permissions.not_selected') %>
+ :include_blank => t('commons.not_selected') %>
<%= form.input :number %>
<%= form.input :approved_on, :as => :date_picker, :format => "%d.%m.%Y" %>
<%= form.input :title, :input_html => {:class => 'for_info_path'} %>
View
4 app/views/manage/projects/_fields.html.erb
@@ -1,8 +1,8 @@
<%= form.inputs do %>
<%= form.input :kind, :collection => form.object.class.values_for_select_tag(:kind) %>
- <%= form.input :context, :collection => current_user.available_contexts_for(:project_operator),
+ <%= form.input :context, :collection => current_user.context_tree,
:member_label => ->(c) { ('&nbsp;' * 2 * c.depth + c.title).html_safe },
- :include_blank => t('permissions.not_selected') %>
+ :include_blank => t('commons.not_selected') %>
<%= form.input :title %>
<%= form.input :published_on, :as => :date_picker, :format => "%d.%m.%Y" %>
<%= render :partial => 'manage/papers/attached_file', :locals => { :form => form } %>

0 comments on commit c586777

Please sign in to comment.
Something went wrong with that request. Please try again.