fix: issue change operate permission and repository detail remove garbage
This commit is contained in:
parent
f957b6f95e
commit
46ab55d50f
|
@ -15,7 +15,7 @@ class IssuesController < ApplicationController
|
|||
include TagChosenHelper
|
||||
|
||||
def index
|
||||
@user_admin_or_member = current_user.present? && current_user.logged? && (current_user.admin || @project.member?(current_user))
|
||||
@user_admin_or_member = current_user.present? && current_user.logged? && (current_user.admin || @project.member?(current_user) || @project.is_public?)
|
||||
issues = @project.issues.issue_issue.issue_index_includes
|
||||
issues = issues.where(is_private: false) unless @user_admin_or_member
|
||||
|
||||
|
@ -453,7 +453,7 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
def operate_issue_permission
|
||||
return render_forbidden("您没有权限进行此操作.") unless current_user.admin? || @project.member?(current_user)
|
||||
return render_forbidden("您没有权限进行此操作.") unless current_user.present? && current_user.logged? && (current_user.admin? || @project.member?(current_user) || @project.is_public?)
|
||||
end
|
||||
|
||||
def export_issues(issues)
|
||||
|
|
|
@ -55,16 +55,6 @@ class RepositoriesController < ApplicationController
|
|||
@entries = Gitea::Repository::Entries::ListService.new(@owner, @project.identifier, ref: @ref).call
|
||||
@entries = @entries.present? ? @entries.sort_by{ |hash| hash['type'] } : []
|
||||
@path = Gitea.gitea_config[:domain]+"/#{@project.owner.login}/#{@project.identifier}/raw/branch/#{@ref}/"
|
||||
|
||||
# TODO
|
||||
# 临时处理readme文件问题
|
||||
result = Gitea::Repository::Readme::GetService.call(@owner.login, @project.identifier, @ref, @owner&.gitea_token)
|
||||
@readme =
|
||||
if result[:status] == :success
|
||||
result[:body]
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,29 +8,25 @@ class Repositories::DetailService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
if @repo.project.educoder?
|
||||
return {
|
||||
repo: {},
|
||||
release: [],
|
||||
branch: [],
|
||||
branch_type: [],
|
||||
tag: [],
|
||||
contributor: [],
|
||||
language: {},
|
||||
readme: {}
|
||||
}
|
||||
else
|
||||
return {
|
||||
repo: repo_suitable,
|
||||
release: release_suitable,
|
||||
branch: branch_suitable,
|
||||
branch_slice: branch_slice_suitable,
|
||||
tag: tag_suitable,
|
||||
contributor: contributor_suitable,
|
||||
language: language_suitable,
|
||||
readme: readme_suitable
|
||||
}
|
||||
end
|
||||
return {
|
||||
repo: repo_suitable,
|
||||
release: release_suitable,
|
||||
branch: branch_suitable,
|
||||
tag: tag_suitable,
|
||||
contributor: contributor_suitable,
|
||||
language: language_suitable
|
||||
}
|
||||
rescue
|
||||
return {
|
||||
repo: {},
|
||||
release: [],
|
||||
branch: [],
|
||||
branch_type: [],
|
||||
tag: [],
|
||||
contributor: [],
|
||||
language: {},
|
||||
readme: {}
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -48,11 +44,6 @@ class Repositories::DetailService < ApplicationService
|
|||
branches.is_a?(Hash) && branches.key?(:status) ? [] : branches
|
||||
end
|
||||
|
||||
def branch_slice_suitable
|
||||
branches = Gitea::Repository::Branches::ListSliceService.call(@owner, @repo.identifier)
|
||||
branches.is_a?(Hash) && branches.key?(:status) ? [] : branches
|
||||
end
|
||||
|
||||
def tag_suitable
|
||||
tags = Gitea::Repository::Tags::ListService.call(@owner&.gitea_token, @owner.login, @repo.identifier)
|
||||
tags.is_a?(Hash) && tags[:status] == -1 ? [] : tags
|
||||
|
@ -67,9 +58,4 @@ class Repositories::DetailService < ApplicationService
|
|||
result = Gitea::Repository::Languages::ListService.call(@owner.login, @repo.identifier, @user&.gitea_token)
|
||||
result[:status] === :success ? hash_transform_precentagable(result[:body]) : nil
|
||||
end
|
||||
|
||||
def readme_suitable
|
||||
result = Gitea::Repository::Readme::GetService.call(@owner.login, @repo.identifier, @repo.default_branch, @owner.gitea_token)
|
||||
result[:status] === :success ? result[:body] : nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
json.content @project.content
|
||||
json.website @project.website
|
||||
json.lesson_url @project.lesson_url
|
||||
if @result[:readme].blank?
|
||||
json.readme nil
|
||||
else
|
||||
json.readme @result[:readme].merge(content: readme_render_decode64_content(@result[:readme]["content"], nil))
|
||||
end
|
||||
json.identifier render_identifier(@project)
|
||||
json.invite_code @project.invite_code
|
||||
json.name @project.name
|
||||
|
@ -72,15 +67,6 @@ json.branches do
|
|||
end
|
||||
json.total_count @result[:branch].size
|
||||
end
|
||||
json.branches_slice do
|
||||
json.list @result[:branch_slice].each do |branch_slice|
|
||||
json.branch_type branch_slice["branch_name"]
|
||||
json.list branch_slice["branches"].each do |branch|
|
||||
json.name branch["name"]
|
||||
end
|
||||
end
|
||||
json.total_count @result[:branch_slice].size
|
||||
end
|
||||
json.tags do
|
||||
json.list @result[:tag].each do |tag|
|
||||
json.name tag["name"]
|
||||
|
@ -104,6 +90,6 @@ json.contributors do
|
|||
end
|
||||
json.total_count total_count
|
||||
end
|
||||
json.languages @result[:language]
|
||||
json.languages @result[:language].blank? ? nil : @result[:language]
|
||||
|
||||
json.partial! 'author', locals: { user: @project.owner }
|
||||
|
|
|
@ -61,5 +61,4 @@ if @project.forge?
|
|||
end
|
||||
end
|
||||
|
||||
json.readme @readme.merge(content: readme_render_decode64_content(@readme["content"], nil))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue