add pull request state
This commit is contained in:
parent
a04e0508d6
commit
1727435aa6
|
@ -109,7 +109,7 @@ class Organization < Owner
|
|||
|
||||
def is_sign?(user_id)
|
||||
return false if cla.nil?
|
||||
cla.user_clas.where(user_id: user_id).present?
|
||||
cla.user_clas.where(user_id: user_id, status: 1).present?
|
||||
end
|
||||
|
||||
def cla_sign_email(user_id)
|
||||
|
|
|
@ -24,10 +24,11 @@
|
|||
#
|
||||
|
||||
class PullRequest < ApplicationRecord
|
||||
#status 0 默认未合并, 1表示合并, 2表示请求拒绝(或已关闭)
|
||||
#status 0 默认未合并, 1表示合并, 2表示请求拒绝(或已关闭) ,3 表示未签署CLA
|
||||
OPEN = 0
|
||||
MERGED = 1
|
||||
CLOSED = 2
|
||||
NEEDCLA = 3
|
||||
|
||||
belongs_to :issue
|
||||
belongs_to :user
|
||||
|
|
|
@ -26,6 +26,10 @@ class UserCla < ApplicationRecord
|
|||
cla.fresh_count
|
||||
end
|
||||
|
||||
before_save do
|
||||
fresh_pull_request
|
||||
end
|
||||
|
||||
def self.build(params,user_id)
|
||||
self.create!(user_id: user_id,
|
||||
cla_id: params[:cla_id],
|
||||
|
@ -35,4 +39,13 @@ class UserCla < ApplicationRecord
|
|||
)
|
||||
end
|
||||
|
||||
def fresh_pull_request
|
||||
gitea_ids = Project.where(user_id: cla.user_id).pluck(:gpid)
|
||||
if state == "signed"
|
||||
PullRequest.where(user_id: user_id, gitea_id: gitea_ids, status:3).update_all(status:0)
|
||||
else
|
||||
PullRequest.where(user_id: user_id, gitea_id: gitea_ids, status:0).update_all(status:3)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,7 +2,8 @@ class PullRequests::SendJournalService < ApplicationService
|
|||
|
||||
def initialize(project, pull_request,current_user)
|
||||
@project = project
|
||||
@issue = pull_request
|
||||
@pull_request = pull_request
|
||||
@issue = pull_request.issue
|
||||
@current_user = current_user
|
||||
@org = project.owner
|
||||
end
|
||||
|
@ -23,6 +24,7 @@ class PullRequests::SendJournalService < ApplicationService
|
|||
}
|
||||
journal = Journal.new journal_params
|
||||
if journal.save
|
||||
@pull_request.update_attributes(status: 3)
|
||||
TouchWebhookJob.set(wait: 5.seconds).perform_later('PullRequestComment', @issue&.id, sender_id, journal.id, 'created', {})
|
||||
push_activity_2_blockchain("issue_comment_create", journal) if Site.has_blockchain? && @project.use_blockchain
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue