diff --git a/app/controllers/edit_controller.rb b/app/controllers/edit_controller.rb index 25549966f..51cd3803f 100644 --- a/app/controllers/edit_controller.rb +++ b/app/controllers/edit_controller.rb @@ -49,7 +49,7 @@ def commit pull_from = forked ? "#{@current_user.login}:#{new_branch}" : branch_name @pr = open_pr(pull_from, @branch, @summary, @description) # Check for CLA - @cla_url = "#{ENV.fetch("SITE_URL")}/cla.html" + @cla_url = "#{ENV.fetch("CLA_URL")}" r = Faraday.get @cla_url @has_cla = (r.status == 200) end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 95d8df793..86f4fae1c 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -20,6 +20,10 @@ def show # Get activity list presenter = ProposalPresenter.new(@proposal) @activity = presenter.activity_log + # TODO needs to check if the manifesto has a cla! + # @unsigned_cla = @is_author && !current_user.cla_accepted? + @unsigned_cla = true + @tbc = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" end def webhook diff --git a/app/models/concerns/github_pull_request.rb b/app/models/concerns/github_pull_request.rb index 904059ffc..bfc6bf48d 100644 --- a/app/models/concerns/github_pull_request.rb +++ b/app/models/concerns/github_pull_request.rb @@ -63,6 +63,19 @@ def set_time_build_status end end + def set_cla_build_status + status = "groupthink/cla" + if cla_required? + if cla_accepted? + set_build_status(:success, I18n.t("build_status.cla.accepted"), status) + else + set_build_status(:pending, I18n.t("build_status.cla.pending"), status) + end + else + set_build_status(:success, I18n.t("build_status.cla.none"), status) + end + end + def merge_pr! Octokit.merge_pull_request(ENV.fetch("GITHUB_REPO"), number) true diff --git a/app/models/concerns/user_admin.rb b/app/models/concerns/user_admin.rb index 7ce3f0a52..f79efc146 100644 --- a/app/models/concerns/user_admin.rb +++ b/app/models/concerns/user_admin.rb @@ -21,6 +21,7 @@ module UserAdmin field :role field :author field :voter + field :cla_accepted end end end diff --git a/app/models/concerns/votable.rb b/app/models/concerns/votable.rb index 6b964a558..4688882fb 100644 --- a/app/models/concerns/votable.rb +++ b/app/models/concerns/votable.rb @@ -43,6 +43,7 @@ def count_votes! unless closed? set_vote_build_status set_time_build_status + set_cla_build_status end end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index cb18134c3..ce58f571c 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -52,6 +52,14 @@ def too_new? age < Rules.min_age end + def cla_required? + ENV['CLA_URL'].present? + end + + def cla_accepted? + proposer.cla_accepted + end + def update_state! state = pr_closed? ? closed_state : open_state update!(state: state) @@ -90,7 +98,7 @@ def closed_state def open_state return nil if pr_closed? return "dead" if too_old? - return "blocked" if blocked? + return "blocked" if blocked? || (cla_required? && !cla_accepted?) if passed? return too_new? ? "agreed" : "passed" end diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 7f016a45e..70c95d45d 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -38,6 +38,22 @@ +<% if @unsigned_cla %> +
+ This proposal is blocked because the manifesto has a contributor license agreement (CLA) which all contributors must sign. + Please " target="_blank" rel="noopener noreferrer">read the agreement and sign it using the accept button below. +
+