Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated price policies index to correctly show edit links.

  • Loading branch information...
commit 110557f41f31ac49316f5315d82cf88c1420a31e 1 parent 8bd1bb3
John Gore johntxi authored
4 app/models/price_policy.rb
@@ -120,6 +120,10 @@ def before_create
120 120 self.expire_date=self.class.generate_expire_date(self) unless expire_date
121 121 end
122 122
  123 + def editable?
  124 + !expired? && !assigned_to_order?
  125 + end
  126 +
123 127 # def self.active(product)
124 128 # policies = product.send("#{product.class.name.downcase}_price_policies")
125 129 # max = nil
2  app/views/instrument_price_policies/_table.html.haml
@@ -15,7 +15,7 @@
15 15 - if instrument_price_policies.first == price_policy
16 16 %td.centered{ :rowspan => instrument_price_policies.length }
17 17 %ul.form
18   - - if !editable && price_policy.assigned_to_order?
  18 + - unless instrument_price_policies.all?{|pp| pp.editable?}
19 19 %li.disabled Edit
20 20 %li.disabled Remove
21 21 - else
4 app/views/instrument_price_policies/index.html.haml
@@ -18,11 +18,11 @@
18 18 - else
19 19 %h2 Current Pricing Rules
20 20 %h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
21   - = render :partial => "table", :locals => { :instrument_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
  21 + = render :partial => "table", :locals => { :instrument_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }
22 22
23 23 - unless @next_dates.empty?
24 24 %h2 Upcoming Pricing Rules
25 25 - @next_dates.each do |date|
26 26 - @price_policies = InstrumentPricePolicy.for_date(@instrument, date)
27 27 %h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
28   - = render :partial => "table", :locals => { :instrument_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
  28 + = render :partial => "table", :locals => { :instrument_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
2  app/views/item_price_policies/_table.html.haml
@@ -12,7 +12,7 @@
12 12 - if item_price_policies.first == price_policy
13 13 %td.centered{ :rowspan => item_price_policies.length }
14 14 %ul.form
15   - - if !editable && price_policy.assigned_to_order?
  15 + - unless item_price_policies.all?{|pp| pp.editable?}
16 16 %li.disabled Edit
17 17 %li.disabled Remove
18 18 - else
4 app/views/item_price_policies/index.html.haml
@@ -19,11 +19,11 @@
19 19 - else
20 20 %h2 Current Pricing Rules
21 21 %h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
22   - = render :partial => "table", :locals => { :item_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
  22 + = render :partial => "table", :locals => { :item_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }
23 23
24 24 - unless @next_dates.empty?
25 25 %h2== Upcoming Pricing Rules
26 26 - @next_dates.each do |date|
27 27 - @price_policies = ItemPricePolicy.for_date(@item, date)
28 28 %h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
29   - = render :partial => "table", :locals => { :item_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
  29 + = render :partial => "table", :locals => { :item_price_policies => @price_policies, :url_date => date.strftime("%Y-%m-%d") }
2  app/views/service_price_policies/_table.html.haml
@@ -12,7 +12,7 @@
12 12 - if service_price_policies.first == price_policy
13 13 %td.centered{ :rowspan => service_price_policies.length }
14 14 %ul.form
15   - - if !editable && price_policy.assigned_to_order?
  15 + - unless service_price_policies.all?{|pp| pp.editable?}
16 16 %li.disabled Edit
17 17 %li.disabled Remove
18 18 - else
4 app/views/service_price_policies/index.html.haml
@@ -18,11 +18,11 @@
18 18 - else
19 19 %h2 Current Pricing Rules
20 20 %h3= "Effective: #{human_date(@current_start_date)}, Expires: #{human_date(@current_price_policies.first.expire_date)}"
21   - = render :partial => "table", :locals => { :service_price_policies => @current_price_policies, :editable => false, :url_date => @current_start_date.strftime("%Y-%m-%d") }
  21 + = render :partial => "table", :locals => { :service_price_policies => @current_price_policies, :url_date => @current_start_date.strftime("%Y-%m-%d") }
22 22
23 23 - unless @next_dates.empty?
24 24 %h2 Upcoming Pricing Rules
25 25 - @next_dates.each do |date|
26 26 - @price_policies = ServicePricePolicy.for_date(@service, date)
27 27 %h3= "Effective: #{human_date(date)}, Expires: #{human_date(@price_policies.first.expire_date)}"
28   - = render :partial => "table", :locals => { :service_price_policies => @price_policies, :editable => true, :url_date => date.strftime("%Y-%m-%d") }
  28 + = 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.
Something went wrong with that request. Please try again.