diff options
author | Marius Mathiesen <marius.mathiesen@gmail.com> | 2009-04-30 13:49:19 +0200 |
---|---|---|
committer | Marius Mathiesen <marius.mathiesen@gmail.com> | 2009-04-30 13:49:36 +0200 |
commit | 991107f85f2273d29b1dd4df087e385ea0480d86 (patch) | |
tree | 1c522fba2dd39dcbff6d018100397fe396cfe543 /app/models/merge_request.rb | |
parent | 209189ab641fcddfc416ac81c43bc0b1602ae5fe (diff) | |
download | gitorious-mainline-outdated-991107f85f2273d29b1dd4df087e385ea0480d86.zip gitorious-mainline-outdated-991107f85f2273d29b1dd4df087e385ea0480d86.tar.gz gitorious-mainline-outdated-991107f85f2273d29b1dd4df087e385ea0480d86.tar.bz2 |
Changing the way signoff of merge requests work, due to a requirement that users who have already accepted the contribution agreement should be reminded of their confirmation when sending new contributions.
- Instead of extracting the agreement version checksum from the response body, it is extracted from a response header (X-Contribution-Agreement-Version).
- The response code (from the oauth provider) tells us whether this is the first or subsequent time a user accepts the license: 202 (Accepted) means it has been accepted before while other codes (preferably 201 Created) means it has been accepted for the first time
- The response body is now used for providing the message to be displayed to the user
The contribution notice is put into flash[:notice] and thus displayed to the user.
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 04e703e..fc34011 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -220,10 +220,30 @@ class MergeRequest < ActiveRecord::Base validate_through_oauth do confirmed_by_user callback_response = access_token.post(target_repository.project.oauth_path_prefix, oauth_signoff_parameters) - update_attributes(:contribution_agreement_version => callback_response.body) + + if Net::HTTPAccepted === callback_response + self.contribution_notice = callback_response.body + end + + contribution_agreement_version = callback_response['X-Contribution-Agreement-Version'] + update_attributes(:contribution_agreement_version => contribution_agreement_version) end end + # If the contribution agreement site wants to remind the user of the current contribution license, + # they respond with a Net::HTTPAccepted header along with a response body containing the notice + def contribution_notice=(notice) + @contribution_notice = notice + end + + def has_contribution_notice? + !contribution_notice.blank? + end + + def contribution_notice + @contribution_notice + end + # Returns the parameters that are passed on to the contribution agreement site def oauth_signoff_parameters { |