mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move #manages_one_enterprise? from User model to Permissions
This commit is contained in:
@@ -5,7 +5,7 @@ Spree::Admin::OverviewController.class_eval do
|
||||
@product_count = Spree::Product.active.managed_by(spree_current_user).count
|
||||
@order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count
|
||||
|
||||
if spree_current_user.manages_one_enterprise?
|
||||
if OpenFoodNetwork::Permissions.new(spree_current_user).manages_one_enterprise?
|
||||
@enterprise = @enterprises.first
|
||||
if @enterprise.sells == "unspecified"
|
||||
render "welcome", layout: "spree/layouts/bare_admin"
|
||||
|
||||
@@ -19,10 +19,6 @@ Spree.user_class.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
def manages_one_enterprise?
|
||||
enterprises.length == 1
|
||||
end
|
||||
|
||||
def send_signup_confirmation
|
||||
Spree::UserMailer.signup_confirmation(self).deliver
|
||||
end
|
||||
|
||||
@@ -25,6 +25,10 @@ module OpenFoodNetwork
|
||||
managed_and_related_enterprises_with :manage_products
|
||||
end
|
||||
|
||||
def manages_one_enterprise?
|
||||
@user.enterprises.length == 1
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user