This commit is contained in:
呱呱呱 2023-08-24 17:03:22 +08:00
parent 31bb2502b8
commit eb449f9937
3 changed files with 12 additions and 5 deletions

View File

@ -2,11 +2,12 @@ class SitePagesController < ApplicationController
before_action :require_login, except: [:softbot_build, :themes]
before_action :require_profile_completed, only: [:create]
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
@pages = PageQuery.call(params,current_user)
@pages = paginate(@pages)
pages = PageQuery.call(params,current_user)
@pages = paginate(pages)
end
def show
@ -66,6 +67,12 @@ class SitePagesController < ApplicationController
end
end
def authenticate_member!
unless @project.member?(current_user) || current_user.admin?
return render_forbidden('你不是成员,没有权限操作')
end
end
def theme_params
params[:language_frame] || "hugo"
end

View File

@ -3,11 +3,11 @@ class PageQuery < ApplicationQuery
def initialize(params, user)
@user = user
@params = params
end
def call
pages = Page.where(user: @user)
pages
end
end

View File

@ -1,4 +1,4 @@
json.total_count @pages.size
json.total_count @pages.total_count
json.pages @pages.each do |page|
json.partial! 'info', locals: {page: page}
end