mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-30 06:31:16 +00:00
Switching enterprise index to its own dedicated serializer, so we can spit out ownership
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
class Api::Admin::BasicEnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :is_primary_producer, :is_distributor, :sells, :category, :payment_method_ids, :shipping_method_ids
|
||||
attributes :producer_profile_only, :permalink
|
||||
attributes :producer_profile_only
|
||||
end
|
||||
|
||||
8
app/serializers/api/admin/index_enterprise_serializer.rb
Normal file
8
app/serializers/api/admin/index_enterprise_serializer.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Api::Admin::IndexEnterpriseSerializer < ActiveModel::Serializer
|
||||
attributes :name, :id, :permalink, :is_primary_producer, :sells, :producer_profile_only, :owned
|
||||
|
||||
def owned
|
||||
return true if options[:spree_current_user].admin?
|
||||
object.owner == options[:spree_current_user]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user