item_models 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/item_models/version.rb +1 -1
- data/lib/models/image.rb +90 -0
- data/lib/models/item_listing.rb +7 -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 +4 -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_listing.rb +24 -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: '07954494f86bfc67a5455de2fc6a9ebf051c8fcfb307a1a1cf221e07561d08b6'
|
4
|
+
data.tar.gz: 47cbf60009a6e8c234368cbf9dbba154988f9e2d8a51b9002eff57780d82a66c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e3cd374958b92a98075fee13186f8074f3de3791e5bb8e5c3d8991c88278e8d5f1006f56a42e336e2f3736bfa65df36161f51f5dca30041b3c3479460f258d7
|
7
|
+
data.tar.gz: 660f2a43d44127f8451401cffb04e5505bc34f5779a5b0890701951ad3500887efb9d37ac2cd2baa1b07a94a0974fcd02131ba92cd4b404a71adb99075a794e4
|
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_listing.rb
CHANGED
@@ -8,11 +8,16 @@ 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
|
@@ -7,4 +7,8 @@ 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
|
10
14
|
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
|
@@ -11,4 +11,28 @@ 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
|
14
38
|
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.15
|
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-03 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
|