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.Gerrit;
|
||||||
import com.google.gerrit.client.Link;
|
import com.google.gerrit.client.Link;
|
||||||
import com.google.gerrit.client.reviewdb.Account;
|
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.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.ui.AccountScreen;
|
import com.google.gerrit.client.ui.AccountScreen;
|
||||||
import com.google.gerrit.client.ui.LazyTabChild;
|
import com.google.gerrit.client.ui.LazyTabChild;
|
||||||
@@ -137,13 +138,15 @@ public class AccountSettings extends AccountScreen {
|
|||||||
}, Util.C.tabWebIdentities());
|
}, Util.C.tabWebIdentities());
|
||||||
tabTokens.add(Link.SETTINGS_WEBIDENT);
|
tabTokens.add(Link.SETTINGS_WEBIDENT);
|
||||||
|
|
||||||
tabs.add(new LazyTabChild<AgreementPanel>() {
|
if (Common.getGerritConfig().isUseContributorAgreements()) {
|
||||||
@Override
|
tabs.add(new LazyTabChild<AgreementPanel>() {
|
||||||
protected AgreementPanel create() {
|
@Override
|
||||||
return new AgreementPanel();
|
protected AgreementPanel create() {
|
||||||
}
|
return new AgreementPanel();
|
||||||
}, Util.C.tabAgreements());
|
}
|
||||||
tabTokens.add(Link.SETTINGS_AGREEMENTS);
|
}, Util.C.tabAgreements());
|
||||||
|
tabTokens.add(Link.SETTINGS_AGREEMENTS);
|
||||||
|
}
|
||||||
|
|
||||||
tabs.addTabListener(new TabListener() {
|
tabs.addTabListener(new TabListener() {
|
||||||
public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
|
public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class GerritConfig {
|
|||||||
protected List<ApprovalType> approvalTypes;
|
protected List<ApprovalType> approvalTypes;
|
||||||
protected List<ApprovalType> actionTypes;
|
protected List<ApprovalType> actionTypes;
|
||||||
protected int sshdPort;
|
protected int sshdPort;
|
||||||
|
protected boolean useContributorAgreements;
|
||||||
private transient Map<ApprovalCategory.Id, ApprovalType> byCategoryId;
|
private transient Map<ApprovalCategory.Id, ApprovalType> byCategoryId;
|
||||||
|
|
||||||
public GerritConfig() {
|
public GerritConfig() {
|
||||||
@@ -88,6 +89,14 @@ public class GerritConfig {
|
|||||||
sshdPort = p;
|
sshdPort = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUseContributorAgreements() {
|
||||||
|
return useContributorAgreements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseContributorAgreements(final boolean r) {
|
||||||
|
useContributorAgreements = r;
|
||||||
|
}
|
||||||
|
|
||||||
public ApprovalType getApprovalType(final ApprovalCategory.Id id) {
|
public ApprovalType getApprovalType(final ApprovalCategory.Id id) {
|
||||||
if (byCategoryId == null) {
|
if (byCategoryId == null) {
|
||||||
byCategoryId = new HashMap<ApprovalCategory.Id, ApprovalType>();
|
byCategoryId = new HashMap<ApprovalCategory.Id, ApprovalType>();
|
||||||
|
|||||||
@@ -83,6 +83,10 @@ public final class SystemConfig {
|
|||||||
@Column(notNull = false)
|
@Column(notNull = false)
|
||||||
public transient String gitBasePath;
|
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. */
|
/** Local TCP port number the embedded SSHD server binds onto. */
|
||||||
@Column
|
@Column
|
||||||
public int sshdPort;
|
public int sshdPort;
|
||||||
|
|||||||
@@ -278,6 +278,7 @@ public class GerritServer {
|
|||||||
final GerritConfig r = new GerritConfig();
|
final GerritConfig r = new GerritConfig();
|
||||||
r.setCanonicalUrl(getCanonicalURL());
|
r.setCanonicalUrl(getCanonicalURL());
|
||||||
r.setSshdPort(sConfig.sshdPort);
|
r.setSshdPort(sConfig.sshdPort);
|
||||||
|
r.setUseContributorAgreements(sConfig.useContributorAgreements);
|
||||||
if (sConfig.gitwebUrl != null) {
|
if (sConfig.gitwebUrl != null) {
|
||||||
r.setGitwebLink(new GitwebLink(sConfig.gitwebUrl));
|
r.setGitwebLink(new GitwebLink(sConfig.gitwebUrl));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ class Receive extends AbstractGitCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void runImpl() throws IOException, Failure {
|
protected void runImpl() throws IOException, Failure {
|
||||||
server = getGerritServer();
|
server = getGerritServer();
|
||||||
verifyActiveContributorAgreement();
|
if (Common.getGerritConfig().isUseContributorAgreements()) {
|
||||||
|
verifyActiveContributorAgreement();
|
||||||
|
}
|
||||||
loadMyEmails();
|
loadMyEmails();
|
||||||
lookup(reviewerId, "reviewer", reviewerEmail);
|
lookup(reviewerId, "reviewer", reviewerEmail);
|
||||||
lookup(ccId, "cc", ccEmail);
|
lookup(ccId, "cc", ccEmail);
|
||||||
|
|||||||
Reference in New Issue
Block a user