Use an existing hook rather than re-rendering the original view (prevent view_paths.unshift)
This commit is contained in:
parent
096087953d
commit
1f8ad9bf4d
@ -1,9 +1,7 @@
|
|||||||
<%
|
<%
|
||||||
# encoding: utf-8
|
|
||||||
#
|
|
||||||
# Redmine plugin for Document Management System "Features"
|
# Redmine plugin for Document Management System "Features"
|
||||||
#
|
#
|
||||||
# Karel Pičman <karel.picman@kontron.com>
|
# Vít Jonáš <vit.jonas@gmail.com>, Daniel Munn <dan.munn@munnster.co.uk>, Karel Pičman <karel.picman@kontron.com>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
@ -20,21 +18,12 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%# Render the original view %>
|
<% if issue.dmsf_files.any? %>
|
||||||
<% view_paths.unshift Rails.root.join('app/views').to_s %>
|
<br>
|
||||||
<%= render partial: 'my/sidebar' %>
|
<fieldset class="attachments"><legend><%= l(:label_dmsf_file_plural) %></legend>
|
||||||
|
<% issue.dmsf_files.each do |f| %>
|
||||||
<%# DMSF extension do %>
|
<%= link_to h(f.name), static_dmsf_file_url(f, filename: f.name) %>
|
||||||
<% if Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest' %>
|
(<%= number_to_human_size(f.last_revision.size) %>)<br>
|
||||||
<h4><%= l(:label_dmsf_webdav_digest) %></h4>
|
|
||||||
<p>
|
|
||||||
<% token = Token.find_by(user_id: @user.id, action: 'dmsf-webdav-digest') %>
|
|
||||||
<% if token %>
|
|
||||||
<%= l(:label_dmsf_webdav_digest_created_on, distance_of_time_in_words(Time.now, token.created_on)) %>
|
|
||||||
<% else %>
|
|
||||||
<%= l(:label_missing_dmsf_webdav_digest) %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
(<%= link_to l(:button_reset), dmsf_digest_path, remote: true %>)
|
</fieldset>
|
||||||
</p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<%# end %>
|
|
||||||
26
app/views/hooks/redmine_dmsf/_view_mailer_issue.text.erb
Normal file
26
app/views/hooks/redmine_dmsf/_view_mailer_issue.text.erb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<%
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Vít Jonáš <vit.jonas@gmail.com>, Daniel Munn <dan.munn@munnster.co.uk>, Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if issue.dmsf_files.any? %>
|
||||||
|
---<%= l(:label_dmsf_file_plural).ljust(37, '-') %>
|
||||||
|
<% issue.dmsf_files.each do |f| %>
|
||||||
|
<%= f.name %> (<%= number_to_human_size(f.last_revision.size) %>)
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
@ -28,3 +28,15 @@
|
|||||||
</p>
|
</p>
|
||||||
<p><%= pref_fields.check_box :receive_download_notification %></p>
|
<p><%= pref_fields.check_box :receive_download_notification %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if Setting.plugin_redmine_dmsf['dmsf_webdav_authentication'] == 'Digest' %>
|
||||||
|
<p>
|
||||||
|
<label for='webdav_digest_reset'><%= l(:label_dmsf_webdav_digest) %></label>
|
||||||
|
<% token = Token.find_by(user_id: @user.id, action: 'dmsf-webdav-digest') %>
|
||||||
|
<% if token %>
|
||||||
|
<%= l(:label_dmsf_webdav_digest_created_on, distance_of_time_in_words(Time.now, token.created_on)) %>
|
||||||
|
<% else %>
|
||||||
|
<%= l(:label_missing_dmsf_webdav_digest) %>
|
||||||
|
<% end %>
|
||||||
|
(<%= link_to l(:button_reset), dmsf_digest_path, remote: true, id: 'webdav_digest_reset' %>)
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@ -25,13 +25,5 @@
|
|||||||
<%= render partial: 'mailer/issue', locals: { issue: issue, issue_url: issue_url, user: user } %>
|
<%= render partial: 'mailer/issue', locals: { issue: issue, issue_url: issue_url, user: user } %>
|
||||||
|
|
||||||
<%# DMSF extension do %>
|
<%# DMSF extension do %>
|
||||||
<% if issue.dmsf_files.any? %>
|
<%= render partial: 'hooks/redmine_dmsf/view_mailer_issue', locals: { issue: issue } %>
|
||||||
<br>
|
|
||||||
<fieldset class="attachments"><legend><%= l(:label_dmsf_file_plural) %></legend>
|
|
||||||
<% issue.dmsf_files.each do |f| %>
|
|
||||||
<%= link_to h(f.name), static_dmsf_file_url(f, filename: f.name) %>
|
|
||||||
(<%= number_to_human_size(f.last_revision.size) %>)<br>
|
|
||||||
<% end %>
|
|
||||||
</fieldset>
|
|
||||||
<% end %>
|
|
||||||
<%# end %>
|
<%# end %>
|
||||||
|
|||||||
@ -25,10 +25,5 @@
|
|||||||
<%= render partial: 'mailer/issue', locals: { issue: issue, issue_url: issue_url, user: user } %>
|
<%= render partial: 'mailer/issue', locals: { issue: issue, issue_url: issue_url, user: user } %>
|
||||||
|
|
||||||
<%# DMSF extension do %>
|
<%# DMSF extension do %>
|
||||||
<% if issue.dmsf_files.any? %>
|
<%= render partial: 'hooks/redmine_dmsf/view_mailer_issue', locals: { issue: issue } %>
|
||||||
---<%= l(:label_dmsf_file_plural).ljust(37, '-') %>
|
|
||||||
<% issue.dmsf_files.each do |f| %>
|
|
||||||
<%= f.name %> (<%= number_to_human_size(f.last_revision.size) %>)
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<%# end %>
|
<%# end %>
|
||||||
|
|||||||
@ -77,6 +77,7 @@ def require_hooks
|
|||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/base_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/base_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/custom_field_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/custom_field_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/issue_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/issue_view_hooks"
|
||||||
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/mailer_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/my_account_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/my_account_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/search_view_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/views/search_view_hooks"
|
||||||
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/issues_helper_hooks"
|
require "#{File.dirname(__FILE__)}/redmine_dmsf/hooks/helpers/issues_helper_hooks"
|
||||||
|
|||||||
41
lib/redmine_dmsf/hooks/views/mailer_view_hooks.rb
Normal file
41
lib/redmine_dmsf/hooks/views/mailer_view_hooks.rb
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
# User form view hooks
|
||||||
|
|
||||||
|
module RedmineDmsf
|
||||||
|
module Hooks
|
||||||
|
module Views
|
||||||
|
# Mailer view hooks
|
||||||
|
class MailerViewHooks < Redmine::Hook::ViewListener
|
||||||
|
def view_mailer_issue_show_text_bottom(context = {})
|
||||||
|
context[:controller].send :render_to_string,
|
||||||
|
{ partial: 'hooks/redmine_dmsf/view_mailer_issue',
|
||||||
|
locals: { issue: context[:issue] } }
|
||||||
|
end
|
||||||
|
|
||||||
|
def view_mailer_issue_show_html_bottom(context = {})
|
||||||
|
context[:controller].send :render_to_string,
|
||||||
|
{ partial: 'hooks/redmine_dmsf/view_mailer_issue',
|
||||||
|
locals: { issue: context[:issue] } }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -25,10 +25,7 @@ module RedmineDmsf
|
|||||||
# My account view hooks
|
# My account view hooks
|
||||||
class MyAccountViewHooks < Redmine::Hook::ViewListener
|
class MyAccountViewHooks < Redmine::Hook::ViewListener
|
||||||
def view_my_account_preferences(context = {})
|
def view_my_account_preferences(context = {})
|
||||||
return unless context.is_a?(Hash) && context[:user]
|
context[:controller].send :render_to_string, { partial: 'hooks/redmine_dmsf/view_my_account' }
|
||||||
|
|
||||||
context[:controller].send :render_to_string,
|
|
||||||
{ partial: 'hooks/redmine_dmsf/view_my_account', locals: context }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user