added annotations in models
gem annotate generated schema informations
This commit is contained in:
parent
deb4417841
commit
ca5d3b711b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue