From e2edfe45f63fdfe083355b35082811aab6132007 Mon Sep 17 00:00:00 2001 From: Thea Choem <29684683+theachoem@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:22:06 +0700 Subject: [PATCH] close #2116 add promotion related field to serializer --- .../admin/promotions/_form/auto_apply_field.html.erb.deface | 2 +- .../spree/v2/storefront/product_serializer_decorator.rb | 3 ++- .../v2/storefront/promotion_serializer.rb | 2 +- .../serializers/spree/v2/storefront/product_serializer_spec.rb | 1 + .../v2/storefront/promotion_serializer_spec.rb | 3 ++- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/overrides/spree/admin/promotions/_form/auto_apply_field.html.erb.deface b/app/overrides/spree/admin/promotions/_form/auto_apply_field.html.erb.deface index 584a7b319..069eb04dd 100644 --- a/app/overrides/spree/admin/promotions/_form/auto_apply_field.html.erb.deface +++ b/app/overrides/spree/admin/promotions/_form/auto_apply_field.html.erb.deface @@ -2,7 +2,7 @@ <%= f.field_container :auto_apply, class: ['checkbox'] do %> <%= f.label :auto_apply do %> - <%= f.check_box :auto_apply %> + <%= f.check_box :auto_apply, checked: f.object.code.nil? && f.object.path.nil? %> <%= Spree.t(:auto_apply) %> <%= raw Spree.t('auto_apply_info') %> diff --git a/app/serializers/spree/v2/storefront/product_serializer_decorator.rb b/app/serializers/spree/v2/storefront/product_serializer_decorator.rb index 20bb69b98..d5d0b8727 100644 --- a/app/serializers/spree/v2/storefront/product_serializer_decorator.rb +++ b/app/serializers/spree/v2/storefront/product_serializer_decorator.rb @@ -10,7 +10,8 @@ def self.prepended(base) base.has_one :default_state, serializer: :state base.has_one :venue, serializer: ::SpreeCmCommissioner::V2::Storefront::ProductPlaceSerializer - base.attributes :need_confirmation, :product_type, :kyc, :allowed_upload_later, :allow_anonymous_booking, :use_video_as_default + + base.attributes :need_confirmation, :product_type, :kyc, :kyc_fields, :allowed_upload_later, :allow_anonymous_booking, :use_video_as_default base.attributes :reveal_description, :discontinue_on, :public_metadata, :purchasable_on base.attribute :purchasable_on_app do |product| diff --git a/app/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer.rb b/app/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer.rb index d49d20998..a8edd227d 100644 --- a/app/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer.rb +++ b/app/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer.rb @@ -2,7 +2,7 @@ module SpreeCmCommissioner module V2 module Storefront class PromotionSerializer < BaseSerializer - attributes :name, :description, :match_policy, :advertise + attributes :name, :description, :match_policy, :advertise, :expires_at has_many :promotion_rules has_many :promotion_actions diff --git a/spec/serializers/spree/v2/storefront/product_serializer_spec.rb b/spec/serializers/spree/v2/storefront/product_serializer_spec.rb index 4a0841d8e..95882a6bd 100644 --- a/spec/serializers/spree/v2/storefront/product_serializer_spec.rb +++ b/spec/serializers/spree/v2/storefront/product_serializer_spec.rb @@ -45,6 +45,7 @@ :display_compare_at_price, :need_confirmation, :kyc, + :kyc_fields, :product_type, :reveal_description, :allowed_upload_later, diff --git a/spec/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer_spec.rb b/spec/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer_spec.rb index 2a46327ec..c3927a2f7 100644 --- a/spec/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer_spec.rb +++ b/spec/serializers/spree_cm_commissioner/v2/storefront/promotion_serializer_spec.rb @@ -16,7 +16,8 @@ :name, :description, :match_policy, - :advertise + :advertise, + :expires_at, ) end