From c1264b4f612fb1805513cd3fd1f8ed2fac09ecb3 Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Fri, 24 Mar 2017 12:43:42 +0100 Subject: [PATCH] Trouble with documents/images after upgrade #703 --- app/views/dmsf_files/_links.html.erb | 4 ++- app/views/settings/_dmsf_settings.html.erb | 9 ++++++ config/locales/cs.yml | 3 ++ config/locales/de.yml | 3 ++ config/locales/en.yml | 3 ++ config/locales/es.yml | 3 ++ config/locales/fr.yml | 3 ++ config/locales/it.yml | 3 ++ config/locales/ja.yml | 3 ++ config/locales/pl.yml | 3 ++ config/locales/pt-BR.yml | 3 ++ config/locales/ru.yml | 3 ++ config/locales/sl.yml | 3 ++ config/locales/zh-TW.yml | 3 ++ config/locales/zh.yml | 3 ++ init.rb | 3 +- .../controllers/issues_controller_hooks.rb | 2 +- .../hooks/views/issue_view_hooks.rb | 28 ++++++++++++------- 18 files changed, 72 insertions(+), 13 deletions(-) diff --git a/app/views/dmsf_files/_links.html.erb b/app/views/dmsf_files/_links.html.erb index 2964d1e2..5ddd50c1 100644 --- a/app/views/dmsf_files/_links.html.erb +++ b/app/views/dmsf_files/_links.html.erb @@ -41,11 +41,13 @@ <% end %> <%= " - #{dmsf_file.description}" unless dmsf_file.description.blank? %> (<%= number_to_human_size dmsf_file.last_revision.size %>) - <%= link_to(image_tag('delete.png'), + <% if User.current.allowed_to?(:file_delete, dmsf_file.project) %> + <%= link_to(image_tag('delete.png'), dmsf_file_path(:id => dmsf_file, :commit => 'yes'), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:title_delete)) %> + <% end %> <%= dmsf_file.last_revision.user %>, <%= format_time(dmsf_file.last_revision.updated_at) %>

<% end %> diff --git a/app/views/settings/_dmsf_settings.html.erb b/app/views/settings/_dmsf_settings.html.erb index 62022bc8..719c4f6d 100644 --- a/app/views/settings/_dmsf_settings.html.erb +++ b/app/views/settings/_dmsf_settings.html.erb @@ -128,6 +128,15 @@

+

+ <%= content_tag(:label, l(:label_act_as_attachable)) %> + <%= check_box_tag('settings[dmsf_act_as_attachable]', true, @settings['dmsf_act_as_attachable']) %> + + <%= l(:note_dmsf_act_as_attachable) %>
+ <%= l(:label_default)%>: <%= l(:general_text_No)%> +
+

+
<%= l(:menu_dmsf) %> <%= l(:field_column_names) %> diff --git a/config/locales/cs.yml b/config/locales/cs.yml index b8707c60..219de60b 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -359,3 +359,6 @@ cs: label_webdav_use_project_names: Použít názvy projektů note_webdav_use_project_names: Použít názvy projektů místo identifikátorů pro názvy adresářů. + + label_act_as_attachable: Jako příloha + note_dmsf_act_as_attachable: Umožní přikládat dokumenty k objektům např. úkolům. \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 3d9d029f..41bcef56 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -356,3 +356,6 @@ de: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 4f909279..1c64149c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -359,3 +359,6 @@ en: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index 3194918b..3d024e1b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -359,3 +359,6 @@ es: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1e48b134..f6f33a73 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -359,3 +359,6 @@ fr: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/it.yml b/config/locales/it.yml index 50b1e09d..26a6f60b 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -359,3 +359,6 @@ it: # Italian strings thx 2 Matteo Arceci! label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 4a97a71d..c83de780 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -359,3 +359,6 @@ ja: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 2ee7d34d..9c24a8b3 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -359,3 +359,6 @@ pl: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index e63bf12a..bee83c1c 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -359,3 +359,6 @@ pt-BR: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 7fb2c19f..469536a7 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -359,3 +359,6 @@ ru: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/sl.yml b/config/locales/sl.yml index d7a10f6f..9475c314 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -359,3 +359,6 @@ sl: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 369c869e..2a9acc71 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -359,3 +359,6 @@ zh-TW: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 65aa5a9b..310b33cc 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -359,3 +359,6 @@ zh: label_webdav_use_project_names: Use project name for project folder note_webdav_use_project_names: Use project names instead of project identifier for project folders. + + label_act_as_attachable: Act as attachable + note_dmsf_act_as_attachable: Allows to attach documents to objects e.g. issues. \ No newline at end of file diff --git a/init.rb b/init.rb index cabd4a7d..54d84e5a 100644 --- a/init.rb +++ b/init.rb @@ -51,7 +51,8 @@ Redmine::Plugin.register :redmine_dmsf do 'dmsf_memcached_servers' => '', 'dmsf_webdav_ignore' => '^(\._|\.DS_Store$|Thumbs.db$)', 'dmsf_webdav_disable_versioning' => '^\~\$|\.tmp$', - 'dmsf_keep_documents_locked' => false + 'dmsf_keep_documents_locked' => false, + 'dmsf_act_as_attachable' => false } menu :project_menu, :dmsf, { :controller => 'dmsf', :action => 'show' }, :caption => :menu_dmsf, :before => :documents, :param => :id diff --git a/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb b/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb index a79421d5..2577c68a 100644 --- a/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb +++ b/lib/redmine_dmsf/hooks/controllers/issues_controller_hooks.rb @@ -60,7 +60,7 @@ module RedmineDmsf uploaded_file[:name] = upload.name uploaded_file[:title] = upload.title end - DmsfUploadHelper.commit_files_internal uploaded_files, issue, nil, self + DmsfUploadHelper.commit_files_internal uploaded_files, issue, nil, context[:controller] end end end diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb index 5ff74fa6..f464e28e 100644 --- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb +++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb @@ -27,22 +27,30 @@ module RedmineDmsf def view_issues_form_details_bottom(context={}) if context.is_a?(Hash) && context[:issue] # Add Dmsf upload form - html = "
" - html << '

' - html << "" - html << context[:controller].send(:render_to_string, - {:partial => 'dmsf_upload/form', :locals => { :multiple => true }}) - html << '

' - html << '
' - html.html_safe + issue = context[:issue] + if User.current.allowed_to?(:file_manipulation, issue.project) && + Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] + html = "
" + html << '

' + html << "" + html << context[:controller].send(:render_to_string, + {:partial => 'dmsf_upload/form', :locals => { :multiple => true }}) + html << '

' + html << '
' + html.html_safe + end end end def view_issues_show_description_bottom(context={}) if context.is_a?(Hash) && context[:issue] + # Add list of attached documents issue = context[:issue] - context[:controller].send(:render_to_string, {:partial => 'dmsf_files/links', - :locals => { :dmsf_files => issue.dmsf_files.to_a, :thumbnails => Setting.thumbnails_enabled? }}) + if User.current.allowed_to?(:view_dmsf_files, issue.project) && + Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] + context[:controller].send(:render_to_string, {:partial => 'dmsf_files/links', + :locals => { :dmsf_files => issue.dmsf_files.to_a, :thumbnails => Setting.thumbnails_enabled? }}) + end end end