item_models 0.0.14 → 0.0.17
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.
- checksums.yaml +4 -4
- data/lib/item_models/version.rb +1 -1
- data/lib/models/image.rb +90 -0
- data/lib/models/item.rb +4 -0
- data/lib/models/item_listing.rb +15 -2
- data/lib/models/item_listing_brand.rb +4 -0
- data/lib/models/item_listing_category.rb +4 -0
- data/lib/models/item_listing_custom_field.rb +6 -0
- data/lib/models/item_listing_variant_custom_field.rb +5 -1
- data/lib/models/item_listing_variant_image.rb +4 -0
- data/lib/models/shopee_brand.rb +9 -0
- data/lib/models/shopee_category.rb +22 -0
- data/lib/models/shopee_item_custom_field.rb +8 -0
- data/lib/models/shopee_item_custom_field_option.rb +10 -0
- data/lib/models/shopee_item_variant_custom_field.rb +5 -0
- data/lib/models/shopee_logistic_address.rb +5 -0
- data/lib/models/shopee_shipping_provider.rb +5 -0
- data/lib/models/variant.rb +5 -0
- data/lib/models/variant_listing.rb +37 -0
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2093ffd195104bfddd2d79661d2e61a987f29046c52049633541c0fe19e6a0e5
|
4
|
+
data.tar.gz: 1e6f5a1c3d04f65ef36186e7ebc8cab503a79a0fa476680a927e000499e8c94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dd4928eaaa427901f61e18c0f5ece615511f088b53ee5e563f17e47c65fa2517ef86e3b6e993b062bc4e038e35eee782ec0c152a8400ff59a71a2f5c6b2a64a
|
7
|
+
data.tar.gz: 649f591532485d598e0d0c4b1162b92e75ea3cfa1bd175d076c0bb5e12e148ffda801f348281fe06c8700d595bed5fc5b66f710ae2f35b7ec08343021a27aec0
|
data/lib/item_models/version.rb
CHANGED
data/lib/models/image.rb
CHANGED
@@ -10,4 +10,94 @@ class Image < ItemApplicationRecord
|
|
10
10
|
has_many :variant_images, foreign_key: :item_image_id
|
11
11
|
has_many :master_catalog_images
|
12
12
|
has_many :item_listing_variant_custom_fields
|
13
|
+
|
14
|
+
has_attached_file :image,
|
15
|
+
path: '/system/item/:class/:attachment/:id_partition/:style/:fingerprint.:extension',
|
16
|
+
default_url: lambda { |attach|
|
17
|
+
attach.instance.url || '/public/missing/missing-item.jpg'
|
18
|
+
},
|
19
|
+
styles: lambda { |attachment|
|
20
|
+
object = attachment.instance.image.queued_for_write[:original]
|
21
|
+
width, height =
|
22
|
+
if object
|
23
|
+
FastImage.size(object) || [0,0]
|
24
|
+
else
|
25
|
+
[(attachment.instance.width || 500), (attachment.instance.height || 500)]
|
26
|
+
end
|
27
|
+
|
28
|
+
dim = [width, height]
|
29
|
+
clamped_dim = dim.max && [600, dim.max, 2000].sort[1]
|
30
|
+
big_clamped_dim = dim.max && [1100, dim.max, 2000].sort[1]
|
31
|
+
|
32
|
+
# max hxw and ratio (1100 x 762)
|
33
|
+
ratio_381_550 = 1100/762.to_f
|
34
|
+
real_ratio = height/width.to_f
|
35
|
+
|
36
|
+
# If real ratio is smaller, then width is thicker than desired width, therefor
|
37
|
+
# adjust height to fit desired ratio.
|
38
|
+
if real_ratio < ratio_381_550
|
39
|
+
w_381_550 = width
|
40
|
+
h_381_550 = width * ratio_381_550
|
41
|
+
else
|
42
|
+
w_381_550 = height / ratio_381_550
|
43
|
+
h_381_550 = height
|
44
|
+
end
|
45
|
+
|
46
|
+
{
|
47
|
+
xlarge: {
|
48
|
+
geometry: '1600x1600>',
|
49
|
+
format: :jpg,
|
50
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
51
|
+
},
|
52
|
+
large: {
|
53
|
+
geometry: '1000x1000>',
|
54
|
+
format: :jpg,
|
55
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
56
|
+
},
|
57
|
+
medium: {
|
58
|
+
geometry: '800x800>',
|
59
|
+
format: :jpg,
|
60
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
61
|
+
},
|
62
|
+
small: {
|
63
|
+
geometry: '500x500>',
|
64
|
+
format: :jpg,
|
65
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
66
|
+
},
|
67
|
+
thumb: {
|
68
|
+
geometry: '100x100>',
|
69
|
+
format: :jpg,
|
70
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
71
|
+
},
|
72
|
+
marketplace: {
|
73
|
+
geometry: '500x500<',
|
74
|
+
format: :jpg,
|
75
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
76
|
+
},
|
77
|
+
# Lazada needs colorspace to be sRGB. CMYK colorspace will produce error
|
78
|
+
square: {
|
79
|
+
geometry: dim.max && dim.max < 600 ? '600x600<' : '2000x2000>',
|
80
|
+
format: :jpg,
|
81
|
+
convert_options: "-strip -colorspace sRGB -interlace Plane -background white -alpha remove -flatten -alpha off -gravity center -extent #{clamped_dim}x#{clamped_dim}"
|
82
|
+
},
|
83
|
+
# Zalora
|
84
|
+
big_square: {
|
85
|
+
geometry: dim.max && dim.max < 1100 ? '1100x1100<' : '2000x2000>',
|
86
|
+
format: :jpg,
|
87
|
+
convert_options: "-strip -colorspace sRGB -interlace Plane -background white -alpha remove -flatten -alpha off -gravity center -extent #{big_clamped_dim}x#{big_clamped_dim}"
|
88
|
+
},
|
89
|
+
# lyke
|
90
|
+
ratio_381_550: {
|
91
|
+
geometry: w_381_550 <= 762 ? '762x1100<' : '762x1100>',
|
92
|
+
format: :jpeg,
|
93
|
+
convert_options: "-strip -colorspace sRGB -interlace Plane -background white -alpha remove -flatten -alpha off -gravity center -extent 762x1100"
|
94
|
+
},
|
95
|
+
# elevenia
|
96
|
+
width_780_or_less: {
|
97
|
+
geometry: '780x>',
|
98
|
+
format: :jpg,
|
99
|
+
convert_options: '-strip -interlace Plane -background white -alpha remove -flatten -alpha off'
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
13
103
|
end
|
data/lib/models/item.rb
CHANGED
data/lib/models/item_listing.rb
CHANGED
@@ -8,12 +8,25 @@ class ItemListing < ItemApplicationRecord
|
|
8
8
|
belongs_to :item
|
9
9
|
has_many :variant_listings, foreign_key: :channel_association_id
|
10
10
|
has_many :item_listing_images, foreign_key: :channel_association_id
|
11
|
-
|
12
|
-
|
11
|
+
has_one :item_listing_category, foreign_key: :channel_association_id
|
12
|
+
has_one :item_listing_brand, foreign_key: :channel_association_id
|
13
13
|
has_many :item_listing_variant_custom_fields, foreign_key: :channel_association_id
|
14
14
|
has_many :item_listing_custom_fields, foreign_key: :channel_association_id
|
15
15
|
has_many :item_listing_variant_images, foreign_key: :channel_association_id
|
16
|
+
has_many :images,
|
17
|
+
class_name: 'ItemListingImage',
|
18
|
+
dependent: :destroy,
|
19
|
+
autosave: true,
|
20
|
+
foreign_key: :channel_association_id
|
16
21
|
has_one :category,
|
17
22
|
dependent: :destroy,
|
18
23
|
autosave: true
|
24
|
+
|
25
|
+
def assign_from_item(item)
|
26
|
+
self.item_id = item.id
|
27
|
+
end
|
28
|
+
|
29
|
+
def assign_from_account(account)
|
30
|
+
self.channel_id = account.channel_id
|
31
|
+
end
|
19
32
|
end
|
@@ -7,4 +7,10 @@ class ItemListingCustomField < ItemApplicationRecord
|
|
7
7
|
|
8
8
|
belongs_to :item_listing, foreign_key: :channel_association_id
|
9
9
|
belongs_to :variant
|
10
|
+
belongs_to :shopee,
|
11
|
+
class_name: 'ShopeeItemCustomField',
|
12
|
+
foreign_key: :shopee_item_custom_field_id,
|
13
|
+
optional: true
|
14
|
+
|
15
|
+
serialize :value
|
10
16
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ItemListingVariantCustomField < ItemApplicationRecord
|
4
|
-
self.table_name = '
|
4
|
+
self.table_name = 'item_channel_association_variant_custom_fields'
|
5
5
|
|
6
6
|
belongs_to :item_listing, foreign_key: :channel_association_id
|
7
7
|
belongs_to :variant
|
8
8
|
belongs_to :image
|
9
|
+
belongs_to :shopee,
|
10
|
+
class_name: 'ShopeeItemVariantCustomField',
|
11
|
+
foreign_key: :shopee_item_variant_custom_field_id,
|
12
|
+
optional: true
|
9
13
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ShopeeCategory < ItemApplicationRecord
|
4
|
+
self.table_name = 'channel_shopee_categories'
|
5
|
+
|
6
|
+
belongs_to :parent_category,
|
7
|
+
class_name: 'ShopeeCategory',
|
8
|
+
foreign_key: :parent_category_id,
|
9
|
+
optional: true
|
10
|
+
belongs_to :primary_category,
|
11
|
+
class_name: 'ShopeeCategory',
|
12
|
+
foreign_key: :primary_category_id,
|
13
|
+
optional: true
|
14
|
+
has_many :child_categories,
|
15
|
+
class_name: 'ShopeeCategory',
|
16
|
+
foreign_key: :parent_category_id,
|
17
|
+
dependent: :destroy
|
18
|
+
|
19
|
+
has_many :item_channel_association_categories,
|
20
|
+
class_name: '::ItemListingCategory',
|
21
|
+
foreign_key: :shopee_category_id
|
22
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ShopeeItemCustomField < ItemApplicationRecord
|
4
|
+
self.table_name = 'channel_shopee_item_custom_fields'
|
5
|
+
|
6
|
+
has_many :associated_custom_fields, class_name: 'ItemListingCustomField'
|
7
|
+
has_many :options, foreign_key: :custom_field_id, class_name: 'ShopeeItemCustomFieldOption'
|
8
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ShopeeItemCustomFieldOption < ItemApplicationRecord
|
4
|
+
self.table_name = 'channel_shopee_item_custom_field_options'
|
5
|
+
|
6
|
+
belongs_to :custom_field,
|
7
|
+
class_name: 'ShopeeItemCustomField',
|
8
|
+
foreign_key: :custom_field_id,
|
9
|
+
optional: true
|
10
|
+
end
|
data/lib/models/variant.rb
CHANGED
@@ -13,4 +13,9 @@ class Variant < ItemApplicationRecord
|
|
13
13
|
has_many :item_listing_variant_custom_field, foreign_key: :variant_id
|
14
14
|
has_many :item_listing_custom_field, foreign_key: :variant_id
|
15
15
|
has_one :master_catalog, foreign_key: :variant_id
|
16
|
+
|
17
|
+
def assign_from_item(item)
|
18
|
+
self.item_id = item.id
|
19
|
+
self.profile_id = item.profile_id
|
20
|
+
end
|
16
21
|
end
|
@@ -11,4 +11,41 @@ class VariantListing < ItemApplicationRecord
|
|
11
11
|
class_name: 'VariantListingStockAllocation',
|
12
12
|
foreign_key: :variant_association_id
|
13
13
|
has_many :variant_listing_price_histories, foreign_key: :variant_association_id
|
14
|
+
|
15
|
+
serialize :option2_value
|
16
|
+
serialize :option_value
|
17
|
+
serialize :name_option
|
18
|
+
serialize :qc_reason
|
19
|
+
serialize :last_log
|
20
|
+
serialize :bukalapak_free_shipping
|
21
|
+
serialize :shopee_shipping_providers
|
22
|
+
serialize :description
|
23
|
+
serialize :description_unique_selling_point
|
24
|
+
|
25
|
+
def item_listing_custom_fields
|
26
|
+
ItemListingCustomField.where("channel_association_id = ? AND variant_id = ?", self.channel_association_id, self.variant_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def item_listing_variant_custom_fields
|
30
|
+
ItemListingVariantCustomField.where("channel_association_id = ? AND variant_id = ?", self.channel_association_id, self.variant_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def item_listing_variant_images
|
34
|
+
ItemListingVariantImage.where(
|
35
|
+
"channel_association_id = ? AND variant_id = ? AND account_id = ?", self.channel_association_id, self.variant_id, self.profile_channel_association_id
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def assign_from_variant(variant)
|
40
|
+
self.variant_id = variant.id
|
41
|
+
end
|
42
|
+
|
43
|
+
def assign_from_item_listing(item)
|
44
|
+
self.channel_association_id = item.id
|
45
|
+
end
|
46
|
+
|
47
|
+
def assign_from_account(account)
|
48
|
+
self.profile_channel_association_id = account.id
|
49
|
+
self.channel_id = account.channel_id
|
50
|
+
end
|
14
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: item_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,6 +78,13 @@ files:
|
|
78
78
|
- lib/models/item_listing_variant_image.rb
|
79
79
|
- lib/models/master_catalog.rb
|
80
80
|
- lib/models/master_catalog_image.rb
|
81
|
+
- lib/models/shopee_brand.rb
|
82
|
+
- lib/models/shopee_category.rb
|
83
|
+
- lib/models/shopee_item_custom_field.rb
|
84
|
+
- lib/models/shopee_item_custom_field_option.rb
|
85
|
+
- lib/models/shopee_item_variant_custom_field.rb
|
86
|
+
- lib/models/shopee_logistic_address.rb
|
87
|
+
- lib/models/shopee_shipping_provider.rb
|
81
88
|
- lib/models/variant.rb
|
82
89
|
- lib/models/variant_image.rb
|
83
90
|
- lib/models/variant_listing.rb
|
@@ -105,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
112
|
- !ruby/object:Gem::Version
|
106
113
|
version: '0'
|
107
114
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.3.7
|
109
116
|
signing_key:
|
110
117
|
specification_version: 4
|
111
118
|
summary: gem for active record item models
|