#95 DMSF tab missing on closed projects

This commit is contained in:
Karel Picman 2013-11-13 15:50:47 +01:00
parent c2117d561a
commit d423d471fe
3 changed files with 143 additions and 139 deletions

View File

@ -33,6 +33,9 @@ class DmsfController < ApplicationController
helper :all helper :all
def show def show
@folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
@file_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project)
unless @folder unless @folder
@subfolders = @project.dmsf_folders.visible @subfolders = @project.dmsf_folders.visible
@files = @project.dmsf_files.visible @files = @project.dmsf_files.visible

View File

@ -109,7 +109,7 @@
<th class="hidden"></th> <th class="hidden"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @subfolders.each do |subfolder| %> <% @subfolders.each do |subfolder| %>
<% locked_for_user = subfolder.locked_for_user? %> <% locked_for_user = subfolder.locked_for_user? %>
<% locked = subfolder.locked? %> <% locked = subfolder.locked? %>
@ -134,60 +134,59 @@
<td class="workflow"></td> <td class="workflow"></td>
<td class="author"><%= h(subfolder.user) %></td> <td class="author"><%= h(subfolder.user) %></td>
<td class="actions"> <td class="actions">
<% if User.current.allowed_to?(:file_approval, @project) %> <% if @folder_manipulation_allowed %>
<div class="right_icon_box" style="width:26px;"> <% if User.current.allowed_to?(:file_approval, @project) %>
<% if subfolder.notification %> <div class="right_icon_box" style="width:26px;">
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf), <% if subfolder.notification %>
"manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project, :folder_id => subfolder)}')", <%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
:title => l(:title_notifications_active_deactivate)) %> "manipulation_link('#{url_for(:action => 'notify_deactivate', :id => @project, :folder_id => subfolder)}')",
<% else %> :title => l(:title_notifications_active_deactivate)) %>
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf), <% else %>
"manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')", <%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
:title => l(:title_notifications_not_active_activate)) %> "manipulation_link('#{url_for(:action => 'notify_activate', :id => @project, :folder_id => subfolder)}')",
<% end %> :title => l(:title_notifications_not_active_activate)) %>
</div> <% end %>
<% end %> </div>
<div class="right_icon_box" style="width: 70px;">
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
<div style="float: left">
<%= link_to(image_tag('edit.png', :class =>'detail_icon'),
{:action => 'edit', :id => @project, :folder_id => subfolder },
:title => l(:link_edit, :title => h(subfolder.title))) unless locked_for_user %>
</div>
<% end %> <% end %>
<div style="float: right; width: 44px;"> <div class="right_icon_box" style="width: 70px;">
<% unless locked_for_user && !User.current.allowed_to?(:force_file_unlock, @project)%> <div style="float: left">
<% if locked %> <%= link_to(image_tag('edit.png', :class =>'detail_icon'),
<% if subfolder.unlockable? %> {:action => 'edit', :id => @project, :folder_id => subfolder },
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf), :title => l(:link_edit, :title => h(subfolder.title))) unless locked_for_user %>
"manipulation_link('#{url_for(:controller => 'dmsf', :action => 'unlock', </div>
:id => @project, :folder_id => subfolder)}')", <div style="float: right; width: 44px;">
:title => l(:title_unlock_file))%> <% unless locked_for_user && !User.current.allowed_to?(:force_file_unlock, @project)%>
<% if locked %>
<% if subfolder.unlockable? %>
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:controller => 'dmsf', :action => 'unlock',
:id => @project, :folder_id => subfolder)}')",
:title => l(:title_unlock_file))%>
<% else %>
<%= image_tag('locked.png', :plugin => :redmine_dmsf,
:title => l(:title_folder_parent_locked, :name => subfolder.lock.reverse[0].folder.title)) %>
<% end %>
<% else %> <% else %>
<%= image_tag('locked.png', :plugin => :redmine_dmsf, <%= link_to_function(image_tag('lock.png', :plugin => :redmine_dmsf),
:title => l(:title_folder_parent_locked, :name => subfolder.lock.reverse[0].folder.title)) %> "manipulation_link('#{url_for(:controller => 'dmsf', :action => 'lock',
<% end %> :id => @project, :folder_id => subfolder)}')",
<% else %> :title => l(:title_lock_file)) %>
<%= link_to_function(image_tag('lock.png', :plugin => :redmine_dmsf), <% end %>
"manipulation_link('#{url_for(:controller => 'dmsf', :action => 'lock', &nbsp;
:id => @project, :folder_id => subfolder)}')", <% end %>
:title => l(:title_lock_file)) %> <%= link_to_function(image_tag('delete.png', :plugin => :redmine_dmsf),
<% end %> "confirmation_link('#{url_for(:action => 'delete', :id => @project, :folder_id => @folder, :delete_folder_id => subfolder)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
&nbsp; :title => l(:title_delete)) unless locked_for_user %>
<% end %> </div>
<% jetzt = Time.now %>
<%= link_to_function(image_tag('delete.png', :plugin => :redmine_dmsf),
"confirmation_link('#{url_for(:action => 'delete', :id => @project, :folder_id => @folder, :delete_folder_id => subfolder)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
:title => l(:title_delete)) unless locked_for_user %>
</div> </div>
</div> <br class="clear" />
<br class="clear" /> <% end %>
</td> </td>
<td class="hidden">0</td> <td class="hidden">0</td>
<td class="hidden">0</td> <td class="hidden">0</td>
</tr> </tr>
<% end %> <% end %>
<% workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).count > 0 %> <% workflows_available = DmsfWorkflow.where(['project_id = ? OR project_id IS NULL', @project.id]).count > 0 %>
<% @files.each do |file| %> <% @files.each do |file| %>
<% unless file.last_revision %> <% unless file.last_revision %>
<% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %> <% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %>
@ -219,8 +218,8 @@
<% end %> <% end %>
</td> </td>
<td class="version"><%= file.last_revision.version %></td> <td class="version"><%= file.last_revision.version %></td>
<td class="workflow"> <td class="workflow">
<% if wf %> <% if wf && @file_manipulation_allowed %>
<%= link_to( <%= link_to(
file.last_revision.workflow_str(false), file.last_revision.workflow_str(false),
log_dmsf_workflow_path( log_dmsf_workflow_path(
@ -235,97 +234,99 @@
</td> </td>
<td class="author"><%= h(file.last_revision.user) %></td> <td class="author"><%= h(file.last_revision.user) %></td>
<td class="actions"> <td class="actions">
<% if User.current.allowed_to?(:file_approval, @project) %> <% if @file_manipulation_allowed %>
<div class="right_icon_box" style="width:26px;"> <% if User.current.allowed_to?(:file_approval, @project) %>
<% if file.notification %> <div class="right_icon_box" style="width:26px;">
<%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf), <% if file.notification %>
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_deactivate', :id => file)}')", <%= link_to_function(image_tag('notify.png', :plugin => :redmine_dmsf),
:title => l(:title_notifications_active_deactivate)) %> "manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_deactivate', :id => file)}')",
<% else %> :title => l(:title_notifications_active_deactivate)) %>
<%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf), <% else %>
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_activate', :id => file)}')", <%= link_to_function(image_tag('notifynot.png', :plugin => :redmine_dmsf),
:title => l(:title_notifications_not_active_activate)) %> "manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'notify_activate', :id => file)}')",
<% end %> :title => l(:title_notifications_not_active_activate)) %>
<% case file.last_revision.workflow %> <% end %>
<% when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL %> <% case file.last_revision.workflow %>
<% if wf %> <% when DmsfWorkflow::STATE_WAITING_FOR_APPROVAL %>
<% assignments = wf.next_assignments(file.last_revision.id) %> <% if wf %>
<% index = assignments.find_index{|assignment| assignment.user_id == User.current.id} if assignments %> <% assignments = wf.next_assignments(file.last_revision.id) %>
<% if index %> <% index = assignments.find_index{|assignment| assignment.user_id == User.current.id} if assignments %>
<%= link_to( <% if index %>
image_tag('waiting_for_approval.png', :plugin => :redmine_dmsf), <%= link_to(
action_dmsf_workflow_path( image_tag('waiting_for_approval.png', :plugin => :redmine_dmsf),
:project_id => @project.id, action_dmsf_workflow_path(
:id => wf.id, :project_id => @project.id,
:dmsf_workflow_step_assignment_id => assignments[index].id, :id => wf.id,
:dmsf_file_revision_id => file.last_revision.id), :dmsf_workflow_step_assignment_id => assignments[index].id,
:title => l(:title_waiting_for_approval), :dmsf_file_revision_id => file.last_revision.id),
:remote => true) %> :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 %>
<% else %> <% 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) %> <%= 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 %> <% end %>
<% else %> <% when DmsfWorkflow::STATE_APPROVED %>
<%= 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) %> <%= image_tag('approved.png', :title => l(:title_approved), :plugin => :redmine_dmsf) %>
<% end %> <% when DmsfWorkflow::STATE_ASSIGNED %>
<% when DmsfWorkflow::STATE_APPROVED %> <% if User.current && (file.last_revision.dmsf_workflow_assigned_by == User.current.id) && wf %>
<%= image_tag('approved.png', :title => l(:title_approved), :plugin => :redmine_dmsf) %> <%= link_to_function(image_tag('assigned.png', :plugin => :redmine_dmsf),
<% when DmsfWorkflow::STATE_ASSIGNED %> "manipulation_link('#{start_dmsf_workflow_path(
<% if User.current && (file.last_revision.dmsf_workflow_assigned_by == User.current.id) && wf %> :id => file.last_revision.dmsf_workflow_id,
<%= link_to_function(image_tag('assigned.png', :plugin => :redmine_dmsf), :dmsf_file_revision_id => file.last_revision.id)}')",
"manipulation_link('#{start_dmsf_workflow_path( :title => l(:label_dmsf_wokflow_action_start)) %>
:id => file.last_revision.dmsf_workflow_id, <% else %>
:dmsf_file_revision_id => file.last_revision.id)}')", <%= image_tag('assigned.png', :title => l(:label_dmsf_wokflow_action_start), :plugin => :redmine_dmsf) %>
:title => l(:label_dmsf_wokflow_action_start)) %> <% end %>
<% else %> <% when DmsfWorkflow::STATE_REJECTED %>
<%= image_tag('assigned.png', :title => l(:label_dmsf_wokflow_action_start), :plugin => :redmine_dmsf) %> <%= image_tag('rejected.png', :title => l(:title_rejected), :plugin => :redmine_dmsf) %>
<% end %> <% else %>
<% when DmsfWorkflow::STATE_REJECTED %> <% if workflows_available %>
<%= image_tag('rejected.png', :title => l(:title_rejected), :plugin => :redmine_dmsf) %> <%= link_to(
<% else %> image_tag('none.png', :plugin => :redmine_dmsf),
<% if workflows_available %> assign_dmsf_workflow_path(
<%= link_to( :project_id => @project.id,
image_tag('none.png', :plugin => :redmine_dmsf), :dmsf_file_revision_id => file.last_revision.id),
assign_dmsf_workflow_path( :title => l(:label_dmsf_wokflow_action_assign),
:project_id => @project.id, :remote => true) %>
:dmsf_file_revision_id => file.last_revision.id), <% end %>
:title => l(:label_dmsf_wokflow_action_assign), <% end %>
:remote => true) %> </div>
<% end %>
<% end %>
</div>
<% end %>
<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)%>
<% if locked %>
<% if file.unlockable? %>
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'unlock', :id => file)}')",
:title => l(:title_unlock_file))%>
<% else %>
<%= image_tag('locked.png', :plugin => :redmine_dmsf,
:title => l(:title_file_parent_locked, :name => file.folder.lock.reverse[0].folder.title)) %>
<% end%>
<% else %>
<%= link_to_function(image_tag('lock.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'lock', :id => file)}')",
:title => l(:title_lock_file)) %>
<% end %>
&nbsp;
<% end %> <% end %>
<% if User.current.allowed_to?(:file_manipulation, @project) && !locked_for_user %> <div class="right_icon_box" style="width: 70px">
<%= link_to_function(image_tag('delete.png', :plugin => :redmine_dmsf), <div style="float: left">
"confirmation_link('#{url_for(:controller => 'dmsf_files', :action => 'delete', :id => file)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')", <%= link_to(image_tag('filedetails.png', :plugin => :redmine_dmsf, :class =>'detail_icon'),
:title => l(:title_delete)) %> {:controller => 'dmsf_files', :action => :show, :id => file },
<% end %> :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)%>
<% if locked %>
<% if file.unlockable? %>
<%= link_to_function(image_tag('unlock.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'unlock', :id => file)}')",
:title => l(:title_unlock_file))%>
<% else %>
<%= image_tag('locked.png', :plugin => :redmine_dmsf,
:title => l(:title_file_parent_locked, :name => file.folder.lock.reverse[0].folder.title)) %>
<% end%>
<% else %>
<%= link_to_function(image_tag('lock.png', :plugin => :redmine_dmsf),
"manipulation_link('#{url_for(:controller => 'dmsf_files', :action => 'lock', :id => file)}')",
:title => l(:title_lock_file)) %>
<% end %>
&nbsp;
<% end %>
<% unless locked_for_user %>
<%= link_to_function(image_tag('delete.png', :plugin => :redmine_dmsf),
"confirmation_link('#{url_for(:controller => 'dmsf_files', :action => 'delete', :id => file)}', '#{l(:question_do_you_really_want_to_delete_this_entry)}')",
:title => l(:title_delete)) %>
<% end %>
</div>
</div> </div>
</div> <br class="clear" />
<br class="clear" /> <% end %>
</td> </td>
<td class="hidden">1</td> <td class="hidden">1</td>
<td class="hidden"><%= file.last_revision.size %></td> <td class="hidden"><%= file.last_revision.size %></td>
@ -411,5 +412,5 @@ sUrl = "jquery.dataTables/#{I18n.locale.to_s.downcase}.json" if I18n.locale && !
</script> </script>
<% end %> <% end %>
<%= render(:partial => 'multi_upload') if (User.current.allowed_to?(:file_manipulation, @project) && !@locked_for_user) %> <%= render(:partial => 'multi_upload') if (@file_manipulation_allowed && !@locked_for_user) %>
<br/> <br/>

View File

@ -49,10 +49,10 @@ Redmine::Plugin.register :redmine_dmsf do
activity_provider :dmsf_files, :class_name => 'DmsfFileRevision', :default => true activity_provider :dmsf_files, :class_name => 'DmsfFileRevision', :default => true
project_module :dmsf do project_module :dmsf do
permission :view_dmsf_folders, {:dmsf => [:show], :dmsf_folders_copy => [:new, :copy_to, :move_to]} 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 :user_preferences, {:dmsf_state => [:user_pref_save]}
permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email], permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email],
:dmsf_files => [:show], :dmsf_files_copy => [:new, :create, :move]} :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 :folder_manipulation, {:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root, :lock, :unlock]}
permission :file_manipulation, {:dmsf_files => [:create_revision, :delete, :lock, :unlock], permission :file_manipulation, {:dmsf_files => [:create_revision, :delete, :lock, :unlock],
:dmsf_upload => [:upload_files, :upload_file, :commit_files]} :dmsf_upload => [:upload_files, :upload_file, :commit_files]}
@ -60,7 +60,7 @@ Redmine::Plugin.register :redmine_dmsf do
:dmsf => [: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]} :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 :force_file_unlock, {}
end end
# Administration menu extension # Administration menu extension
Redmine::MenuManager.map :admin_menu do |menu| Redmine::MenuManager.map :admin_menu do |menu|