Wednesday, September 4, 2019

Online Shop Web Design

Online Shop Web Design Shop Online Web Application system, allows the customer to shop online for their required items, and also represents an associated window for the orders selected by the customer. Each Customer will be having their desired page when they login or signup into the Shop Online Web Application. The Customer can select the required items into the cart without logging into their account. But the purchase of the items in the cart has to be done using their registered account in the System using either credit or debit card, they can also cancel the payment or return the items purchased only after a detailed specification of the reason for it. The Logged In customers will be having a wish-list function so that they can put the items they wanted to buy in the wish-list and can buy later. There is one more function price checker, which intimates the customer regarding the item selected by them whenever there is a cut-off in the price of that item, but only for a few selected items. There is also a desired page for the history of items bought by the customers.   The customer can maintain their account and address details. The customer also can reset their password if forgotten by getting a link to reset password to their concerned web mail. Requirements for the system are we will be using Ruby On Rails for the development, and for the web design HTML, Javascript and CSS. The Backend is managed by MySQL. The Database for the System consists of shop online development database which consist of tables for categories, products, product images, users. The Columns for the categories are id, title, weight, products_counter, created_at, updated_at, ancestry. The Columns for products are id, category_id, titile, status, amount, uuid, msrp, price, description, created_at, updated_at, lprice. The Columns for the product images are id, product_id, weight, image_file_name, image_content_type, image_file_sizee, image_updated_at, created_at, updated_at. The Columns for the users are id, email, crypted_password, created_at, updated_at,activation_state, activation_token, activation_token_expires_at, remember_me_token, remember_me_token_expires_at, reset_password_token, reset_password_token_expires_at, reset_password_email_sent_at. Entity Relationship Diagram: FIG. 1 (Relationship between the tables) In ruby on rails the web application code is divided into model, view, controller. Model represents the database access, View represents the html pages before and after access of the database, and controller represents the action to be done once the we get a request from the Web Application. Model Code: (Category) class Category < ApplicationRecord    validates :title, presence: { message: Empty name! }    validates :title, uniqueness: { message: Repeated name! }    has_ancestry orphan_strategy: :destroy    has_many :products, dependent: :destroy    before_validation :correct_ancestry    def self.grouped_data   Ã‚  Ã‚   self.roots.order(weight desc).inject([]) do |result, parent|   Ã‚  Ã‚  Ã‚  Ã‚   row = []   Ã‚  Ã‚  Ã‚  Ã‚   row { where(status: Status::On) }    module Status   Ã‚  Ã‚   On = on   Ã‚  Ã‚   Off = off    end    private    def set_default_attrs   Ã‚  Ã‚   self.uuid = RandomCode.generate_product_uuid    end end (product image): class ProductImage < ApplicationRecord    belongs_to :product    has_attached_file :image, styles: {   Ã‚  Ã‚  Ã‚  Ã‚   small: 60^x60,   Ã‚  Ã‚  Ã‚  Ã‚   middle: 200^x200,   Ã‚  Ã‚  Ã‚  Ã‚   big: 960x    }    validates_attachment_content_type :image, content_type: /Aimage/.*Z/    validates_attachment_size :image, in: 0..5.megabytes end (User): class User < ApplicationRecord    authenticates_with_sorcery!    attr_accessor :password, :password_confirmation    validates_presence_of :email, message: Email cannot be empty!    validates_format_of :email,message: Email format mistake!,   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   with: /w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/,   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   if: proc { |user| !user.email.blank? }    validates :email, uniqueness: true    validates_presence_of :password, message: Password cannot be empty!,   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   if: :need_validate_password    validates_presence_of :password_confirmation, message: Password confirm cannot be empty!,   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   if: :need_validate_password    validates_confirmation_of :password,message: Password not right ,   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   if: :need_validate_password    validates_length_of :password, message: Password at least 6 digits, minimum: 6,   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   if: :need_validate_password    def username   Ã‚  Ã‚   self.email.split(@).first    end    private    def need_validate_password   Ã‚  Ã‚  Ã‚   self.new_record? || (!self.password.nil?||!self.password_confirmation.nil?)    end end Controller Code: (Category) class CategoriesController < ApplicationController    def show   Ã‚  Ã‚   @categories = Category.grouped_data   Ã‚  Ã‚   @category = Category.find(params[:id])   Ã‚  Ã‚   @products = @category.products.onshelf.page(params[:page] || 1).per_page(params[:per_page] || 12)   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   .order(id desc).includes(:main_product_image)    end end (Product): class ProductsController < ApplicationController    def show   Ã‚  Ã‚   @categories = Category.grouped_data   Ã‚  Ã‚   @product = Product.find(params[:id])    end end (Session): class SessionsController < ApplicationController    def new    end    def create   Ã‚  Ã‚   if user= login(params[:email],params[:password])#loginsorcery   Ã‚  Ã‚  Ã‚  Ã‚   flash[:notice]=You have logged in!   Ã‚  Ã‚  Ã‚  Ã‚   redirect_to root_path   Ã‚  Ã‚   else   Ã‚  Ã‚  Ã‚  Ã‚   flash[:notice]=Emails or Password mistake   Ã‚  Ã‚  Ã‚  Ã‚   redirect_to new_session_path   Ã‚  Ã‚   end    end    def destroy   Ã‚  Ã‚   logout   Ã‚  Ã‚   flash[:notice]=You already logged out!   Ã‚  Ã‚   redirect_to root_path    end end (User): class UsersController < ApplicationController    def new   Ã‚  Ã‚   @user = User.new    end    def create   Ã‚  Ã‚   @user= User.new(params.require(:user).permit(:email,:password,:password_confirmation))   Ã‚  Ã‚   if @user.save   Ã‚  Ã‚  Ã‚  Ã‚   flash[:notice] = sign up successfully! Please log in   Ã‚  Ã‚  Ã‚  Ã‚   redirect_to new_session_path   Ã‚  Ã‚   else   Ã‚  Ã‚  Ã‚  Ã‚   render action: :new   Ã‚  Ã‚   end    end end (Welcome): class WelcomeController < ApplicationController    def index   Ã‚  Ã‚   @categories = Category.grouped_data   Ã‚  Ã‚   @products = Product.onshelf.page(params[:page] || 1).per_page(params[:per_page] || 12)   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Ã‚   .order(id desc).includes(:main_product_image)    end end

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.