solidus_bling 2.0.3 → 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: 3888ee5c2c2115caad5550a8b4b0c4a8c357271dedac7ceac19d8f9bf518b4b0
4
- data.tar.gz: e635f3c6e6dafb8a38b437611cc157e0535a0dfacebe61f60bf7bf31be0bc76b
3
+ metadata.gz: 7a1eeddb2480fc6c8c413632d68a9474a8861221a2696d686b855e815cabca27
4
+ data.tar.gz: 6a9654d237829e34477e9a975c80f66a60dad7756f894f4d9c316b0a416e50ca
5
5
  SHA512:
6
- metadata.gz: 52f2e484e6f4ed2110b5ea29858eea98bb24de7fd6d65d0381632bcf47650c18d978afd7265026b3b02f7f528f648ee0895fec925043d5119550a0f95025c9f6
7
- data.tar.gz: 3ffda6fc4dedc0ceda4dc2bb9d0e9de143fbda038562a6efb4297e195ba679125e47e3c77428c88483fe22f7240c276b6dbb7598a3d4d39915a02e15d0189baf
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
@@ -1,4 +1,5 @@
1
1
  <%= form_with model: bling_account, url: form_url do |form| %>
2
+ <h6>Dados da conta</h6>
2
3
  <div>
3
4
  <%= form.label :app_name, "Nome do Aplicativo: " %>
4
5
  <%= form.text_field :app_name %>
@@ -34,25 +35,28 @@
34
35
  <%= form.text_field :incoming_category_id %>
35
36
  </div>
36
37
 
37
- <div>
38
- <% bling_account.payment_methods.each do |payment_method| %>
39
- <%= form.fields_for :payment_methods do |payment_form| %>
38
+ <div style="margin: 10px 0">
39
+ <h6>Métodos de Pagamento</h6>
40
+ <%= form.fields_for :payment_methods do |payment_form| %>
41
+ <div>
40
42
  <%= payment_form.select :spree_payment_method_id, @payment_methods %>
41
43
  <%= payment_form.text_field :external_id %>
42
- <% end %>
44
+ </div>
43
45
  <% end %>
44
46
  </div>
45
47
 
46
- <div>
47
- <% bling_account.shipping_methods.each do |shipping_method| %>
48
- <%= form.fields_for :shipping_methods do |shipping_form| %>
48
+ <div style="margin: 10px 0">
49
+ <h6>Métodos de Envio</h6>
50
+ <%= form.fields_for :shipping_methods do |shipping_form| %>
51
+ <div>
49
52
  <%= shipping_form.select :spree_shipping_method_id, @shipping_methods %>
50
53
  <%= shipping_form.text_field :alias %>
51
- <% end %>
54
+ </div>
52
55
  <% end %>
53
56
  </div>
54
57
 
55
- <div>
58
+ <div style="margin: 10px 0">
59
+ <h6>Vendedores</h6>
56
60
  <% bling_account.sellers.each do |seller| %>
57
61
  <%= form.fields_for :sellers do |seller_form| %>
58
62
  <%= seller_form.label :name, "Nome do Vendedor: " %>
@@ -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.3'
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.3
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