#187 - Approval workflow permissions
This commit is contained in:
parent
5a2d5bfbde
commit
28d7b8d07a
@ -35,6 +35,7 @@ class DmsfController < ApplicationController
|
||||
def show
|
||||
@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
|
||||
@file_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
|
||||
@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project)
|
||||
|
||||
unless @folder
|
||||
@subfolders = @project.dmsf_folders.visible
|
||||
|
||||
@ -23,7 +23,7 @@ class DmsfWorkflowsController < ApplicationController
|
||||
before_filter :find_workflow, :except => [:create, :new, :index, :assign, :assignment]
|
||||
before_filter :find_project, :except => [:start]
|
||||
before_filter :authorize_global
|
||||
before_filter :authorize_custom, :except => [:assignment, :start, :new_action]
|
||||
before_filter :authorize_custom, :except => [:assignment, :start, :new_action]
|
||||
|
||||
def index
|
||||
if @project
|
||||
|
||||
@ -134,20 +134,18 @@
|
||||
<td class="workflow"></td>
|
||||
<td class="author"><%= h(subfolder.user) %></td>
|
||||
<td class="actions">
|
||||
<% if @folder_manipulation_allowed %>
|
||||
<% if User.current.allowed_to?(:file_approval, @project) %>
|
||||
<div class="right_icon_box" style="width:26px;">
|
||||
<% if subfolder.notification %>
|
||||
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project, :folder_id => subfolder)}')",
|
||||
:title => l(:title_notifications_active_deactivate)) %>
|
||||
<% else %>
|
||||
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')",
|
||||
:title => l(:title_notifications_not_active_activate)) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @folder_manipulation_allowed %>
|
||||
<div class="right_icon_box" style="width:26px;">
|
||||
<% if subfolder.notification %>
|
||||
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project, :folder_id => subfolder)}')",
|
||||
:title => l(:title_notifications_active_deactivate)) %>
|
||||
<% else %>
|
||||
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')",
|
||||
:title => l(:title_notifications_not_active_activate)) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="right_icon_box" style="width: 70px;">
|
||||
<div style="float: left">
|
||||
<%= link_to(image_tag('edit.png', :class =>'detail_icon'),
|
||||
@ -234,74 +232,72 @@
|
||||
</td>
|
||||
<td class="author"><%= h(file.last_revision.user) %></td>
|
||||
<td class="actions">
|
||||
<% if @file_manipulation_allowed %>
|
||||
<% if User.current.allowed_to?(:file_approval, @project) %>
|
||||
<div class="right_icon_box" style="width:26px;">
|
||||
<% if file.notification %>
|
||||
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_deactivate', :id => file)}')",
|
||||
:title => l(:title_notifications_active_deactivate)) %>
|
||||
<% else %>
|
||||
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_activate', :id => file)}')",
|
||||
:title => l(:title_notifications_not_active_activate)) %>
|
||||
<% end %>
|
||||
<% case file.last_revision.workflow %>
|
||||
<% when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL %>
|
||||
<% if wf %>
|
||||
<% assignments = wf.next_assignments(file.last_revision.id) %>
|
||||
<% index = assignments.find_index{|assignment| assignment.user_id == User.current.id} if assignments %>
|
||||
<% if index %>
|
||||
<%= link_to(
|
||||
image_tag('waiting_for_approval.png', :plugin => :redmine_dmsf),
|
||||
action_dmsf_workflow_path(
|
||||
:project_id => @project.id,
|
||||
:id => wf.id,
|
||||
:dmsf_workflow_step_assignment_id => assignments[index].id,
|
||||
:dmsf_file_revision_id => file.last_revision.id),
|
||||
:title => l(:title_waiting_for_approval),
|
||||
:remote => true) %>
|
||||
<% else %>
|
||||
<%= image_tag('waiting_for_approval.png', :title => "#{l(:label_dmsf_wokflow_action_approve)} #{l(:label_dmsf_wokflow_action_reject)} #{l(:label_dmsf_wokflow_action_delegate)}", :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
<% if @file_manipulation_allowed %>
|
||||
<div class="right_icon_box" style="width:26px;">
|
||||
<% if file.notification %>
|
||||
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_deactivate', :id => file)}')",
|
||||
:title => l(:title_notifications_active_deactivate)) %>
|
||||
<% else %>
|
||||
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_activate', :id => file)}')",
|
||||
:title => l(:title_notifications_not_active_activate)) %>
|
||||
<% end %>
|
||||
<% case file.last_revision.workflow %>
|
||||
<% when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL %>
|
||||
<% if wf %>
|
||||
<% assignments = wf.next_assignments(file.last_revision.id) %>
|
||||
<% index = assignments.find_index{|assignment| assignment.user_id == User.current.id} if assignments %>
|
||||
<% if index %>
|
||||
<%= link_to(
|
||||
image_tag('waiting_for_approval.png', :plugin => :redmine_dmsf),
|
||||
action_dmsf_workflow_path(
|
||||
:project_id => @project.id,
|
||||
:id => wf.id,
|
||||
:dmsf_workflow_step_assignment_id => assignments[index].id,
|
||||
:dmsf_file_revision_id => file.last_revision.id),
|
||||
:title => l(:title_waiting_for_approval),
|
||||
:remote => true) %>
|
||||
<% else %>
|
||||
<%= image_tag('waiting_for_approval.png', :title => "#{l(:label_dmsf_wokflow_action_approve)} #{l(:label_dmsf_wokflow_action_reject)} #{l(:label_dmsf_wokflow_action_delegate)}", :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
<% when DmsfWorkflow::STATE_APPROVED %>
|
||||
<%= image_tag('approved.png', :title => l(:title_approved), :plugin => :redmine_dmsf) %>
|
||||
<% when DmsfWorkflow::STATE_ASSIGNED %>
|
||||
<% if User.current && (file.last_revision.dmsf_workflow_assigned_by == User.current.id) && wf %>
|
||||
<%= link_to_function(image_tag('assigned.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{start_dmsf_workflow_path(
|
||||
:id => file.last_revision.dmsf_workflow_id,
|
||||
:dmsf_file_revision_id => file.last_revision.id)}')",
|
||||
:title => l(:label_dmsf_wokflow_action_start)) %>
|
||||
<% else %>
|
||||
<%= image_tag('assigned.png', :title => l(:label_dmsf_wokflow_action_start), :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
<% when DmsfWorkflow::STATE_REJECTED %>
|
||||
<%= image_tag('rejected.png', :title => l(:title_rejected), :plugin => :redmine_dmsf) %>
|
||||
<% else %>
|
||||
<% if workflows_available %>
|
||||
<%= link_to(
|
||||
image_tag('none.png', :plugin => :redmine_dmsf),
|
||||
assign_dmsf_workflow_path(
|
||||
:project_id => @project.id,
|
||||
:dmsf_file_revision_id => file.last_revision.id),
|
||||
:title => l(:label_dmsf_wokflow_action_assign),
|
||||
:remote => true) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= image_tag('waiting_for_approval.png', :title => "#{l(:label_dmsf_wokflow_action_approve)} #{l(:label_dmsf_wokflow_action_reject)} #{l(:label_dmsf_wokflow_action_delegate)}", :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
<% when DmsfWorkflow::STATE_APPROVED %>
|
||||
<%= image_tag('approved.png', :title => l(:title_approved), :plugin => :redmine_dmsf) %>
|
||||
<% when DmsfWorkflow::STATE_ASSIGNED %>
|
||||
<% if User.current && (file.last_revision.dmsf_workflow_assigned_by == User.current.id) && wf %>
|
||||
<%= link_to_function(image_tag('assigned.png', :plugin => :redmine_dmsf),
|
||||
"manipulation_link('#{start_dmsf_workflow_path(
|
||||
:id => file.last_revision.dmsf_workflow_id,
|
||||
:dmsf_file_revision_id => file.last_revision.id)}')",
|
||||
:title => l(:label_dmsf_wokflow_action_start)) %>
|
||||
<% else %>
|
||||
<%= image_tag('assigned.png', :title => l(:label_dmsf_wokflow_action_start), :plugin => :redmine_dmsf) %>
|
||||
<% end %>
|
||||
<% when DmsfWorkflow::STATE_REJECTED %>
|
||||
<%= image_tag('rejected.png', :title => l(:title_rejected), :plugin => :redmine_dmsf) %>
|
||||
<% else %>
|
||||
<% if workflows_available %>
|
||||
<%= link_to(
|
||||
image_tag('none.png', :plugin => :redmine_dmsf),
|
||||
assign_dmsf_workflow_path(
|
||||
:project_id => @project.id,
|
||||
:dmsf_file_revision_id => file.last_revision.id),
|
||||
:title => l(:label_dmsf_wokflow_action_assign),
|
||||
:remote => true) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="right_icon_box" style="width: 70px">
|
||||
<div style="float: left">
|
||||
<%= link_to(image_tag('filedetails.png', :plugin => :redmine_dmsf, :class =>'detail_icon'),
|
||||
{:controller => 'dmsf_files', :action => :show, :id => file },
|
||||
:title => l(:link_details, :title =>h(file.last_revision.title))) %>
|
||||
</div>
|
||||
<div style="float: right; width: 44px;">
|
||||
<% unless locked_for_user && !User.current.allowed_to?(:force_file_unlock, @project)%>
|
||||
<div style="float: right; width: 44px;">
|
||||
<% if !locked_for_user || @force_file_unlock_allowed %>
|
||||
<% if locked %>
|
||||
<% if file.unlockable? %>
|
||||
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf),
|
||||
|
||||
32
init.rb
32
init.rb
@ -50,17 +50,27 @@ Redmine::Plugin.register :redmine_dmsf do
|
||||
activity_provider :dmsf_files, :class_name => 'DmsfFileRevision', :default => true
|
||||
|
||||
project_module :dmsf do
|
||||
permission :view_dmsf_folders, {:dmsf => [:show], :dmsf_folders_copy => [:new, :copy_to, :move_to]}, :read => true
|
||||
permission :user_preferences, {:dmsf_state => [:user_pref_save]}
|
||||
permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email],
|
||||
:dmsf_files => [:show], :dmsf_files_copy => [:new, :create, :move]}, :read => true
|
||||
permission :folder_manipulation, {:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root, :lock, :unlock]}
|
||||
permission :file_manipulation, {:dmsf_files => [:create_revision, :delete, :lock, :unlock],
|
||||
:dmsf_upload => [:upload_files, :upload_file, :commit_files]}
|
||||
permission :file_approval, {:dmsf_files => [:delete_revision, :notify_activate, :notify_deactivate],
|
||||
:dmsf => [:notify_activate, :notify_deactivate],
|
||||
:dmsf_workflows => [:index, :new, :create, :destroy, :edit, :add_step, :remove_step, :reorder_steps, :update, :start, :assign, :assignment, :action, :new_action, :log, :autocomplete_for_user]}
|
||||
permission :force_file_unlock, {}
|
||||
permission :view_dmsf_folders,
|
||||
{:dmsf => [:show],
|
||||
:dmsf_folders_copy => [:new, :copy_to, :move_to]},
|
||||
:read => true
|
||||
permission :user_preferences,
|
||||
{:dmsf_state => [:user_pref_save]}
|
||||
permission :view_dmsf_files,
|
||||
{:dmsf => [:entries_operation, :entries_email],
|
||||
:dmsf_files => [:show],
|
||||
:dmsf_files_copy => [:new, :create, :move],
|
||||
:dmsf_workflows => [:log]},
|
||||
:read => true
|
||||
permission :folder_manipulation,
|
||||
{:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root, :lock, :unlock, :notify_activate, :notify_deactivate]}
|
||||
permission :file_manipulation,
|
||||
{:dmsf_files => [:create_revision, :delete, :lock, :unlock, :delete_revision, :notify_activate, :notify_deactivate],
|
||||
:dmsf_upload => [:upload_files, :upload_file, :commit_files],
|
||||
:dmsf_workflows => [:action, :new_action, :autocomplete_for_user, :start, :assign, :assignment]}
|
||||
permission :manage_workflows,
|
||||
{:dmsf_workflows => [:index, :new, :create, :destroy, :edit, :add_step, :remove_step, :reorder_steps, :update]}
|
||||
permission :force_file_unlock, {}
|
||||
end
|
||||
|
||||
# Administration menu extension
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user