e9_vendors 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,12 @@
1
1
  class VendorMember < ActiveRecord::Base
2
2
  include E9Vendors::Model
3
3
 
4
- def self.add_vendor_proxy(proxy_association)
5
- all.each {|member| member.vendor_proxies << proxy_association.build }
6
- end
7
-
8
- has_many :vendor_proxies, :dependent => :destroy do
9
- def by_category
10
- includes(:vendor => :vendor_categories)
11
- .order('vendor_categories.position')
12
- .group_by {|vd| vd.vendor.vendor_category.name }
13
- end
14
- end
4
+ has_many :vendor_proxies, :dependent => :destroy
15
5
  has_many :vendors, :through => :vendor_proxies
16
6
 
17
- mount_uploader :logo, LogoUploader
18
-
19
7
  validates :name, :presence => true
8
+
9
+ def self.add_vendor_proxy(proxy_association)
10
+ all.each {|member| member.vendor_proxies << proxy_association.build }
11
+ end
20
12
  end
@@ -4,10 +4,8 @@ class VendorProxy < ActiveRecord::Base
4
4
  belongs_to :vendor, :touch => true
5
5
  belongs_to :vendor_member, :touch => true
6
6
 
7
- before_validation :populate_default_discount_code, :on => :create
7
+ before_validation :populate_default_discount_code
8
8
 
9
- validates :discount_code, :presence => true, :on => :update
10
- validates :discount_percentage, :numericality => { :greater_than_or_equal_to => 0, :less_than => 100 }
11
9
  validates :sales_email, :email => { :allow_blank => true }
12
10
 
13
11
  delegate :name, :to => :vendor, :prefix => true
@@ -30,7 +28,7 @@ class VendorProxy < ActiveRecord::Base
30
28
  protected
31
29
 
32
30
  def populate_default_discount_code
33
- self.discount_code = "V-#{self.vendor.id}-#{self.vendor_member.id}"
31
+ self.discount_code = self.discount_code.presence || "V-#{self.vendor.id}-#{self.vendor_member.id}"
34
32
  end
35
33
 
36
34
  def vendor_fallback(column)
@@ -1,3 +1,3 @@
1
1
  module E9Vendors
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: e9_vendors
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Travis Cox