rshop 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ef6b28d414f9fea6d5c074b3b9b8334c889cd23
4
- data.tar.gz: 4c279dfcaacc4fc5a285cc871c5cdaaa2bfe2a61
3
+ metadata.gz: 4e20b91d65e4865e3792e3de95a1ad12aaa38bde
4
+ data.tar.gz: 9ab35783cd6523b629fec2075918a1d787b6473b
5
5
  SHA512:
6
- metadata.gz: 0b5dcacbb4ed1cd8ee06fdc74053fea0792b8f9e1d8b037f029b5c03843462a16b41fbea5eae1c1b2a7844b6c11a04409bbe43bc20f61a2f88cfb4e695558988
7
- data.tar.gz: e51429e1a9792017964f9300601103850d72821a582b93a08a98c80e3ffaa9a70a509cc80f1b4a6db9ef0c2d85e55daf04af3024a951a9cff1b4f2852f7f1cba
6
+ metadata.gz: 138911d0c0496a1abd525b5a009ceaac7d296299af6002696ceea437de33573bb22ac28c768863ecf685b614ca28634859ae3bcccaba717aceb8fce609fa1b78
7
+ data.tar.gz: 448b5950340fc5d1f574df84f690fbf8db5824c5f362b5c47d18056c8ad9b67adfbfe0aa2fdf08e2167f2f7ea7b3ea8d26c051c3f6cf80d6f64fc0097942ba2e
@@ -0,0 +1,37 @@
1
+ .cart-show{
2
+ .product-item{
3
+ .image{
4
+ float: left;
5
+ margin-right: 10px;
6
+
7
+ img{
8
+ max-height: 50px;
9
+ }
10
+ }
11
+
12
+ .info{
13
+ float: left;
14
+ }
15
+
16
+ .brand{
17
+ font-size: 0.9em;
18
+ }
19
+
20
+ .qty{
21
+ span{
22
+ display: inline-block;
23
+ }
24
+ input{
25
+ display: inline-block;
26
+ margin: 0 1px;
27
+ width: 45px;
28
+ text-align: center;
29
+ }
30
+ .operation{
31
+ margin: 0 7px;
32
+ color: #949494;
33
+ font-size: 0.9em;
34
+ }
35
+ }
36
+ }
37
+ }
@@ -10,7 +10,7 @@ class RshopViewsGenerator < Rails::Generators::Base
10
10
  copy_file "app/views/rshop/cart/#{name}"
11
11
  end
12
12
 
13
- %w(show.html.slim).each do |name|
13
+ %w(form.html.slim ty.html.slim).each do |name|
14
14
  copy_file "app/views/rshop/checkout/#{name}"
15
15
  end
16
16
  end
@@ -5,6 +5,7 @@ module Rshop
5
5
  autoload :AutoApplicationController, 'rshop/auto_application_controller'
6
6
  autoload :PriceLoggableProduct, 'rshop/price_loggable_product'
7
7
  autoload :PriceAdjustableProduct, 'rshop/price_adjustable_product'
8
+ autoload :ProductBase, 'rshop/models/product_base'
8
9
 
9
10
  class Engine < Rails::Engine
10
11
  end
@@ -4,11 +4,15 @@ module Rshop
4
4
  base.class_eval do
5
5
  # extend Base
6
6
  include ClassMethods
7
+ helper_method :cart_view
7
8
  before_filter :setup_cart
8
9
  end
9
10
  end
10
11
 
11
12
  module ClassMethods
13
+ def cart_view
14
+ get_cart || Rshop::Order.new(user: current_user)
15
+ end
12
16
  # cart
13
17
  def get_cart
14
18
  id = get_cart_id
@@ -0,0 +1,78 @@
1
+ module Rshop
2
+ module ProductBase
3
+ # ctb - cart to buy rate
4
+ # ctc - click to cart rate
5
+
6
+ def self.included base
7
+ base.instance_eval do
8
+ extend FriendlyId
9
+ friendly_id :name, use: [:slugged, :finders]
10
+
11
+ has_one :album, as: :albumizable, dependent: :destroy, class_name: Rshop::Album
12
+ belongs_to :brand, touch: true, class_name: Rshop::Brand, foreign_key: :rshop_brand_id
13
+
14
+ accepts_nested_attributes_for :album, allow_destroy: true
15
+ after_initialize :init
16
+ before_save :calc_ctb, :calc_ctc
17
+
18
+ validates :name, :price, presence: true
19
+
20
+ scope :frontend, -> {where(is_published: true)}
21
+
22
+ include InstanceMethods
23
+ end
24
+ end
25
+
26
+ module InstanceMethods
27
+ def image_url variant = nil
28
+ image = self.album.images.first
29
+ path = image.try(:url, variant)
30
+ path ? path : Rshop::AlbumImage.new.url(variant)
31
+ end
32
+
33
+ protected
34
+
35
+ def calc_ctb
36
+ if cart_count + sold_count <= 0
37
+ self.ctb = 0
38
+ return
39
+ end
40
+
41
+ if sold_count == 0
42
+ self.sold_count = 1
43
+ end
44
+ self.ctb = sold_count / cart_count
45
+
46
+ rescue StandardError => e
47
+ p e.to_s
48
+ end
49
+
50
+ def calc_ctc
51
+ if views_count + cart_count <= 0
52
+ self.ctc = 0
53
+ return
54
+ end
55
+
56
+ if views_count == 0
57
+ self.views_count = 1
58
+ end
59
+ self.ctc = cart_count / views_count
60
+
61
+ rescue StandardError => e
62
+ p e.to_s
63
+ end
64
+
65
+ def should_generate_new_friendly_id?
66
+ !slug.present?
67
+ end
68
+
69
+ def init
70
+ unless self.persisted?
71
+ self.in_stock = true
72
+ self.album = Rshop::Album.new if self.album.nil?
73
+ end
74
+ end
75
+ end
76
+
77
+ end
78
+ end
@@ -1,3 +1,3 @@
1
1
  module Rshop
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ruslan.palagin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,6 +55,7 @@ files:
55
55
  - LICENSE.txt
56
56
  - README.md
57
57
  - Rakefile
58
+ - app/assets/stylesheets/rshop/cart.scss
58
59
  - app/controllers/ajax/rshop/products_controller.rb
59
60
  - app/controllers/rshop/.keep
60
61
  - app/controllers/rshop/auto_products_controller.rb
@@ -125,6 +126,7 @@ files:
125
126
  - lib/rshop.rb
126
127
  - lib/rshop/application_controller.rb
127
128
  - lib/rshop/auto_application_controller.rb
129
+ - lib/rshop/models/product_base.rb
128
130
  - lib/rshop/price_adjustable_product.rb
129
131
  - lib/rshop/price_loggable_product.rb
130
132
  - lib/rshop/version.rb