动态导航权限控制,没有勾选模块不能进入页面,语言过滤0.0%

动态导航权限控制,没有勾选模块不能进入页面,语言过滤0.0%
This commit is contained in:
jasder 2021-03-19 18:40:23 +08:00
commit c07c570061
6 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,6 @@ module Repository::LanguagesPercentagable
hash.transform_values { |v|
ActionController::Base.helpers
.number_to_percentage((v * 100.0 / total_byte_size), precision: 1)
}
}.select{|k,v| v != "0.0%"}
end
end

View File

@ -12,6 +12,7 @@ class IssuesController < ApplicationController
include TagChosenHelper
def index
return render_not_found unless @project.has_menu_permission("issues")
@user_admin_or_member = current_user.present? && current_user.logged? && (current_user.admin || @project.member?(current_user))
issues = @project.issues.issue_issue.issue_index_includes
issues = issues.where(is_private: false) unless @user_admin_or_member

View File

@ -8,6 +8,7 @@ class PullRequestsController < ApplicationController
def index
return render_not_found unless @project.has_menu_permission("pulls")
# @issues = Gitea::PullRequest::ListService.new(@user,@repository.try(:identifier)).call #通过gitea获取
issues = @project.issues.issue_pull_request.issue_index_includes.includes(pull_request: :user)
issues = issues.where(is_private: false) unless current_user.present? && (current_user.admin? || @project.member?(current_user))

View File

@ -18,6 +18,7 @@ class RepositoriesController < ApplicationController
# 新版项目详情
def detail
return render_not_found unless @project.has_menu_permission("code")
@user = current_user
@result = Repositories::DetailService.call(@owner, @repository, @user)
@project_fork_id = @project.try(:forked_from_project_id)

View File

@ -5,6 +5,7 @@ class VersionsController < ApplicationController
before_action :set_version, only: [:edit, :update, :destroy, :show,:update_status]
def index
return render_not_found unless @project.has_menu_permission("versions")
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
order_name = params[:order_name] || "created_on"
order_type = params[:order_type] || "desc"

View File

@ -9,6 +9,7 @@ class Projects::MigrateService < ApplicationService
def call
@project = Project.new(project_params)
if @project.save!
ProjectUnit.init_types(@project.id)
Project.update_mirror_projects_count!
Repositories::MigrateService.new(user, @project, repository_params).call
else