solidus_bling 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e4a5f9765d1f7f6e6b29effcaac981bbe0dfd62b8786d643f9d2a60b9340a59
4
- data.tar.gz: 8b153d5ba28e4f284521f6721309188d8ff87ec7826f1093a57c741c27a2480a
3
+ metadata.gz: 7a1eeddb2480fc6c8c413632d68a9474a8861221a2696d686b855e815cabca27
4
+ data.tar.gz: 6a9654d237829e34477e9a975c80f66a60dad7756f894f4d9c316b0a416e50ca
5
5
  SHA512:
6
- metadata.gz: 557622616334f5524f651a6e30e3ec1d17b0f01ff4e5c7c97a74daca156543e5f003c7b2f015bcfb17e03986054b02f2b8f85b2d125147b96b79247ce2b3fad7
7
- data.tar.gz: '099ecd7d4c1b2f485884124545fe25fedeb8c168b6da4b6f8bce124f37e4de289cf4d281f35d0d316e56f6b87d4853687b2ef24ac7a2970166cc5194acecd0ac'
6
+ metadata.gz: 4dc19ff8328d031b59baa44c5cb42fbf9ff9e004f8e751ffe4eb7044a7fac234d0315df516fd519492d6a24f100714ec8e97c76d9f88503a0e356f29c8189ed7
7
+ data.tar.gz: f82406fc7f2de27d9476ead0d9a4a48873509cfa8aa95312b30c1242503de200421fd2f82385f0f2d2366fcc845193e5a19e328910a4ece17d7d5a2d3d10fca0
@@ -18,8 +18,14 @@ module Spree
18
18
  end
19
19
 
20
20
  def create
21
- bling_account = SolidusBling::Account.create account_params.merge(name: "Bling")
22
- redirect_to admin_accounts_path
21
+ bling_account = SolidusBling::Account.new account_params.merge(name: "Bling")
22
+ if bling_account.save
23
+ flash[:success] = "Conta criada com sucesso"
24
+ redirect_to admin_accounts_path
25
+ else
26
+ flash[:error] = bling_account.errors.full_messages.join("\n")
27
+ redirect_to new_admin_account_path
28
+ end
23
29
  end
24
30
 
25
31
  def edit
@@ -27,7 +33,7 @@ module Spree
27
33
  @payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
28
34
  @shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
29
35
  @products_count = @bling_account.products.count
30
- @last_update = SolidusBling::Event.where(method: "products_updated").max.created_at.strftime("%d/%m/%Y %H:%M")
36
+ @last_update = SolidusBling::Event.where(method: "products_updated").max.try(:created_at)
31
37
  end
32
38
 
33
39
  def update
@@ -1,9 +1,9 @@
1
1
  module SolidusBling
2
2
  class Account < ApplicationRecord
3
- has_many :payment_methods
4
- has_many :shipping_methods
5
- has_many :products
6
- has_many :sellers
3
+ has_many :payment_methods, dependent: :destroy
4
+ has_many :shipping_methods, dependent: :destroy
5
+ has_many :products, dependent: :destroy
6
+ has_many :sellers, dependent: :destroy
7
7
  accepts_nested_attributes_for :payment_methods, :shipping_methods, :sellers
8
8
  end
9
9
  end
@@ -1,5 +1,7 @@
1
1
  module SolidusBling
2
2
  class PaymentMethod < ApplicationRecord
3
+ validates :external_id, presence: true
4
+
3
5
  belongs_to :account
4
6
  belongs_to :spree_payment_method, class_name: "Spree::PaymentMethod"
5
7
  end
@@ -1,5 +1,8 @@
1
1
  module SolidusBling
2
2
  class Seller < ApplicationRecord
3
+ validates :name, presence: true
4
+ validates :external_id, presence: true
5
+
3
6
  belongs_to :account
4
7
  end
5
8
  end
@@ -1,5 +1,7 @@
1
1
  module SolidusBling
2
2
  class ShippingMethod < ApplicationRecord
3
+ validates :alias, presence: true
4
+
3
5
  belongs_to :account
4
6
  belongs_to :spree_shipping_method, class_name: "Spree::ShippingMethod"
5
7
  end
@@ -3,7 +3,9 @@
3
3
  {confirm: "Deseja baixar os produtos?" } %>
4
4
  <span>Produtos baixados: <%= @products_count %></span>
5
5
  <br>
6
- <span>Ultima atualização: <%= @last_update %> </span>
6
+ <% if @last_update.present? %>
7
+ <span>Ultima atualização: <%= @last_update.strftime("%d/%m/%Y %H:%M") %> </span>
8
+ <% end %>
7
9
  </div>
8
10
 
9
11
  <%= render "form", bling_account: @bling_account, form_url: admin_account_path(@bling_account.id) %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBling
4
- VERSION = '2.0.4'
4
+ VERSION = '2.0.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_bling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses-bull
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubygems_version: 3.4.6
202
+ rubygems_version: 3.4.19
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Solidus extension to integrate with the Bling