Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Code review issues fixed.
Matthew Kennedya10baf86ada8
diff --git a/core/app/models/spree/digital.rb b/core/app/models/spree/digital.rbindex d906406391..9fc4a59b5c 100644--- a/core/app/models/spree/digital.rb+++ b/core/app/models/spree/digital.rb@@ -4,6 +4,7 @@ module Spreehas_many :digital_links, dependent: :destroyhas_one_attached :attachment+validates :attachment, attached: trueendenddiff --git a/core/app/models/spree/digital_link.rb b/core/app/models/spree/digital_link.rbindex 5723fa71aa..3056d83197 100644--- a/core/app/models/spree/digital_link.rb+++ b/core/app/models/spree/digital_link.rb@@ -1,15 +1,16 @@module Spreeclass DigitalLink < Spree::Base+ has_secure_token :secret+belongs_to :digitalvalidates :digital, presence: truebelongs_to :line_item- validates_length_of :secret, is: 30-before_validation :set_defaults, on: :create- # Can this link stil be used? It is valid if it's less than 24 hours old and was not accessed more than 3 times+ # Can this link stil be used? It is valid if it's less than 24 hours+ # old and was not accessed more than 3 timesdef authorizable?!(expired? || access_limit_exceeded?)end@@ -30,14 +31,14 @@ module Spreedef reset!update_column :access_counter, 0- update_column :created_at, Time.now+ update_column :created_at, Time.currentendprivate- # Populating the secret automatically and zero'ing the access_counter (otherwise it might turn out to be NULL)+ # Populating the secret automatically and zero'ing the access_counter+ # (otherwise it might turn out to be NULL)def set_defaults- self.secret = SecureRandom.hex(15)self.access_counter ||= 0endenddiff --git a/core/app/models/spree/line_item.rb b/core/app/models/spree/line_item.rbindex e063eadc9b..04a655849d 100644--- a/core/app/models/spree/line_item.rb+++ b/core/app/models/spree/line_item.rb@@ -129,8 +129,8 @@ module Spree# include master variant digitalsmaster = variant.product.master- create_digital_links_for_variant(master) if master.digital?+ create_digital_links_for_variant(master) if master.digital?create_digital_links_for_variant(variant) unless variant.is_master?enddiff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rbindex 5c1069e9b9..5d7ce03b99 100644--- a/core/app/models/spree/product.rb+++ b/core/app/models/spree/product.rb@@ -55,7 +55,6 @@ module Spreehas_many :possible_promotions, -> { advertised.active }, through: :promotion_rules,class_name: 'Spree::Promotion',source: :promotion- has_many :digitals, through: :variants_including_masterbelongs_to :tax_category, class_name: 'Spree::TaxCategory'belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', inverse_of: :products@@ -88,6 +87,7 @@ module Spreehas_many :store_products, class_name: 'Spree::StoreProduct'has_many :stores, through: :store_products, class_name: 'Spree::Store'+ has_many :digitals, through: :variants_including_masterafter_create :add_associations_from_prototypeafter_create :build_variants_from_option_values_hash, if: :option_values_hashdiff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rbindex 4b6920a0bc..dd97b9de70 100644--- a/core/app/models/spree/variant.rb+++ b/core/app/models/spree/variant.rb@@ -43,6 +43,7 @@ module Spreeinverse_of: :varianthas_many :wished_items, dependent: :destroy+has_many :digitalsbefore_validation :set_cost_currency