Browse Source

Merge pull request '调整返回值' (#123) from KingChan/forgeplus:chenjing into standalone_develop

pull/338/head
KingChan 2 years ago
parent
commit
cded93715d
3 changed files with 12 additions and 5 deletions
  1. +10
    -3
      app/controllers/site_pages_controller.rb
  2. +1
    -1
      app/queries/page_query.rb
  3. +1
    -1
      app/views/site_pages/index.json.jbuilder

+ 10
- 3
app/controllers/site_pages_controller.rb 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


+ 1
- 1
app/queries/page_query.rb 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

+ 1
- 1
app/views/site_pages/index.json.jbuilder 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

Loading…
Cancel
Save