Allow contributor agreements to be optional
By default the contributor agreements are disabled, as there are no agreements in the database. Admins which require agreements must enable them in system_config. This permits friendly community installations, such as a corporate location, where access automatically implies agreement to contribute because it is work-for-hire. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
		@@ -19,6 +19,7 @@ import static com.google.gerrit.client.FormatUtil.mediumFormat;
 | 
			
		||||
import com.google.gerrit.client.Gerrit;
 | 
			
		||||
import com.google.gerrit.client.Link;
 | 
			
		||||
import com.google.gerrit.client.reviewdb.Account;
 | 
			
		||||
import com.google.gerrit.client.rpc.Common;
 | 
			
		||||
import com.google.gerrit.client.rpc.GerritCallback;
 | 
			
		||||
import com.google.gerrit.client.ui.AccountScreen;
 | 
			
		||||
import com.google.gerrit.client.ui.LazyTabChild;
 | 
			
		||||
@@ -137,6 +138,7 @@ public class AccountSettings extends AccountScreen {
 | 
			
		||||
    }, Util.C.tabWebIdentities());
 | 
			
		||||
    tabTokens.add(Link.SETTINGS_WEBIDENT);
 | 
			
		||||
 | 
			
		||||
    if (Common.getGerritConfig().isUseContributorAgreements()) {
 | 
			
		||||
      tabs.add(new LazyTabChild<AgreementPanel>() {
 | 
			
		||||
        @Override
 | 
			
		||||
        protected AgreementPanel create() {
 | 
			
		||||
@@ -144,6 +146,7 @@ public class AccountSettings extends AccountScreen {
 | 
			
		||||
        }
 | 
			
		||||
      }, Util.C.tabAgreements());
 | 
			
		||||
      tabTokens.add(Link.SETTINGS_AGREEMENTS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    tabs.addTabListener(new TabListener() {
 | 
			
		||||
      public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ public class GerritConfig {
 | 
			
		||||
  protected List<ApprovalType> approvalTypes;
 | 
			
		||||
  protected List<ApprovalType> actionTypes;
 | 
			
		||||
  protected int sshdPort;
 | 
			
		||||
  protected boolean useContributorAgreements;
 | 
			
		||||
  private transient Map<ApprovalCategory.Id, ApprovalType> byCategoryId;
 | 
			
		||||
 | 
			
		||||
  public GerritConfig() {
 | 
			
		||||
@@ -88,6 +89,14 @@ public class GerritConfig {
 | 
			
		||||
    sshdPort = p;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public boolean isUseContributorAgreements() {
 | 
			
		||||
    return useContributorAgreements;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public void setUseContributorAgreements(final boolean r) {
 | 
			
		||||
    useContributorAgreements = r;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ApprovalType getApprovalType(final ApprovalCategory.Id id) {
 | 
			
		||||
    if (byCategoryId == null) {
 | 
			
		||||
      byCategoryId = new HashMap<ApprovalCategory.Id, ApprovalType>();
 | 
			
		||||
 
 | 
			
		||||
@@ -83,6 +83,10 @@ public final class SystemConfig {
 | 
			
		||||
  @Column(notNull = false)
 | 
			
		||||
  public transient String gitBasePath;
 | 
			
		||||
 | 
			
		||||
  /** Is a verified {@link AccountAgreement} required to upload changes? */
 | 
			
		||||
  @Column
 | 
			
		||||
  public boolean useContributorAgreements;
 | 
			
		||||
 | 
			
		||||
  /** Local TCP port number the embedded SSHD server binds onto. */
 | 
			
		||||
  @Column
 | 
			
		||||
  public int sshdPort;
 | 
			
		||||
 
 | 
			
		||||
@@ -278,6 +278,7 @@ public class GerritServer {
 | 
			
		||||
    final GerritConfig r = new GerritConfig();
 | 
			
		||||
    r.setCanonicalUrl(getCanonicalURL());
 | 
			
		||||
    r.setSshdPort(sConfig.sshdPort);
 | 
			
		||||
    r.setUseContributorAgreements(sConfig.useContributorAgreements);
 | 
			
		||||
    if (sConfig.gitwebUrl != null) {
 | 
			
		||||
      r.setGitwebLink(new GitwebLink(sConfig.gitwebUrl));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -89,7 +89,9 @@ class Receive extends AbstractGitCommand {
 | 
			
		||||
  @Override
 | 
			
		||||
  protected void runImpl() throws IOException, Failure {
 | 
			
		||||
    server = getGerritServer();
 | 
			
		||||
    if (Common.getGerritConfig().isUseContributorAgreements()) {
 | 
			
		||||
      verifyActiveContributorAgreement();
 | 
			
		||||
    }
 | 
			
		||||
    loadMyEmails();
 | 
			
		||||
    lookup(reviewerId, "reviewer", reviewerEmail);
 | 
			
		||||
    lookup(ccId, "cc", ccEmail);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user