diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb
index a84fb49..3169b4d 100644
--- a/app/controllers/checkout_controller.rb
+++ b/app/controllers/checkout_controller.rb
@@ -75,6 +75,7 @@ class CheckoutController < ShopController
def order_params
params.require(:order)
.permit(:email, :message_from_client, :terms_of_service_acceptance,
- :first_name, :last_name, :phone, :street, :city, :zip_code)
+ :first_name, :last_name, :phone, :street, :city, :zip_code,
+ :voivodeship, :country, :shipping_id)
end
end
diff --git a/app/models/order.rb b/app/models/order.rb
index dba8f9e..ca74389 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -43,6 +43,12 @@ class Order < ApplicationRecord
7 => 'Anulowane'
}.freeze
+ VOIVOIDSHIPS = ['dolnośląskie', 'kujawsko-pomorskie', 'lubelskie', 'lubuskie',
+ 'łódzkie', 'małopolskie', 'mazowieckie', 'opolskie',
+ 'podkarpackie', 'podlaskie', 'pomorskie', 'śląskie',
+ 'świętokrzyskie', 'warmińsko-mazurskie', 'wielkopolskie',
+ 'zachodniopomorskie'].freeze
+
def order_summary
order_value + shipping.price
end
@@ -80,7 +86,8 @@ class Order < ApplicationRecord
end
def address
- "#{street}\n#{zip_code} #{city}\n\ntel: #{phone}"
+ "#{street}\n#{zip_code} #{city}\n"\
+ "woj. #{voivodeship}\n#{country}\n\ntel: #{phone}"
end
def order_value
diff --git a/app/views/checkout/partials/_shipping_address.html.erb b/app/views/checkout/partials/_shipping_address.html.erb
index 7111999..ebfc0b4 100644
--- a/app/views/checkout/partials/_shipping_address.html.erb
+++ b/app/views/checkout/partials/_shipping_address.html.erb
@@ -61,10 +61,20 @@
+
+
+
+
+ <%= select(:order, :voivodeship, options_for_select(Order::VOIVOIDSHIPS), {}, {class: 'form-control'}) %>
+
+
+
-
+ <%= select(:order, :country, options_for_select(['Polska']), {}, {class: 'form-control'}) %>
diff --git a/db/migrate/20180605061228_add_voivodeship_and_country_to_order.rb b/db/migrate/20180605061228_add_voivodeship_and_country_to_order.rb
new file mode 100644
index 0000000..6c743fc
--- /dev/null
+++ b/db/migrate/20180605061228_add_voivodeship_and_country_to_order.rb
@@ -0,0 +1,6 @@
+class AddVoivodeshipAndCountryToOrder < ActiveRecord::Migration[5.1]
+ def change
+ add_column :orders, :voivodeship, :string, after: 'zip_code'
+ add_column :orders, :country, :string, after: 'voivodeship'
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index ee1ecfc..59e5e5c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180119145343) do
+ActiveRecord::Schema.define(version: 20180605061228) do
create_table "admins", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
t.string "email", default: "", null: false
@@ -157,6 +157,7 @@ ActiveRecord::Schema.define(version: 20180119145343) do
end
create_table "orders", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
+ t.integer "order_number"
t.bigint "cart_id", null: false
t.integer "shipping_id"
t.integer "payment_method_id"
@@ -168,6 +169,8 @@ ActiveRecord::Schema.define(version: 20180119145343) do
t.string "street"
t.string "city", limit: 80
t.string "zip_code", limit: 10
+ t.string "voivodeship"
+ t.string "country"
t.text "message_from_client"
t.integer "status", default: 0, null: false
t.datetime "created_at"
@@ -239,6 +242,7 @@ ActiveRecord::Schema.define(version: 20180119145343) do
t.text "index_page_second_info", limit: 4294967295
t.text "index_page_content", limit: 4294967295
t.text "shop_owners_emails"
+ t.boolean "recaptcha_chk", default: false, null: false
t.datetime "updated_at"
t.integer "updated_by"
end