mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-21 05:09:15 +00:00
Move class instance variable to helper
This commit is contained in:
@@ -8,7 +8,6 @@ module Admin
|
||||
before_action :init_filters_params
|
||||
before_action :init_pagination_params
|
||||
before_action :init_none_tag
|
||||
before_action :fetch_data, include: [:index, :bulk_update]
|
||||
|
||||
def index
|
||||
fetch_products
|
||||
@@ -204,11 +203,6 @@ module Admin
|
||||
).distinct.order(:name).pluck(:name)
|
||||
end
|
||||
|
||||
def fetch_data
|
||||
@allowed_source_producers = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.enterprises_granting_sourced_variants
|
||||
end
|
||||
|
||||
def fetch_products
|
||||
product_query = OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.editable_products.merge(product_scope_with_includes).ransack(ransack_query).result
|
||||
|
||||
@@ -47,5 +47,10 @@ module Admin
|
||||
def variant_tag_enabled?(user)
|
||||
feature?(:variant_tag, user) || feature?(:variant_tag, *user.enterprises)
|
||||
end
|
||||
|
||||
def allowed_source_producers
|
||||
@allowed_source_producers ||= OpenFoodNetwork::Permissions.new(spree_current_user)
|
||||
.enterprises_granting_sourced_variants
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
- if variant.persisted?
|
||||
= link_to t('admin.products_page.actions.edit'), edit_admin_product_variant_path(variant.product, variant)
|
||||
|
||||
- if @allowed_source_producers.include?(variant.supplier)
|
||||
- if allowed_source_producers.include?(variant.supplier)
|
||||
= link_to t('admin.products_page.actions.create_sourced_variant'), admin_create_sourced_variant_path(variant_id: variant.id, product_index:), 'data-turbo-method': :post
|
||||
|
||||
- if variant.product.variants.size > 1
|
||||
|
||||
Reference in New Issue
Block a user