Show only started orders to members for ordering

This commit is contained in:
Patrick Gansterer 2020-02-25 00:38:06 +01:00
parent ab912877c3
commit 739914ad43
3 changed files with 5 additions and 3 deletions

View File

@ -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') }

View File

@ -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

View File

@ -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?