mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Eager-load and update BasicEnterpriseSerializer
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
module Admin
|
||||
class EnterpriseRelationshipsController < ResourceController
|
||||
def index
|
||||
@my_enterprises = Enterprise.managed_by(spree_current_user).by_name
|
||||
@all_enterprises = Enterprise.by_name
|
||||
@enterprise_relationships = EnterpriseRelationship.by_name.involving_enterprises @my_enterprises
|
||||
@my_enterprises = Enterprise.
|
||||
includes(:shipping_methods, :payment_methods).
|
||||
managed_by(spree_current_user).by_name
|
||||
@all_enterprises = Enterprise.includes(:shipping_methods, :payment_methods).by_name
|
||||
@enterprise_relationships = EnterpriseRelationship.
|
||||
includes(:parent, :child).
|
||||
by_name.involving_enterprises @my_enterprises
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
class Api::Admin::BasicEnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category,
|
||||
:payment_method_ids, :shipping_method_ids, :producer_profile_only, :permalink
|
||||
|
||||
def payment_method_ids
|
||||
object.payment_methods.map(&:id)
|
||||
end
|
||||
|
||||
def shipping_method_ids
|
||||
object.shipping_methods.map(&:id)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user