Add option to restrict ordering when not enough apples.
This commit is contained in:
parent
d3abc03e56
commit
ff4ab44bcc
11 changed files with 104 additions and 28 deletions
|
|
@ -5,6 +5,7 @@ class GroupOrdersController < ApplicationController
|
|||
before_filter :ensure_ordergroup_member
|
||||
before_filter :ensure_open_order, :only => [:new, :create, :edit, :update, :order, :stock_order, :saveOrder]
|
||||
before_filter :ensure_my_group_order, only: [:show, :edit, :update]
|
||||
before_filter :enough_apples?, only: [:new, :create]
|
||||
|
||||
# Index page.
|
||||
def index
|
||||
|
|
@ -88,4 +89,12 @@ class GroupOrdersController < ApplicationController
|
|||
redirect_to group_orders_url, alert: 'Fehlerhafte URL, das ist nicht Deine Bestellung.'
|
||||
end
|
||||
|
||||
def enough_apples?
|
||||
if @ordergroup.not_enough_apples?
|
||||
redirect_to group_orders_url,
|
||||
alert: t('not_enough_apples', scope: 'group_orders.messages', apples: @ordergroup.apples,
|
||||
stop_ordering_under: FoodsoftConfig[:stop_ordering_under])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue