diff --git a/app/models/order.rb b/app/models/order.rb index 7f131de7..8838a499 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -27,6 +27,7 @@ class Order < ApplicationRecord after_save :save_order_articles, :update_price_of_group_orders # Finders + scope :started, -> { where('starts <= ?', Time.now) } scope :open, -> { where(state: 'open').order('ends DESC') } scope :finished, -> { where("orders.state = 'finished' OR orders.state = 'closed'").order('ends DESC') } scope :finished_not_closed, -> { where(state: 'finished').order('ends DESC') } diff --git a/app/views/group_orders/_switch_order.html.haml b/app/views/group_orders/_switch_order.html.haml index efa6e2b3..76443524 100644 --- a/app/views/group_orders/_switch_order.html.haml +++ b/app/views/group_orders/_switch_order.html.haml @@ -1,4 +1,4 @@ -- orders = Order.open.reject{ |order| order == current_order } +- orders = Order.open.started.reject{ |order| order == current_order } - unless orders.empty? %h2= t '.title' %ul.unstyled diff --git a/app/views/shared/_open_orders.html.haml b/app/views/shared/_open_orders.html.haml index 86871c6a..cef00797 100644 --- a/app/views/shared/_open_orders.html.haml +++ b/app/views/shared/_open_orders.html.haml @@ -3,7 +3,8 @@ - if ordergroup.not_enough_apples? .alert = t '.not_enough_apples' - - unless Order.open.empty? + - orders = Order.open.started + - unless orders.empty? %table.table.table-striped %thead %tr @@ -14,7 +15,7 @@ %th.numeric= heading_helper GroupOrder, :price %tbody - total = 0 - - Order.open.each do |order| + - orders.each do |order| %tr %td= link_to_ordering(order) %td= format_date(order.pickup) unless order.pickup.nil?