Merge pull request '调整返回值' (#123) from KingChan/forgeplus:chenjing into standalone_develop
This commit is contained in:
commit
cded93715d
|
@ -2,11 +2,12 @@ class SitePagesController < ApplicationController
|
||||||
before_action :require_login, except: [:softbot_build, :themes]
|
before_action :require_login, except: [:softbot_build, :themes]
|
||||||
before_action :require_profile_completed, only: [:create]
|
before_action :require_profile_completed, only: [:create]
|
||||||
before_action :load_project, except: [:softbot_build, :index, :themes]
|
before_action :load_project, except: [:softbot_build, :index, :themes]
|
||||||
before_action :authenticate_user!, except: [:softbot_build, :index, :themes]
|
before_action :authenticate_user!, except: [:softbot_build, :index, :themes, :show]
|
||||||
|
before_action :authenticate_member!, only: [:show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@pages = PageQuery.call(params,current_user)
|
pages = PageQuery.call(params,current_user)
|
||||||
@pages = paginate(@pages)
|
@pages = paginate(pages)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -66,6 +67,12 @@ class SitePagesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authenticate_member!
|
||||||
|
unless @project.member?(current_user) || current_user.admin?
|
||||||
|
return render_forbidden('你不是成员,没有权限操作')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def theme_params
|
def theme_params
|
||||||
params[:language_frame] || "hugo"
|
params[:language_frame] || "hugo"
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,11 +3,11 @@ class PageQuery < ApplicationQuery
|
||||||
|
|
||||||
def initialize(params, user)
|
def initialize(params, user)
|
||||||
@user = user
|
@user = user
|
||||||
|
@params = params
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
pages = Page.where(user: @user)
|
pages = Page.where(user: @user)
|
||||||
|
|
||||||
pages
|
pages
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
json.total_count @pages.size
|
json.total_count @pages.total_count
|
||||||
json.pages @pages.each do |page|
|
json.pages @pages.each do |page|
|
||||||
json.partial! 'info', locals: {page: page}
|
json.partial! 'info', locals: {page: page}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue