Unverified Commit d312ebf8 authored by Robert Knight's avatar Robert Knight Committed by Sean Hammond

Only display CC 0 license for shared annotations in public groups

Do not display the CC 0 license for annotations that are shared in a
private group.
parent 09922220
...@@ -541,6 +541,17 @@ function AnnotationController( ...@@ -541,6 +541,17 @@ function AnnotationController(
}; };
}; };
/**
* Return true if the CC 0 license notice should be shown beneath the
* annotation body.
*/
vm.shouldShowLicense = function () {
if (!vm.editing() || !vm.isShared()) {
return false;
}
return vm.group().public;
};
init(); init();
} }
......
...@@ -9,6 +9,25 @@ var testUtil = require('../../../shared/test/util'); ...@@ -9,6 +9,25 @@ var testUtil = require('../../../shared/test/util');
var util = require('../../directive/test/util'); var util = require('../../directive/test/util');
var inject = angular.mock.inject; var inject = angular.mock.inject;
var unroll = testUtil.unroll;
var draftFixtures = {
shared: { text: 'draft', tags: [], isPrivate: false },
private: { text: 'draft', tags: [], isPrivate: true },
};
var groupFixtures = {
private: {
id: 'private',
url: 'https://example.org/g/private',
public: false,
},
public: {
id: 'world',
url: 'https://example.org/g/public',
public: true,
},
};
/** /**
* Returns the annotation directive with helpers stubbed out. * Returns the annotation directive with helpers stubbed out.
...@@ -157,7 +176,7 @@ describe('annotation', function() { ...@@ -157,7 +176,7 @@ describe('annotation', function() {
fakeDrafts = { fakeDrafts = {
update: sandbox.stub(), update: sandbox.stub(),
remove: sandbox.stub(), remove: sandbox.stub(),
get: sandbox.stub(), get: sandbox.stub().returns(null),
}; };
fakeFeatures = { fakeFeatures = {
...@@ -193,10 +212,8 @@ describe('annotation', function() { ...@@ -193,10 +212,8 @@ describe('annotation', function() {
fakeServiceUrl = sinon.stub(); fakeServiceUrl = sinon.stub();
fakeGroups = { fakeGroups = {
focused: function() { focused: sinon.stub().returns(groupFixtures.public),
return {}; get: sinon.stub().returns(groupFixtures.public),
},
get: function() {},
}; };
fakeSettings = { fakeSettings = {
...@@ -791,6 +808,39 @@ describe('annotation', function() { ...@@ -791,6 +808,39 @@ describe('annotation', function() {
}); });
}); });
describe('#shouldShowLicense', function () {
unroll('returns #expected if #case_', function (testCase) {
var ann = fixtures.publicAnnotation();
ann.group = testCase.group.id;
fakeDrafts.get.returns(testCase.draft);
fakeGroups.get.returns(testCase.group);
var controller = createDirective(ann).controller;
assert.equal(controller.shouldShowLicense(), testCase.expected);
}, [{
case_: 'the annotation is not being edited',
draft: null,
group: groupFixtures.public,
expected: false,
},{
case_: 'the draft is private',
draft: draftFixtures.private,
group: groupFixtures.public,
expected: false,
},{
case_: 'the group is private',
draft: draftFixtures.shared,
group: groupFixtures.private,
expected: false,
},{
case_: 'the draft is shared and the group is public',
draft: draftFixtures.shared,
group: groupFixtures.public,
expected: true,
}]);
});
describe('saving a new annotation', function() { describe('saving a new annotation', function() {
var annotation; var annotation;
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
</div> </div>
<div class="annotation-section annotation-license" <div class="annotation-section annotation-license"
ng-show="vm.isShared() && vm.editing()"> ng-show="vm.shouldShowLicense()">
<a class="annotation-license__link" href="http://creativecommons.org/publicdomain/zero/1.0/" <a class="annotation-license__link" href="http://creativecommons.org/publicdomain/zero/1.0/"
title="View more information about the Creative Commons Public Domain dedication" title="View more information about the Creative Commons Public Domain dedication"
target="_blank"> target="_blank">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment