-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no issue - Added new fixtures for member permissions for Admin
- Loading branch information
1 parent
20a898a
commit d62feca
Showing
5 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
core/server/data/migrations/versions/2.16/1-add-members-perrmissions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const _ = require('lodash'); | ||
const utils = require('../../../schema/fixtures/utils'); | ||
const permissions = require('../../../../services/permissions'); | ||
const common = require('../../../../lib/common'); | ||
const resource = 'members'; | ||
const _private = {}; | ||
|
||
_private.getPermissions = function getPermissions() { | ||
return utils.findModelFixtures('Permission', {object_type: resource}); | ||
}; | ||
|
||
_private.getRelations = function getRelations() { | ||
return utils.findPermissionRelationsForObject(resource); | ||
}; | ||
|
||
_private.printResult = function printResult(result, message) { | ||
if (result.done === result.expected) { | ||
common.logging.info(message); | ||
} else { | ||
common.logging.warn('(' + result.done + '/' + result.expected + ') ' + message); | ||
} | ||
}; | ||
|
||
module.exports.up = function addMembersPermissions(options) { | ||
const modelToAdd = _private.getPermissions(); | ||
const relationToAdd = _private.getRelations(); | ||
const localOptions = _.merge({ | ||
context: { | ||
internal: true, | ||
migrating: true | ||
} | ||
}, options); | ||
|
||
return utils.addFixturesForModel(modelToAdd, localOptions) | ||
.then(function (result) { | ||
_private.printResult(result, 'Adding permissions fixtures for ' + resource + 's'); | ||
return utils.addFixturesForRelation(relationToAdd, localOptions); | ||
}) | ||
.then(function (result) { | ||
_private.printResult(result, 'Adding permissions_roles fixtures for ' + resource + 's'); | ||
return permissions.init(localOptions); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters