FIX merge develop branch
This commit is contained in:
commit
2d648e516e
|
@ -3,7 +3,7 @@ class IssuesController < ApplicationController
|
||||||
before_action :load_project
|
before_action :load_project
|
||||||
before_action :set_user
|
before_action :set_user
|
||||||
before_action :check_issue_permission
|
before_action :check_issue_permission
|
||||||
before_action :operate_issue_permission, only:[:create, :update, :destroy, :clean, :series_update]
|
before_action :operate_issue_permission, only:[:create, :update, :destroy, :clean, :series_update, :copy]
|
||||||
before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue]
|
before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue]
|
||||||
|
|
||||||
before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
|
before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
|
||||||
|
@ -231,7 +231,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user_permission = current_user.present? && current_user.logged? && (!@issue.is_lock || @project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
@user_permission = current_user.present? && current_user.logged? && (@project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
||||||
@issue_attachments = @issue.attachments
|
@issue_attachments = @issue.attachments
|
||||||
@issue_user = @issue.user
|
@issue_user = @issue.user
|
||||||
@issue_assign_to = @issue.get_assign_user
|
@issue_assign_to = @issue.get_assign_user
|
||||||
|
@ -316,6 +316,7 @@ class IssuesController < ApplicationController
|
||||||
|
|
||||||
def copy
|
def copy
|
||||||
@new_issue = @issue.dup
|
@new_issue = @issue.dup
|
||||||
|
@new_issue.author_id = current_user.id
|
||||||
if @new_issue.save
|
if @new_issue.save
|
||||||
issue_tags = @issue.issue_tags.pluck(:id)
|
issue_tags = @issue.issue_tags.pluck(:id)
|
||||||
if issue_tags.present?
|
if issue_tags.present?
|
||||||
|
@ -416,7 +417,7 @@ class IssuesController < ApplicationController
|
||||||
def operate_issue_permission
|
def operate_issue_permission
|
||||||
return render_forbidden("您没有权限进行此操作.") unless current_user.admin? || @project.member?(current_user)
|
return render_forbidden("您没有权限进行此操作.") unless current_user.admin? || @project.member?(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_issues(issues)
|
def export_issues(issues)
|
||||||
@table_columns = %w(ID 类型 标题 描述 状态 指派给 优先级 标签 发布人 创建时间 里程碑 开始时间 截止时间 完成度 分类 金额 属于)
|
@table_columns = %w(ID 类型 标题 描述 状态 指派给 优先级 标签 发布人 创建时间 里程碑 开始时间 截止时间 完成度 分类 金额 属于)
|
||||||
@export_issues = []
|
@export_issues = []
|
||||||
|
|
|
@ -116,10 +116,11 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
Projects::UpdateForm.new(validate_params).validate!
|
Projects::UpdateForm.new(validate_params).validate!
|
||||||
|
|
||||||
private = params[:private] || false
|
private = @project.forked_from_project.present? ? !@project.forked_from_project.is_public : params[:private] || false
|
||||||
|
|
||||||
new_project_params = project_params.except(:private).merge(is_public: !private)
|
new_project_params = project_params.except(:private).merge(is_public: !private)
|
||||||
@project.update_attributes!(new_project_params)
|
@project.update_attributes!(new_project_params)
|
||||||
|
@project.forked_projects.update_all(is_public: @project.is_public)
|
||||||
gitea_params = {
|
gitea_params = {
|
||||||
private: private,
|
private: private,
|
||||||
default_branch: @project.default_branch,
|
default_branch: @project.default_branch,
|
||||||
|
@ -144,6 +145,7 @@ class ProjectsController < ApplicationController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
||||||
@project.destroy!
|
@project.destroy!
|
||||||
|
@project.forked_projects.update_all(forked_from_project_id: nil)
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -150,9 +150,16 @@ class PullRequestsController < ApplicationController
|
||||||
else
|
else
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
begin
|
begin
|
||||||
result = PullRequests::MergeService.call(@owner, @repository, @pull_request, current_user, params)
|
@gitea_pull = Gitea::PullRequest::GetService.call(@owner.login, @repository.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||||
|
|
||||||
if result.status == 200 && @pull_request.merge!
|
if @gitea_pull["merged_by"].present?
|
||||||
|
success_condition = true
|
||||||
|
else
|
||||||
|
result = PullRequests::MergeService.call(@owner, @repository, @pull_request, current_user, params)
|
||||||
|
success_condition = result.status == 200
|
||||||
|
end
|
||||||
|
|
||||||
|
if success_condition && @pull_request.merge!
|
||||||
@pull_request.project_trend_status!
|
@pull_request.project_trend_status!
|
||||||
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
||||||
normal_status(1, "合并成功")
|
normal_status(1, "合并成功")
|
||||||
|
|
|
@ -1,81 +1,81 @@
|
||||||
# == Schema Information
|
|
||||||
#
|
|
||||||
# Table name: projects
|
|
||||||
#
|
|
||||||
# id :integer not null, primary key
|
|
||||||
# name :string(255) default(""), not null
|
|
||||||
# description :text(4294967295)
|
|
||||||
# homepage :string(255) default("")
|
|
||||||
# is_public :boolean default("1"), not null
|
|
||||||
# parent_id :integer
|
|
||||||
# created_on :datetime
|
|
||||||
# updated_on :datetime
|
|
||||||
# identifier :string(255)
|
|
||||||
# status :integer default("1"), not null
|
|
||||||
# lft :integer
|
|
||||||
# rgt :integer
|
|
||||||
# inherit_members :boolean default("0"), not null
|
|
||||||
# project_type :integer default("0")
|
|
||||||
# hidden_repo :boolean default("0"), not null
|
|
||||||
# attachmenttype :integer default("1")
|
|
||||||
# user_id :integer
|
|
||||||
# dts_test :integer default("0")
|
|
||||||
# enterprise_name :string(255)
|
|
||||||
# organization_id :integer
|
|
||||||
# project_new_type :integer
|
|
||||||
# gpid :integer
|
|
||||||
# forked_from_project_id :integer
|
|
||||||
# forked_count :integer default("0")
|
|
||||||
# publish_resource :integer default("0")
|
|
||||||
# visits :integer default("0")
|
|
||||||
# hot :integer default("0")
|
|
||||||
# invite_code :string(255)
|
|
||||||
# qrcode :string(255)
|
|
||||||
# qrcode_expiretime :integer default("0")
|
|
||||||
# script :text(65535)
|
|
||||||
# training_status :integer default("0")
|
|
||||||
# rep_identifier :string(255)
|
|
||||||
# project_category_id :integer
|
|
||||||
# project_language_id :integer
|
|
||||||
# praises_count :integer default("0")
|
|
||||||
# watchers_count :integer default("0")
|
|
||||||
# issues_count :integer default("0")
|
|
||||||
# pull_requests_count :integer default("0")
|
|
||||||
# language :string(255)
|
|
||||||
# versions_count :integer default("0")
|
|
||||||
# issue_tags_count :integer default("0")
|
|
||||||
# closed_issues_count :integer default("0")
|
|
||||||
# open_devops :boolean default("0")
|
|
||||||
# gitea_webhook_id :integer
|
|
||||||
# open_devops_count :integer default("0")
|
|
||||||
# recommend :boolean default("0")
|
|
||||||
# platform :integer default("0")
|
|
||||||
# license_id :integer
|
|
||||||
# ignore_id :integer
|
|
||||||
# default_branch :string(255) default("master")
|
|
||||||
# website :string(255)
|
|
||||||
# lesson_url :string(255)
|
|
||||||
#
|
|
||||||
# Indexes
|
|
||||||
#
|
|
||||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
|
||||||
# index_projects_on_identifier (identifier)
|
|
||||||
# index_projects_on_invite_code (invite_code)
|
|
||||||
# index_projects_on_is_public (is_public)
|
|
||||||
# index_projects_on_lft (lft)
|
|
||||||
# index_projects_on_license_id (license_id)
|
|
||||||
# index_projects_on_name (name)
|
|
||||||
# index_projects_on_platform (platform)
|
|
||||||
# index_projects_on_project_category_id (project_category_id)
|
|
||||||
# index_projects_on_project_language_id (project_language_id)
|
|
||||||
# index_projects_on_project_type (project_type)
|
|
||||||
# index_projects_on_recommend (recommend)
|
|
||||||
# index_projects_on_rgt (rgt)
|
|
||||||
# index_projects_on_status (status)
|
|
||||||
# index_projects_on_updated_on (updated_on)
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: projects
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# name :string(255) default(""), not null
|
||||||
|
# description :text(4294967295)
|
||||||
|
# homepage :string(255) default("")
|
||||||
|
# is_public :boolean default("1"), not null
|
||||||
|
# parent_id :integer
|
||||||
|
# created_on :datetime
|
||||||
|
# updated_on :datetime
|
||||||
|
# identifier :string(255)
|
||||||
|
# status :integer default("1"), not null
|
||||||
|
# lft :integer
|
||||||
|
# rgt :integer
|
||||||
|
# inherit_members :boolean default("0"), not null
|
||||||
|
# project_type :integer default("0")
|
||||||
|
# hidden_repo :boolean default("0"), not null
|
||||||
|
# attachmenttype :integer default("1")
|
||||||
|
# user_id :integer
|
||||||
|
# dts_test :integer default("0")
|
||||||
|
# enterprise_name :string(255)
|
||||||
|
# organization_id :integer
|
||||||
|
# project_new_type :integer
|
||||||
|
# gpid :integer
|
||||||
|
# forked_from_project_id :integer
|
||||||
|
# forked_count :integer default("0")
|
||||||
|
# publish_resource :integer default("0")
|
||||||
|
# visits :integer default("0")
|
||||||
|
# hot :integer default("0")
|
||||||
|
# invite_code :string(255)
|
||||||
|
# qrcode :string(255)
|
||||||
|
# qrcode_expiretime :integer default("0")
|
||||||
|
# script :text(65535)
|
||||||
|
# training_status :integer default("0")
|
||||||
|
# rep_identifier :string(255)
|
||||||
|
# project_category_id :integer
|
||||||
|
# project_language_id :integer
|
||||||
|
# license_id :integer
|
||||||
|
# ignore_id :integer
|
||||||
|
# praises_count :integer default("0")
|
||||||
|
# watchers_count :integer default("0")
|
||||||
|
# issues_count :integer default("0")
|
||||||
|
# pull_requests_count :integer default("0")
|
||||||
|
# language :string(255)
|
||||||
|
# versions_count :integer default("0")
|
||||||
|
# issue_tags_count :integer default("0")
|
||||||
|
# closed_issues_count :integer default("0")
|
||||||
|
# open_devops :boolean default("0")
|
||||||
|
# gitea_webhook_id :integer
|
||||||
|
# open_devops_count :integer default("0")
|
||||||
|
# recommend :boolean default("0")
|
||||||
|
# platform :integer default("0")
|
||||||
|
# default_branch :string(255) default("master")
|
||||||
|
# website :string(255)
|
||||||
|
# order_index :integer default("0")
|
||||||
|
# lesson_url :string(255)
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||||
|
# index_projects_on_identifier (identifier)
|
||||||
|
# index_projects_on_invite_code (invite_code)
|
||||||
|
# index_projects_on_is_public (is_public)
|
||||||
|
# index_projects_on_lft (lft)
|
||||||
|
# index_projects_on_license_id (license_id)
|
||||||
|
# index_projects_on_name (name)
|
||||||
|
# index_projects_on_platform (platform)
|
||||||
|
# index_projects_on_project_category_id (project_category_id)
|
||||||
|
# index_projects_on_project_language_id (project_language_id)
|
||||||
|
# index_projects_on_project_type (project_type)
|
||||||
|
# index_projects_on_recommend (recommend)
|
||||||
|
# index_projects_on_rgt (rgt)
|
||||||
|
# index_projects_on_status (status)
|
||||||
|
# index_projects_on_updated_on (updated_on)
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
class Project < ApplicationRecord
|
class Project < ApplicationRecord
|
||||||
|
@ -100,10 +100,12 @@ class Project < ApplicationRecord
|
||||||
belongs_to :organization_extension, foreign_key: :user_id, primary_key: :organization_id, optional: true, counter_cache: :num_projects
|
belongs_to :organization_extension, foreign_key: :user_id, primary_key: :organization_id, optional: true, counter_cache: :num_projects
|
||||||
belongs_to :project_category, optional: true , :counter_cache => true
|
belongs_to :project_category, optional: true , :counter_cache => true
|
||||||
belongs_to :project_language, optional: true , :counter_cache => true
|
belongs_to :project_language, optional: true , :counter_cache => true
|
||||||
|
belongs_to :forked_from_project, class_name: 'Project', optional: true, foreign_key: :forked_from_project_id
|
||||||
has_many :project_trends, dependent: :destroy
|
has_many :project_trends, dependent: :destroy
|
||||||
has_many :watchers, as: :watchable, dependent: :destroy
|
has_many :watchers, as: :watchable, dependent: :destroy
|
||||||
has_many :fork_users, dependent: :destroy
|
has_many :fork_users, dependent: :destroy
|
||||||
has_many :forked_users, class_name: 'ForkUser', foreign_key: :fork_project_id, dependent: :destroy
|
has_many :forked_users, class_name: 'ForkUser', foreign_key: :fork_project_id, dependent: :destroy
|
||||||
|
has_many :forked_projects, class_name: 'Project', foreign_key: :forked_from_project_id
|
||||||
has_one :project_educoder, dependent: :destroy
|
has_one :project_educoder, dependent: :destroy
|
||||||
|
|
||||||
has_one :project_score, dependent: :destroy
|
has_one :project_score, dependent: :destroy
|
||||||
|
|
|
@ -186,7 +186,7 @@ class User < Owner
|
||||||
:show_email, :show_location, :show_department,
|
:show_email, :show_location, :show_department,
|
||||||
:technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true
|
:technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true
|
||||||
|
|
||||||
before_save :update_hashed_password
|
before_save :update_hashed_password, :set_lastname
|
||||||
after_create do
|
after_create do
|
||||||
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
|
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
|
||||||
end
|
end
|
||||||
|
@ -791,6 +791,10 @@ class User < Owner
|
||||||
|
|
||||||
self.laboratory = Laboratory.current if laboratory_id.blank?
|
self.laboratory = Laboratory.current if laboratory_id.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_lastname
|
||||||
|
self.lastname = self.nickname if changes[:nickname].present?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
namespace :sync_projects_by_forked_project do
|
||||||
|
desc "sync projects is_public by forked project"
|
||||||
|
task is_public: :environment do
|
||||||
|
count = 0
|
||||||
|
Project.where.not(forked_from_project_id: nil).group(:forked_from_project_id).count.each do |k, _|
|
||||||
|
project = Project.find_by_id(k)
|
||||||
|
need_update_forked_projects = Project.where(forked_from_project_id: k)
|
||||||
|
need_update_forked_projects.update_all(is_public: project&.is_public)
|
||||||
|
need_update_forked_repositories = Repository.where(project_id: need_update_forked_projects.ids)
|
||||||
|
need_update_forked_repositories.update_all(hidden: !project&.is_public)
|
||||||
|
count +=need_update_forked_projects.size
|
||||||
|
end
|
||||||
|
puts "共同步了#{count}个项目"
|
||||||
|
end
|
||||||
|
|
||||||
|
task destroy: :environment do
|
||||||
|
count = 0
|
||||||
|
Project.where.not(forked_from_project_id: nil).find_each do |project|
|
||||||
|
if project.forked_from_project.nil?
|
||||||
|
project.update(forked_from_project_id: nil)
|
||||||
|
count +=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
puts "共同步了#{count}个项目"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue