Move editable and filesEditable props to libraries table [DB reupgrade]

And add group.fromJSON(json, userID), which sets editable and
filesEditable properties based on the group JSON (libraryReading, role
lists, etc.) and the given user
This commit is contained in:
Dan Stillman 2015-06-07 15:40:04 -04:00
parent 53706d633a
commit a22c4969e6
9 changed files with 294 additions and 106 deletions

View file

@ -229,8 +229,13 @@ function waitForCallback(cb, interval, timeout) {
/**
* Get a default group used by all tests that want one, creating one if necessary
*/
var getGroup = Zotero.lazy(function () {
return createGroup({
var _defaultGroup;
var getGroup = Zotero.Promise.method(function () {
// Cleared in resetDB()
if (_defaultGroup) {
return _defaultGroup;
}
return _defaultGroup = createGroup({
name: "My Group"
});
});
@ -239,7 +244,7 @@ var getGroup = Zotero.lazy(function () {
var createGroup = Zotero.Promise.coroutine(function* (props) {
props = props || {};
var group = new Zotero.Group;
group.id = Zotero.Utilities.rand(10000, 1000000);
group.id = props.id || Zotero.Utilities.rand(10000, 1000000);
group.name = props.name || "Test " + Zotero.Utilities.randomString();
group.description = props.description || "";
group.editable = props.editable || true;
@ -363,6 +368,7 @@ function resetDB() {
var db = Zotero.getZoteroDatabase();
return Zotero.reinit(function() {
db.remove(false);
_defaultGroup = null;
}).then(function() {
return Zotero.Schema.schemaUpdatePromise;
});