Skip to content

Commit

Permalink
Merge pull request #266 from wvengen/feature-apples_optional
Browse files Browse the repository at this point in the history
make apple points optional
  • Loading branch information
wvengen committed Mar 15, 2014
2 parents aad9fae + 48865d1 commit 4fa2d22
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/models/ordergroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def apples
# 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
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
apples < FoodsoftConfig[:stop_ordering_under] and
group_orders.count > 5 and
Expand Down
3 changes: 2 additions & 1 deletion app/views/admin/ordergroups/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
= f.input :contact_person
= f.input :contact_phone
= 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
= f.button :submit
= link_to t('ui.or_cancel'), :back
2 changes: 1 addition & 1 deletion app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
= render :partial => 'shared/open_orders', :locals => {:ordergroup => current_user.ordergroup}

// Stats
- if current_user.ordergroup
- if current_user.ordergroup and FoodsoftConfig[:use_apple_points]
%section
%h2= t '.ordergroup.title'
= render :partial => "apple_bar", :locals => {:apple_bar => AppleBar.new(current_user.ordergroup)}
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_group.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
- members = group.users
= "(#{members.size})"
= 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'
%dd= group.ignore_apple_restriction ? t('.deactivated') : t('.activated')
3 changes: 3 additions & 0 deletions config/app_config.yml.SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ default: &defaults
# Comment out this option to activate this restriction
# 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
# not fully enforced right now, since the check is only client-side
# minimum_balance: 0
Expand Down
3 changes: 2 additions & 1 deletion lib/foodsoft_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def setup_database
# configuration files that haven't been updated, still work as they did.
def set_missing
config.replace({
use_nick: true
use_nick: true,
use_apple_points: true
}.merge(config))
end

Expand Down

0 comments on commit 4fa2d22

Please sign in to comment.