Skip to content

Commit

Permalink
pos and shop model
Browse files Browse the repository at this point in the history
  • Loading branch information
chonglou committed Jul 8, 2017
1 parent fe366b2 commit c299d88
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 2 deletions.
17 changes: 17 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@ def dashboard
{label: 'attachments.index.title', href: attachments_path},
]
},
{
label: '.shopping',
links: [

],
},
]
forum_links = [
{label: 'forum.articles.new.title', href: new_forum_article_path},
{label: 'forum.articles.index.title', href: forum_articles_path},
{label: 'forum.comments.index.title', href: forum_comments_path},
]

mall_card = {
label: '.mall',
links: [
{label: 'mall.stores.index.title', href: mall_stores_path}
],
}

if current_user.is_admin?
@cards << {
label: '.site',
Expand All @@ -47,7 +60,11 @@ def dashboard
]
}

@cards << mall_card

forum_links << {label: 'forum.tags.index.title', href: forum_tags_path}
elsif current_user.is_member?
@cards << mall_card
end

@cards << {label: '.forum', links: forum_links}
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/mall/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Mall::HomeController < ApplicationController
def index
end
end
4 changes: 4 additions & 0 deletions app/controllers/pos/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Pos::HomeController < ApplicationController
def index
end
end
4 changes: 4 additions & 0 deletions app/controllers/shop/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Shop::HomeController < ApplicationController
def index
end
end
1 change: 1 addition & 0 deletions app/models/mall/store.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Mall::Store < ApplicationRecord
resourcify
end
40 changes: 40 additions & 0 deletions app/policies/mall/store_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module Mall
class StorePolicy
attr_reader :user, :record

def initialize(user, record)
@user = user
@record = record
end

def index?
create?
end

def create?
!user.nil? && user.has_role?(:member)
end

def new?
create?
end

def edit?
update?
end

def update?
!user.nil? && (user.has_role? :manager, record)
end

def destroy?
update?
end

def sell?
!user.nil? && (user.has_role? :seller, record)
end


end
end
2 changes: 2 additions & 0 deletions app/views/mall/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Mall::Home#index</h1>
<p>Find me in app/views/mall/home/index.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/pos/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Pos::Home#index</h1>
<p>Find me in app/views/pos/home/index.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/shop/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Shop::Home#index</h1>
<p>Find me in app/views/shop/home/index.html.erb</p>
2 changes: 2 additions & 0 deletions config/locales/mall.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
mall:
2 changes: 2 additions & 0 deletions config/locales/mall.zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
zh-CN:
mall:
2 changes: 2 additions & 0 deletions config/locales/pos.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
pos:
2 changes: 2 additions & 0 deletions config/locales/pos.zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
zh-CN:
pos:
2 changes: 2 additions & 0 deletions config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ zh-CN:
site: 站点设置
forum: 社区
survey: 问卷调查
mall: 商店
shopping: 购物
donate:
title: 捐赠
admin:
Expand Down
27 changes: 25 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,35 @@

Rails.application.routes.draw do

# pos
namespace :pos do
root to:'home#index'
resources :orders, except: [:show, :destroy]
resources :returns, except: [:show, :destroy]
end

# shop
namespace :shop do
root to:'home#index'
resources :stores, only:[:index, :show]
resources :products, only:[:index, :show]
resources :variants, only:[:index, :show]
end

# mall
namespace :mall do
resources :products
resources :stores
resources :variants
resources :catalogs

# resources :products
# resources :variants
# resources :addresses
# resources :payment_methods
# resources :payments
# resources :shipping_methods
# resources :shipments

root to: 'home#index'
end

# survey
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170707181427_create_mall_catalogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def change

t.integer :sort_order, limit:1, null:false

t.belongs_to :mall_store, index: true, null: false
t.timestamps
end
end
Expand Down
2 changes: 2 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@
t.text "description", null: false
t.text "assets"
t.integer "sort_order", limit: 2, null: false
t.bigint "mall_store_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["format"], name: "index_mall_catalogs_on_format"
t.index ["mall_store_id"], name: "index_mall_catalogs_on_mall_store_id"
t.index ["name"], name: "index_mall_catalogs_on_name"
end

Expand Down

0 comments on commit c299d88

Please sign in to comment.