diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb
index 109ae804..08f09370 100644
--- a/app/models/dmsf_file.rb
+++ b/app/models/dmsf_file.rb
@@ -628,9 +628,13 @@ class DmsfFile < ApplicationRecord
def container
return unless dmsf_folder&.system && dmsf_folder.title&.match(/(^\d+)/)
- issue_id = Regexp.last_match(1)
- parent = dmsf_folder.dmsf_folder
- Regexp.last_match(1).constantize.visible.find_by(id: issue_id) if parent&.title&.match(/^\.(.+)s/)
+ id = Regexp.last_match(1).to_i
+ case dmsf_folder.dmsf_folder&.title
+ when '.CRM cases'
+ EasyCrmCase.visible.find_by id: id
+ when '.Issues'
+ Issue.visible.find_by id: id
+ end
end
if defined?(EasyExtensions)
diff --git a/lib/redmine_dmsf.rb b/lib/redmine_dmsf.rb
index 6c22098f..0eed415a 100644
--- a/lib/redmine_dmsf.rb
+++ b/lib/redmine_dmsf.rb
@@ -71,12 +71,7 @@ module RedmineDmsf
def dmsf_webdav?
value = Setting.plugin_redmine_dmsf['dmsf_webdav']
- webdav = value.to_i.positive? || value == 'true'
- if webdav && defined?(EasyExtensions)
- webdav = Redmine::Plugin.installed?('easy_hosting_services') &&
- EasyHostingServices::EasyMultiTenancy.activated?
- end
- webdav
+ value.to_i.positive? || value == 'true'
end
def dmsf_display_notified_recipients?
diff --git a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb
index f436c679..a4528deb 100644
--- a/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb
+++ b/lib/redmine_dmsf/hooks/views/issue_view_hooks.rb
@@ -196,18 +196,18 @@ module RedmineDmsf
end
end
- def attachment_rows(links, issue, controller)
+ def attachment_rows(links, container, controller)
return unless links.any?
html = "
| #{l(:label_dmsf_attachments)} (#{links.count}) |
"
links.each do |dmsf_file, link, _created_at|
- html << attachment_row(dmsf_file, link, issue, controller)
+ html << attachment_row(dmsf_file, link, container, controller)
end
html << ''
html
end
- def attachment_row(dmsf_file, link, issue, controller)
+ def attachment_row(dmsf_file, link, container, controller)
html = link ? +'' : +'
'
# Checkbox
html << ' | '
@@ -273,13 +273,19 @@ module RedmineDmsf
title: l(:title_notifications_not_active_activate), class: 'icon icon-email-add'
end
# Delete
- if issue.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation,
- dmsf_file.project)) || (!link &&
+ if container.attributes_editable? && ((link && User.current.allowed_to?(:file_manipulation,
+ dmsf_file.project)) || (!link &&
User.current.allowed_to?(:file_delete, dmsf_file.project)))
+ back_url = case container.class.name
+ when 'Issue'
+ issue_path container
+ when 'EasyCrmCase'
+ easy_crm_case_path container
+ end
url = if link
- dmsf_link_path link, commit: 'yes', back_url: issue_path(issue)
+ dmsf_link_path link, commit: 'yes', back_url: back_url
else
- dmsf_file_path id: dmsf_file, commit: 'yes', back_url: issue_path(issue)
+ dmsf_file_path id: dmsf_file, commit: 'yes', back_url: back_url
end
html << delete_link(url)
end
diff --git a/test/functional/dmsf_controller_test.rb b/test/functional/dmsf_controller_test.rb
index cfc0e644..53140016 100644
--- a/test/functional/dmsf_controller_test.rb
+++ b/test/functional/dmsf_controller_test.rb
@@ -237,9 +237,6 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
def test_show_webdav_disabled
post '/login', params: { username: 'jsmith', password: 'jsmith' }
- # TODO: with_settings seems to be not working with Easy
- return if defined?(EasyExtensions)
-
with_settings plugin_redmine_dmsf: { 'dmsf_webdav' => nil } do
get "/projects/#{@project1.id}/dmsf"
assert_response :success
diff --git a/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb b/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb
index 3721a160..625f74a5 100644
--- a/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb
+++ b/test/integration/webdav/dmsf_webdav_custom_middleware_test.rb
@@ -44,9 +44,6 @@ class DmsfWebdavCustomMiddlewareTest < RedmineDmsf::Test::IntegrationTest
end
def test_webdav_not_enabled
- # TODO: with_settings seems to be not working with Easy
- return if defined?(EasyExtensions)
-
with_settings plugin_redmine_dmsf: { 'dmsf_webdav' => nil } do
process :options, '/dmsf/webdav'
assert_response :not_found