Merge pull request '一些功能修改以及bug修复' (#263) from yystopf/forgeplus:hh_hotfix into develop
|
@ -43,7 +43,7 @@ class CompareController < ApplicationController
|
||||||
|
|
||||||
def load_compare_params
|
def load_compare_params
|
||||||
@base = Addressable::URI.unescape(params[:base])
|
@base = Addressable::URI.unescape(params[:base])
|
||||||
@head = params[:head].include?('json') ? params[:head]&.split('.json')[0] : params[:head]
|
@head = params[:head].include?('.json') ? params[:head][0..-6] : params[:head]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ForksController < ApplicationController
|
||||||
if current_user&.id == @project.user_id
|
if current_user&.id == @project.user_id
|
||||||
render_result(-1, "自己不能fork自己的项目")
|
render_result(-1, "自己不能fork自己的项目")
|
||||||
elsif Project.exists?(user_id: current_user.id, identifier: @project.identifier)
|
elsif Project.exists?(user_id: current_user.id, identifier: @project.identifier)
|
||||||
render_result(-1, "fork失败,你已拥有了这个项目")
|
render_result(0, "fork失败,你已拥有了这个项目")
|
||||||
end
|
end
|
||||||
# return if current_user != @project.owner
|
# return if current_user != @project.owner
|
||||||
# render_result(-1, "自己不能fork自己的项目")
|
# render_result(-1, "自己不能fork自己的项目")
|
||||||
|
|
|
@ -2,7 +2,7 @@ class IssueTagsController < ApplicationController
|
||||||
before_action :require_login, except: [:index]
|
before_action :require_login, except: [:index]
|
||||||
before_action :load_repository
|
before_action :load_repository
|
||||||
before_action :set_user
|
before_action :set_user
|
||||||
before_action :check_issue_permission, except: :index
|
before_action :check_issue_tags_permission
|
||||||
before_action :set_issue_tag, only: [:edit, :update, :destroy]
|
before_action :set_issue_tag, only: [:edit, :update, :destroy]
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,9 +122,9 @@ class IssueTagsController < ApplicationController
|
||||||
@user = @project.owner
|
@user = @project.owner
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_issue_permission
|
def check_issue_tags_permission
|
||||||
unless @project.member?(current_user) || current_user.admin?
|
unless @project.manager?(current_user) || current_user.admin?
|
||||||
normal_status(-1, "您没有权限")
|
return render_forbidden('你不是管理员,没有权限操作')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class MembersController < ApplicationController
|
||||||
before_action :load_project
|
before_action :load_project
|
||||||
before_action :find_user_with_id, only: %i[create remove change_role]
|
before_action :find_user_with_id, only: %i[create remove change_role]
|
||||||
before_action :check_user_profile_completed, only: [:create]
|
before_action :check_user_profile_completed, only: [:create]
|
||||||
before_action :operate!, except: %i[index]
|
before_action :operate!
|
||||||
before_action :check_member_exists!, only: %i[create]
|
before_action :check_member_exists!, only: %i[create]
|
||||||
before_action :check_member_not_exists!, only: %i[remove change_role]
|
before_action :check_member_not_exists!, only: %i[remove change_role]
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
@organization.save!
|
@organization.save!
|
||||||
sync_organization_extension!
|
sync_organization_extension!
|
||||||
|
|
||||||
Gitea::Organization::UpdateService.call(@organization.gitea_token, login, @organization.reload)
|
Gitea::Organization::UpdateService.call(current_user.gitea_token, login, @organization.reload)
|
||||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
@ -57,10 +57,14 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
||||||
def destroy
|
def destroy
|
||||||
tip_exception("密码不正确") unless current_user.check_password?(password)
|
tip_exception("密码不正确") unless current_user.check_password?(password)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
Gitea::Organization::DeleteService.call(@organization.gitea_token, @organization.login)
|
gitea_status, gitea_message = Gitea::Organization::DeleteService.call(current_user.gitea_token, @organization.login)
|
||||||
|
if gitea_status == 204
|
||||||
@organization.destroy!
|
@organization.destroy!
|
||||||
end
|
|
||||||
render_ok
|
render_ok
|
||||||
|
else
|
||||||
|
tip_exception("当组织内含有仓库时,无法删除此组织")
|
||||||
|
end
|
||||||
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
uid_logger_error(e.message)
|
uid_logger_error(e.message)
|
||||||
tip_exception(e.message)
|
tip_exception(e.message)
|
||||||
|
|
|
@ -56,6 +56,7 @@ class PullRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
return render_forbidden("你没有权限操作.") unless @project.operator?(current_user)
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
||||||
if @gitea_pull_request[:status] == :success
|
if @gitea_pull_request[:status] == :success
|
||||||
|
@ -78,6 +79,7 @@ class PullRequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
return render_forbidden("你没有权限操作.") unless @project.operator?(current_user)
|
||||||
if params[:title].nil?
|
if params[:title].nil?
|
||||||
normal_status(-1, "名称不能为空")
|
normal_status(-1, "名称不能为空")
|
||||||
elsif params[:issue_tag_ids].nil?
|
elsif params[:issue_tag_ids].nil?
|
||||||
|
@ -197,7 +199,7 @@ class PullRequestsController < ApplicationController
|
||||||
def check_can_merge
|
def check_can_merge
|
||||||
target_head = params[:head] #源分支
|
target_head = params[:head] #源分支
|
||||||
target_base = params[:base] #目标分支
|
target_base = params[:base] #目标分支
|
||||||
is_original = params[:is_original]
|
is_original = params[:is_original] || false
|
||||||
if target_head.blank? || target_base.blank?
|
if target_head.blank? || target_base.blank?
|
||||||
normal_status(-2, "请选择分支")
|
normal_status(-2, "请选择分支")
|
||||||
elsif target_head === target_base && !is_original
|
elsif target_head === target_base && !is_original
|
||||||
|
@ -228,11 +230,11 @@ class PullRequestsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
def load_pull_request
|
def load_pull_request
|
||||||
@pull_request = PullRequest.find params[:id]
|
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_pull_request
|
def find_pull_request
|
||||||
@pull_request = PullRequest.find_by_id(params[:id])
|
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||||
@issue = @pull_request&.issue
|
@issue = @pull_request&.issue
|
||||||
if @pull_request.blank?
|
if @pull_request.blank?
|
||||||
normal_status(-1, "合并请求不存在")
|
normal_status(-1, "合并请求不存在")
|
||||||
|
|
|
@ -32,7 +32,8 @@ class UsersController < ApplicationController
|
||||||
@waiting_applied_messages = @user.applied_messages.waiting
|
@waiting_applied_messages = @user.applied_messages.waiting
|
||||||
@common_applied_transfer_projects = AppliedTransferProject.where(owner_id: @user.id).common + AppliedTransferProject.where(owner_id: Organization.joins(team_users: :team).where(team_users: {user_id: @user.id}, teams: {authorize: %w(admin owner)} )).common
|
@common_applied_transfer_projects = AppliedTransferProject.where(owner_id: @user.id).common + AppliedTransferProject.where(owner_id: Organization.joins(team_users: :team).where(team_users: {user_id: @user.id}, teams: {authorize: %w(admin owner)} )).common
|
||||||
@common_applied_projects = AppliedProject.where(project_id: @user.full_admin_projects).common
|
@common_applied_projects = AppliedProject.where(project_id: @user.full_admin_projects).common
|
||||||
@undo_events = @waiting_applied_messages.size + @common_applied_transfer_projects.size + @common_applied_projects.size
|
#@undo_events = @waiting_applied_messages.size + @common_applied_transfer_projects.size + @common_applied_projects.size
|
||||||
|
@undo_events = @common_applied_transfer_projects.size + @common_applied_projects.size
|
||||||
else
|
else
|
||||||
@waiting_applied_messages = AppliedMessage.none
|
@waiting_applied_messages = AppliedMessage.none
|
||||||
@common_applied_transfer_projects = AppliedTransferProject.none
|
@common_applied_transfer_projects = AppliedTransferProject.none
|
||||||
|
|
|
@ -8,4 +8,11 @@ class Organizations::CreateForm < BaseForm
|
||||||
validates :description, length: { maximum: 200 }
|
validates :description, length: { maximum: 200 }
|
||||||
validates :name, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
validates :name, format: { with: NAME_REGEX, multiline: true, message: "只能含有数字、字母、下划线且不能以下划线开头和结尾" }
|
||||||
|
|
||||||
|
validate do
|
||||||
|
check_name(name) unless name.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_name(name)
|
||||||
|
raise "组织账号已被使用." if Owner.where(login: name.strip).exists?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Project < ApplicationRecord
|
||||||
after_create :incre_user_statistic, :incre_platform_statistic
|
after_create :incre_user_statistic, :incre_platform_statistic
|
||||||
after_save :check_project_members, :reset_cache_data
|
after_save :check_project_members, :reset_cache_data
|
||||||
before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned
|
before_save :set_invite_code, :reset_unmember_followed, :set_recommend_and_is_pinned
|
||||||
before_destroy :decre_project_common
|
before_destroy :decre_project_common, :decre_forked_from_project_count
|
||||||
after_destroy :decre_user_statistic, :decre_platform_statistic
|
after_destroy :decre_user_statistic, :decre_platform_statistic
|
||||||
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :description, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :description, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
||||||
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
||||||
|
@ -173,6 +173,14 @@ class Project < ApplicationRecord
|
||||||
CacheAsyncClearJob.perform_later('project_common_service', self.id)
|
CacheAsyncClearJob.perform_later('project_common_service', self.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def decre_forked_from_project_count
|
||||||
|
forked_project = self.forked_from_project
|
||||||
|
if forked_project.present?
|
||||||
|
forked_project.decrement(:forked_count, 1)
|
||||||
|
forked_project.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def incre_user_statistic
|
def incre_user_statistic
|
||||||
CacheAsyncSetJob.perform_later("user_statistic_service", {project_count: 1, project_language_count_key: self.project_language&.name, project_language_count: 1}, self.user_id)
|
CacheAsyncSetJob.perform_later("user_statistic_service", {project_count: 1, project_language_count_key: self.project_language&.name, project_language_count: 1}, self.user_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -144,6 +144,8 @@ class Gitea::ClientService < ApplicationService
|
||||||
{status: 403, message: '你没有权限操作!'}
|
{status: 403, message: '你没有权限操作!'}
|
||||||
when 404
|
when 404
|
||||||
{status: 404, message: '你访问的链接不存在!'}
|
{status: 404, message: '你访问的链接不存在!'}
|
||||||
|
when 500
|
||||||
|
{status: 500, message: ''}
|
||||||
else
|
else
|
||||||
if response&.body.blank?
|
if response&.body.blank?
|
||||||
message = "请求失败"
|
message = "请求失败"
|
||||||
|
|
|
@ -94,7 +94,7 @@ class PullRequests::CreateService < ApplicationService
|
||||||
user: @current_user,
|
user: @current_user,
|
||||||
issue: pull_issue,
|
issue: pull_issue,
|
||||||
fork_project_id: @params[:fork_project_id],
|
fork_project_id: @params[:fork_project_id],
|
||||||
is_original: @params[:is_original],
|
is_original: is_original,
|
||||||
files_count: @params[:files_count] || 0,
|
files_count: @params[:files_count] || 0,
|
||||||
commits_count: @params[:commits_count] || 0
|
commits_count: @params[:commits_count] || 0
|
||||||
})
|
})
|
||||||
|
@ -145,7 +145,13 @@ class PullRequests::CreateService < ApplicationService
|
||||||
raise "title参数不能为空" if @params[:title].blank?
|
raise "title参数不能为空" if @params[:title].blank?
|
||||||
raise "head参数不能为空" if @params[:head].blank?
|
raise "head参数不能为空" if @params[:head].blank?
|
||||||
raise "base参数不能为空" if @params[:base].blank?
|
raise "base参数不能为空" if @params[:base].blank?
|
||||||
|
raise "分支内容相同,无需创建合并请求" if @params[:head] === @params[:base] && !is_original
|
||||||
|
raise "合并请求已存在" if @project&.pull_requests.where(head: @params[:head], base: @params[:base], status: 0, is_original: is_original, fork_project_id: @params[:fork_project_id]).present?
|
||||||
raise @pull_issue.errors.full_messages.join(", ") unless pull_issue.valid?
|
raise @pull_issue.errors.full_messages.join(", ") unless pull_issue.valid?
|
||||||
raise @pull_request.errors.full_messages.join(", ") unless pull_request.valid?
|
raise @pull_request.errors.full_messages.join(", ") unless pull_request.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_original
|
||||||
|
@params[:is_original] || false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
project = object.project
|
project = object.project
|
||||||
json.project do
|
if project.present?
|
||||||
|
json.project do
|
||||||
json.id project.id
|
json.id project.id
|
||||||
json.identifier project.identifier
|
json.identifier project.identifier
|
||||||
json.name project.name
|
json.name project.name
|
||||||
|
@ -8,6 +9,9 @@ json.project do
|
||||||
json.owner do
|
json.owner do
|
||||||
json.partial! "/users/user_simple", locals: {user: project.owner}
|
json.partial! "/users/user_simple", locals: {user: project.owner}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
json.project nil
|
||||||
end
|
end
|
||||||
json.user do
|
json.user do
|
||||||
json.partial! "/users/user_simple", locals: {user: object.user}
|
json.partial! "/users/user_simple", locals: {user: object.user}
|
||||||
|
|
|
@ -14,6 +14,7 @@ json.issues do
|
||||||
json.array! @issues.to_a do |issue|
|
json.array! @issues.to_a do |issue|
|
||||||
pr = issue.pull_request
|
pr = issue.pull_request
|
||||||
json.pull_request_id pr.id
|
json.pull_request_id pr.id
|
||||||
|
json.pull_request_number pr.gitea_number
|
||||||
json.pull_request_status pr.status
|
json.pull_request_status pr.status
|
||||||
json.pull_request_head pr.head
|
json.pull_request_head pr.head
|
||||||
json.pull_request_base pr.base
|
json.pull_request_base pr.base
|
||||||
|
|
|
@ -16,7 +16,7 @@ zh-CN:
|
||||||
'agreed': '已同意'
|
'agreed': '已同意'
|
||||||
trend:
|
trend:
|
||||||
Issue: 易修(Issue)
|
Issue: 易修(Issue)
|
||||||
PullRequest: 合并请求
|
PullRequest: 合并请求(PR)
|
||||||
VersionRelease: 版本发布
|
VersionRelease: 版本发布
|
||||||
create: 创建了
|
create: 创建了
|
||||||
journal: 回复了
|
journal: 回复了
|
||||||
|
|
|
@ -12,12 +12,27 @@
|
||||||
body {
|
body {
|
||||||
font-family: "微软雅黑","宋体";
|
font-family: "微软雅黑","宋体";
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
}
|
}
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
p {
|
img{
|
||||||
font-size: 0.8em;
|
vertical-align: middle;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
a{
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.font-16{
|
||||||
|
font-size: 16px !important;
|
||||||
|
}
|
||||||
|
.mt56{
|
||||||
|
margin-top: 56px;
|
||||||
|
}
|
||||||
|
.color-blue{
|
||||||
|
color:#466AFF !important;
|
||||||
}
|
}
|
||||||
.h_content{
|
.h_content{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -33,6 +48,23 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: -webkit-flex;
|
display: -webkit-flex;
|
||||||
}
|
}
|
||||||
|
.edu-txt-center {
|
||||||
|
text-align: center !important;
|
||||||
|
}
|
||||||
|
.newTable{
|
||||||
|
padding-top: 120px;
|
||||||
|
background-color: #F0F5FF;
|
||||||
|
position: relative;
|
||||||
|
height: 100vh;
|
||||||
|
text-align: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.newMargin{
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function(){
|
$(function(){
|
||||||
|
@ -49,13 +81,18 @@
|
||||||
<p>An error occurred on the page you were trying to access.<br />
|
<p>An error occurred on the page you were trying to access.<br />
|
||||||
If you continue to experience problems please contact your Trustie administrator for assistance.</p>
|
If you continue to experience problems please contact your Trustie administrator for assistance.</p>
|
||||||
<p>If you are the Trustie administrator, check your log files for details about the error.</p> -->
|
<p>If you are the Trustie administrator, check your log files for details about the error.</p> -->
|
||||||
<div class="verticalCenter">
|
<div class="newTable clearfix">
|
||||||
<div class="edu-txt-center">
|
<img src="images/warn/pic_500.jpg">
|
||||||
<img src="/images/warn/pic_500.jpg" >
|
<div class="font-16 mt56" style="text-align: center;">
|
||||||
<p class="font-18 mt40">您可以稍后尝试
|
<p>服务器异常,请稍后重试</p>
|
||||||
您可以稍后尝试 <a href="javascript:history.back()" class="color-blue">返回上页</a>,或者
|
您可尝试<a href="javascript:location.reload();" class="color-blue">刷新页面</a>或<a href="/explore"
|
||||||
<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=2f2043d88c1bd61d182b98bf1e061c6185e23055bec832c07d8148fe11c5a6cd" class="color-blue">QQ反馈>></a>
|
class="color-blue">返回首页</a>,也可以通过
|
||||||
</p>
|
<a target="_blank"
|
||||||
|
href="https://qm.qq.com/cgi-bin/qm/qr?k=YVGUhY7uK8ovpyd7tG_lHe2qGZ63LOij&jump_from=webapi"
|
||||||
|
class="color-blue">QQ</a>向我们反馈
|
||||||
|
</div>
|
||||||
|
<div class="newMargin">
|
||||||
|
<img src="images/warn/pic_bg.png" width="100%" height="292px"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 141 KiB |
After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 52 KiB |