make apple points optional

a next step would be to move this to a plugin
This commit is contained in:
wvengen 2014-02-25 10:53:28 +01:00
parent f71b78665e
commit 3f032e5dd9
6 changed files with 11 additions and 5 deletions

View file

@ -85,7 +85,8 @@ class Ordergroup < Group
# The restriction can be deactivated for each ordergroup. # The restriction can be deactivated for each ordergroup.
# Only ordergroups, which have participated in more than 5 orders in total and more than 2 orders in apple time period # Only ordergroups, which have participated in more than 5 orders in total and more than 2 orders in apple time period
def not_enough_apples? def not_enough_apples?
FoodsoftConfig[:stop_ordering_under].present? and FoodsoftConfig[:use_apple_points] and
FoodsoftConfig[:stop_ordering_under].present? and
!ignore_apple_restriction and !ignore_apple_restriction and
apples < FoodsoftConfig[:stop_ordering_under] and apples < FoodsoftConfig[:stop_ordering_under] and
group_orders.count > 5 and group_orders.count > 5 and

View file

@ -5,7 +5,8 @@
= f.input :contact_person = f.input :contact_person
= f.input :contact_phone = f.input :contact_phone
= f.input :contact_address = f.input :contact_address
= f.input :ignore_apple_restriction, :label => false, :inline_label => true - if FoodsoftConfig[:use_apple_points]
= f.input :ignore_apple_restriction, :label => false, :inline_label => true
.form-actions .form-actions
= f.button :submit = f.button :submit
= link_to t('ui.or_cancel'), :back = link_to t('ui.or_cancel'), :back

View file

@ -27,7 +27,7 @@
= render :partial => 'shared/open_orders', :locals => {:ordergroup => current_user.ordergroup} = render :partial => 'shared/open_orders', :locals => {:ordergroup => current_user.ordergroup}
// Stats // Stats
- if current_user.ordergroup - if current_user.ordergroup and FoodsoftConfig[:use_apple_points]
%section %section
%h2= t '.ordergroup.title' %h2= t '.ordergroup.title'
= render :partial => "apple_bar", :locals => {:apple_bar => AppleBar.new(current_user.ordergroup)} = render :partial => "apple_bar", :locals => {:apple_bar => AppleBar.new(current_user.ordergroup)}

View file

@ -13,6 +13,6 @@
- members = group.users - members = group.users
= "(#{members.size})" = "(#{members.size})"
= members.collect{|u| show_user(u)}.join(", ") = members.collect{|u| show_user(u)}.join(", ")
- unless group.is_a?(Workgroup) - if group.is_a?(Ordergroup) and FoodsoftConfig[:use_apple_points]
%dt= t '.apple_limit' %dt= t '.apple_limit'
%dd= group.ignore_apple_restriction ? t('.deactivated') : t('.activated') %dd= group.ignore_apple_restriction ? t('.deactivated') : t('.activated')

View file

@ -48,6 +48,9 @@ default: &defaults
# Comment out this option to activate this restriction # Comment out this option to activate this restriction
# stop_ordering_under: 75 # stop_ordering_under: 75
# Comment out to completely hide apple points (be sure to comment stop_ordering_under)
# use_apple_points: false
# ordergroups can only order when their balance is higher than or equal to this # ordergroups can only order when their balance is higher than or equal to this
# not fully enforced right now, since the check is only client-side # not fully enforced right now, since the check is only client-side
# minimum_balance: 0 # minimum_balance: 0

View file

@ -52,7 +52,8 @@ class FoodsoftConfig
# configuration files that haven't been updated, still work as they did. # configuration files that haven't been updated, still work as they did.
def set_missing def set_missing
config.replace({ config.replace({
use_nick: true use_nick: true,
use_apple_points: true
}.merge(config)) }.merge(config))
end end