Ported the basics for the Rate form from the Budget plugin. #1923

This commit is contained in:
Eric Davis
2009-01-21 12:15:44 -08:00
parent 256627d2a3
commit 05501f3eb6
+38 -1
View File
@@ -1,6 +1,6 @@
# Hooks to attach to the Redmine Projects.
class RateProjectHook < Redmine::Hook::ViewListener
def protect_against_forgery?
false
end
@@ -14,5 +14,42 @@ class RateProjectHook < Redmine::Hook::ViewListener
return "<th>#{l(:rate_label_rate)} #{l(:rate_label_currency)}</td>"
end
# Renders an AJAX from to update the member's billing rate
#
# Context:
# * :project => Current project
# * :member => Current Member record
#
def view_projects_settings_members_table_row(context = { })
member = context[:member]
project = context[:project]
rate = Rate.for(member.user, project)
url = {
:controller => 'rates',
:action => 'create',
:method => :post,
:protocol => Setting.protocol,
:host => Setting.host_name
}
# Build a form_remote_tag by hand since this isn't in the scope of a controller
# and url_rewriter doesn't like that fact.
form = form_tag(url, :onsubmit => remote_function(:url => url,
:host => Setting.host_name,
:protocol => Setting.protocol,
:form => true,
:method => 'post',
:return => 'false' )+ '; return false;')
form << text_field(:rate, :amount)
form << hidden_field(:rate,:date_in_effect, :value => Date.today.to_s)
form << hidden_field(:rate, :project_id, :value => project.id)
form << hidden_field(:rate, :user_id, :value => member.user.id)
form << hidden_field_tag("back_url", url_for(:controller => 'projects', :action => 'settings', :id => project, :tab => 'members', :protocol => Setting.protocol, :host => Setting.host_name))
form << submit_tag(l(:rate_label_set_rate), :class => "small")
return content_tag(:td, form, :align => 'center' )
end
end