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:
Shawn O. Pearce
2009-01-06 17:00:51 -08:00
parent 5c22bd5bdf
commit 1ae09f8f98
5 changed files with 27 additions and 8 deletions

View File

@@ -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,13 +138,15 @@ public class AccountSettings extends AccountScreen {
}, Util.C.tabWebIdentities());
tabTokens.add(Link.SETTINGS_WEBIDENT);
tabs.add(new LazyTabChild<AgreementPanel>() {
@Override
protected AgreementPanel create() {
return new AgreementPanel();
}
}, Util.C.tabAgreements());
tabTokens.add(Link.SETTINGS_AGREEMENTS);
if (Common.getGerritConfig().isUseContributorAgreements()) {
tabs.add(new LazyTabChild<AgreementPanel>() {
@Override
protected AgreementPanel create() {
return new AgreementPanel();
}
}, Util.C.tabAgreements());
tabTokens.add(Link.SETTINGS_AGREEMENTS);
}
tabs.addTabListener(new TabListener() {
public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {

View File

@@ -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>();

View File

@@ -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;

View File

@@ -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));
}

View File

@@ -89,7 +89,9 @@ class Receive extends AbstractGitCommand {
@Override
protected void runImpl() throws IOException, Failure {
server = getGerritServer();
verifyActiveContributorAgreement();
if (Common.getGerritConfig().isUseContributorAgreements()) {
verifyActiveContributorAgreement();
}
loadMyEmails();
lookup(reviewerId, "reviewer", reviewerEmail);
lookup(ccId, "cc", ccEmail);