diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index ab5cb35..cf38f41 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -4,7 +4,7 @@ class ShopController < ApplicationController include PageContent def set_settings - #Rails.logger.error request.location.country_code + # Rails.logger.error request.location.country_code @ss = ScSetting.first redirect_to '/closed.html' if @ss.shop_active.eql?(false) end diff --git a/app/models/admin.rb b/app/models/admin.rb index f703406..d3dc2e8 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -1,3 +1,26 @@ +# == Schema Information +# +# Table name: admins +# +# id :bigint(8) not null, primary key +# email :string(255) default(""), not null +# description :string(80) +# encrypted_password :string(255) default(""), not null +# reset_password_token :string(255) +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default(0), not null +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string(255) +# last_sign_in_ip :string(255) +# failed_attempts :integer default(0), not null +# unlock_token :string(255) +# locked_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# + # Administrators of application class Admin < ApplicationRecord # Include default devise modules. Others available are: diff --git a/app/models/all_page.rb b/app/models/all_page.rb index 21411df..ea8d506 100644 --- a/app/models/all_page.rb +++ b/app/models/all_page.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: all_pages +# +# id :integer not null, primary key +# name :string(40) not null +# title :string(255) not null +# slug :string(255) not null +# meta_description :string(255) +# nofollow :boolean default(FALSE) +# type_of :integer not null +# article_id :integer +# small_text :text(65535) +# full_text :text(16777215) +# updated_at :datetime +# updated_by :bigint(8) +# published :boolean default(FALSE), not null +# + # Model for allpages that are not published class AllPage < ApplicationRecord extend FriendlyId diff --git a/app/models/article.rb b/app/models/article.rb index 69fd14b..6986135 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,3 +1,13 @@ +# == Schema Information +# +# Table name: articles +# +# id :integer not null, primary key +# name :string(255) not null +# updated_at :datetime +# updated_by :bigint(8) +# + # Articles for page class Article < ApplicationRecord has_many :all_pages, dependent: :destroy diff --git a/app/models/cart.rb b/app/models/cart.rb index 8a46062..5011219 100644 --- a/app/models/cart.rb +++ b/app/models/cart.rb @@ -1,8 +1,36 @@ +# == Schema Information +# +# Table name: carts +# +# id :bigint(8) not null, primary key +# uuid :string(80) not null +# ip :string(255) +# useragent :string(255) +# created_at :datetime +# updated_at :datetime +# + # Shopping carts model class Cart < ApplicationRecord + # == Constants ============================================================ + + # == Attributes =========================================================== + + # == Extensions =========================================================== + + # == Relationships ======================================================== has_many :cart_products, -> { joins(:product).order('products.name ASC') } has_one :order + # == Validations ========================================================== + + # == Scopes =============================================================== + + # == Callbacks ============================================================ + + # == Class Methods ======================================================== + + # == Instance Methods ===================================================== def cart_value cart_products.sum('cart_products.price * cart_products.quantity') end diff --git a/app/models/cart_product.rb b/app/models/cart_product.rb index 983e286..175a16f 100644 --- a/app/models/cart_product.rb +++ b/app/models/cart_product.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: cart_products +# +# id :bigint(8) not null, primary key +# cart_id :bigint(8) not null +# product_id :integer not null +# quantity :integer not null +# price :decimal(10, 2) not null +# created_at :datetime +# updated_at :datetime +# + # Shopping cart_products class CartProduct < ApplicationRecord belongs_to :cart diff --git a/app/models/category.rb b/app/models/category.rb index 262d267..3201ad5 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: categories +# +# id :integer not null, primary key +# parent_id :integer default(0), not null +# level_depth :integer default(0), not null +# name :string(255) not null +# slug :string(255) not null +# active :boolean default(TRUE), not null +# created_at :datetime +# created_by :bigint(8) +# updated_at :datetime +# updated_by :bigint(8) +# + # Categories class Category < ApplicationRecord extend FriendlyId diff --git a/app/models/image.rb b/app/models/image.rb index 66857a5..23b853f 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: images +# +# id :integer not null, primary key +# imageable_type :string(255) not null +# imageable_id :bigint(8) not null +# image_file_name :string(255) not null +# image_content_type :string(255) not null +# image_file_size :integer not null +# updated_at :datetime +# updated_by :integer +# position :integer default(0), not null +# cover :boolean default(FALSE), not null +# active :boolean default(TRUE), not null +# + # Model store Images for products, categories etc class Image < ApplicationRecord belongs_to :imageable, polymorphic: true @@ -14,7 +31,8 @@ class Image < ApplicationRecord } # before_post_process :rename_file validates_attachment_content_type :image, content_type: /\Aimage/ - validates_attachment_file_name :image, matches: [/png\z/, /jpe?g\z/, /PNG\z/, /JPE?G\z/] + validates_attachment_file_name :image, matches: [/png\z/, /jpe?g\z/, + /PNG\z/, /JPE?G\z/] do_not_validate_attachment_file_type :image scope :by_image_type, ->(type) { where(imageable_type: type) } scope :by_position_desc, -> { order(position: :desc) } diff --git a/app/models/order.rb b/app/models/order.rb index ca74389..e7b78ba 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,3 +1,29 @@ +# == Schema Information +# +# Table name: orders +# +# id :bigint(8) not null, primary key +# order_number :integer +# cart_id :bigint(8) not null +# shipping_id :integer +# payment_method_id :integer +# terms_of_service_acceptance :boolean +# email :string(255) +# first_name :string(80) +# last_name :string(80) +# phone :string(15) +# street :string(255) +# city :string(80) +# zip_code :string(10) +# voivodeship :string(255) +# country :string(255) +# message_from_client :text(65535) +# status :integer default(0), not null +# created_at :datetime +# updated_at :datetime +# updated_by :bigint(8) +# + # order model class Order < ApplicationRecord belongs_to :cart diff --git a/app/models/order_faq.rb b/app/models/order_faq.rb index 0d5c3d1..4689b92 100644 --- a/app/models/order_faq.rb +++ b/app/models/order_faq.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: order_faqs +# +# id :integer not null, primary key +# title :string(40) not null +# description :text(65535) not null +# position :integer default(0), not null +# active :integer default(0), not null +# created_at :datetime +# created_by :bigint(8) +# updated_at :datetime +# updated_by :bigint(8) +# + # order FAQ class class OrderFaq < ApplicationRecord scope :available, -> { where(active: true) } diff --git a/app/models/order_history.rb b/app/models/order_history.rb index 53a7514..152011e 100644 --- a/app/models/order_history.rb +++ b/app/models/order_history.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: order_histories +# +# id :bigint(8) unsigned, not null, primary key +# order_id :bigint(8) not null +# status :integer not null +# created_at :datetime +# created_by :integer +# + # Order change status history class OrderHistory < ApplicationRecord belongs_to :order diff --git a/app/models/order_product.rb b/app/models/order_product.rb index 929a410..965a074 100644 --- a/app/models/order_product.rb +++ b/app/models/order_product.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: order_products +# +# id :integer not null, primary key +# order_id :integer not null +# product_id :integer not null +# quantity :integer not null +# price :decimal(10, 2) not null +# created_at :datetime +# updated_at :datetime +# + # order products model class OrderProduct < ApplicationRecord belongs_to :product diff --git a/app/models/payment_method.rb b/app/models/payment_method.rb index 61c4ead..b353a16 100644 --- a/app/models/payment_method.rb +++ b/app/models/payment_method.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: payment_methods +# +# id :integer not null, primary key +# name :string(40) not null +# description :string(255) not null +# default :boolean default(FALSE), not null +# active :boolean default(FALSE), not null +# created_at :datetime +# created_by :integer +# updated_at :datetime +# updated_by :integer +# + # metody platnosci class PaymentMethod < ApplicationRecord has_many :orders diff --git a/app/models/product.rb b/app/models/product.rb index 2d821c3..038899b 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: products +# +# id :integer unsigned, not null, primary key +# name :string(255) not null +# slug :string(255) not null +# description :text(65535) +# description_short :text(65535) +# default_category_id :integer not null +# price :decimal(10, 2) not null +# quantity :integer default(0), not null +# chk_quantity :boolean default(FALSE), not null +# active :boolean default(FALSE), not null +# created_at :datetime +# created_by :bigint(8) unsigned +# updated_at :datetime +# updated_by :bigint(8) unsigned +# + # products goes here class Product < ApplicationRecord extend FriendlyId diff --git a/app/models/published_page.rb b/app/models/published_page.rb index f4b17a2..1beaac0 100644 --- a/app/models/published_page.rb +++ b/app/models/published_page.rb @@ -1,3 +1,26 @@ +# == Schema Information +# +# Table name: published_pages +# +# id :integer not null, primary key +# name :string(40) not null +# title :string(255) not null +# slug :string(255) not null +# meta_description :string(255) +# all_page_id :integer not null +# nofollow :boolean default(FALSE), not null +# number_of_views :integer default(0), not null +# type_of :integer not null +# article_id :integer +# priority :integer default(0), not null +# small_text :text(65535) +# full_text :text(16777215) +# created_at :datetime +# created_by :bigint(8) +# updated_at :datetime +# updated_by :bigint(8) +# + # All published pages class PublishedPage < ApplicationRecord extend FriendlyId diff --git a/app/models/sc_setting.rb b/app/models/sc_setting.rb index 5430c1f..3c4c26d 100644 --- a/app/models/sc_setting.rb +++ b/app/models/sc_setting.rb @@ -1,3 +1,22 @@ +# == Schema Information +# +# Table name: sc_settings +# +# id :integer not null, primary key +# index_number_of_views :integer default(0), not null +# contact_number_of_views :integer default(0), not null +# shop_name :string(255) +# chk_quantity_global :boolean default(FALSE), not null +# shop_active :boolean default(TRUE), not null +# index_page_first_info :text(4294967295) +# index_page_second_info :text(4294967295) +# index_page_content :text(4294967295) +# shop_owners_emails :text(65535) +# recaptcha_chk :boolean default(FALSE), not null +# updated_at :datetime +# updated_by :integer +# + # main setting is stored in this model class ScSetting < ApplicationRecord has_one :image, as: :imageable, dependent: :destroy diff --git a/app/models/shipping.rb b/app/models/shipping.rb index 5a88a54..611790e 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: shippings +# +# id :integer not null, primary key +# name :string(255) not null +# price :decimal(10, 2) not null +# default :boolean default(FALSE), not null +# active :boolean default(TRUE), not null +# created_at :datetime +# created_by :bigint(8) +# updated_at :datetime +# updated_by :bigint(8) +# + # shipping class class Shipping < ApplicationRecord has_many :orders diff --git a/test/models/admin_test.rb b/test/models/admin_test.rb index ab20b8c..326a12d 100644 --- a/test/models/admin_test.rb +++ b/test/models/admin_test.rb @@ -1,3 +1,26 @@ +# == Schema Information +# +# Table name: admins +# +# id :bigint(8) not null, primary key +# email :string(255) default(""), not null +# description :string(80) +# encrypted_password :string(255) default(""), not null +# reset_password_token :string(255) +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default(0), not null +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string(255) +# last_sign_in_ip :string(255) +# failed_attempts :integer default(0), not null +# unlock_token :string(255) +# locked_at :datetime +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class AdminTest < ActiveSupport::TestCase