Skip to content

Commit

Permalink
Updated price policies index to correctly show edit links.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Gore committed May 18, 2011
1 parent 8bd1bb3 commit 110557f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/models/price_policy.rb
Expand Up @@ -120,6 +120,10 @@ def before_create
self.expire_date=self.class.generate_expire_date(self) unless expire_date
end

def editable?
!expired? && !assigned_to_order?
end

# def self.active(product)
# policies = product.send("#{product.class.name.downcase}_price_policies")
# max = nil
Expand Down
2 changes: 1 addition & 1 deletion app/views/instrument_price_policies/_table.html.haml
Expand Up @@ -15,7 +15,7 @@
- if instrument_price_policies.first == price_policy
%td.centered{ :rowspan => instrument_price_policies.length }
%ul.form
- if !editable && price_policy.assigned_to_order?
- unless instrument_price_policies.all?{|pp| pp.editable?}
%li.disabled Edit
%li.disabled Remove
- else
Expand Down
4 changes: 2 additions & 2 deletions app/views/instrument_price_policies/index.html.haml
Expand Up @@ -18,11 +18,11 @@
- else
%h2 Current Pricing Rules
%h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
= render :partial => "table", :locals => { :instrument_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
= render :partial => "table", :locals => { :instrument_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }

- unless @next_dates.empty?
%h2 Upcoming Pricing Rules
- @next_dates.each do |date|
- @price_policies = InstrumentPricePolicy.for_date(@instrument, date)
%h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
= render :partial => "table", :locals => { :instrument_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
= render :partial => "table", :locals => { :instrument_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
2 changes: 1 addition & 1 deletion app/views/item_price_policies/_table.html.haml
Expand Up @@ -12,7 +12,7 @@
- if item_price_policies.first == price_policy
%td.centered{ :rowspan => item_price_policies.length }
%ul.form
- if !editable && price_policy.assigned_to_order?
- unless item_price_policies.all?{|pp| pp.editable?}
%li.disabled Edit
%li.disabled Remove
- else
Expand Down
4 changes: 2 additions & 2 deletions app/views/item_price_policies/index.html.haml
Expand Up @@ -19,11 +19,11 @@
- else
%h2 Current Pricing Rules
%h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
= render :partial => "table", :locals => { :item_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
= render :partial => "table", :locals => { :item_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }

- unless @next_dates.empty?
%h2== Upcoming Pricing Rules
- @next_dates.each do |date|
- @price_policies = ItemPricePolicy.for_date(@item, date)
%h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
= render :partial => "table", :locals => { :item_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
= render :partial => "table", :locals => { :item_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
2 changes: 1 addition & 1 deletion app/views/service_price_policies/_table.html.haml
Expand Up @@ -12,7 +12,7 @@
- if service_price_policies.first == price_policy
%td.centered{ :rowspan => service_price_policies.length }
%ul.form
- if !editable && price_policy.assigned_to_order?
- unless service_price_policies.all?{|pp| pp.editable?}
%li.disabled Edit
%li.disabled Remove
- else
Expand Down
4 changes: 2 additions & 2 deletions app/views/service_price_policies/index.html.haml
Expand Up @@ -18,11 +18,11 @@
- else
%h2 Current Pricing Rules
%h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
= render :partial => "table", :locals => { :service_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
= render :partial => "table", :locals => { :service_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }

- unless @next_dates.empty?
%h2 Upcoming Pricing Rules
- @next_dates.each do |date|
- @price_policies = ServicePricePolicy.for_date(@service, date)
%h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
= render :partial => "table", :locals => { :service_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
= render :partial => "table", :locals => { :service_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }

0 comments on commit 110557f

Please sign in to comment.