Browse Source

新增:个人项目分页limit使用9999

pull/343/head
yystopf 3 years ago
parent
commit
b37ff07bcf
2 changed files with 9 additions and 1 deletions
  1. +8
    -0
      app/controllers/application_controller.rb
  2. +1
    -1
      app/controllers/users_controller.rb

+ 8
- 0
app/controllers/application_controller.rb View File

@@ -680,6 +680,14 @@ class ApplicationController < ActionController::Base
relation.page(page).per(limit)
end

def kaminari_unlimit_paginate(ralation)
limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 9999) ? 9999 : limit.to_i
page = params[:page].to_i.zero? ? 1 : params[:page].to_i

relation.page(page).per(limit)
end

def kaminari_array_paginate(relation)
limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 20) ? 20 : limit.to_i


+ 1
- 1
app/controllers/users_controller.rb View File

@@ -281,7 +281,7 @@ class UsersController < ApplicationController
is_current_admin_user = User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
scope = Projects::ListMyQuery.call(params, @user,is_current_admin_user)
@total_count = scope.size
@projects = paginate(scope)
@projects = kaminari_unlimit_paginate(scope)
end

# TODO 其他平台登录时同步修改gitea平台对应用户的密码


Loading…
Cancel
Save