@dhyasama/totem-models 2.7.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LimitedPartner.js +15 -13
- package/lib/Organization.js +26 -15
- package/package.json +2 -2
- package/test/Interaction.js +1 -1
- package/test/Organization.js +14 -7
- package/.npmignore +0 -14
- package/package-lock.json +0 -1163
package/lib/LimitedPartner.js
CHANGED
|
@@ -617,6 +617,8 @@ module.exports = function(mongoose, config) {
|
|
|
617
617
|
});
|
|
618
618
|
};
|
|
619
619
|
|
|
620
|
+
if (role == 'none') return cb(null, []);
|
|
621
|
+
|
|
620
622
|
if (CUSTOMER_ID == 'GLOBAL_PROCESS') {
|
|
621
623
|
query = self.find({'name': new RegExp(terms, "i")}, self.getReadFilterKeys(role));
|
|
622
624
|
getLps();
|
|
@@ -816,21 +818,21 @@ module.exports = function(mongoose, config) {
|
|
|
816
818
|
//////////////////////////////
|
|
817
819
|
|
|
818
820
|
LimitedPartner.plugin(filter, {
|
|
819
|
-
readFilter: {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
821
|
+
"readFilter": {
|
|
822
|
+
"admin": ["name", "shortName", "start", "people", "documentSlugs", "fundsInvested", "contact", "distributions", "k1", "entered", "status", "flagged", "flags", "notes"],
|
|
823
|
+
"lp-full": ["name", "shortName", "start", "people", "documentSlugs", "fundsInvested", "contact", "distributions", "k1", "entered", "status", "flagged", "flags", "notes"],
|
|
824
|
+
"lp-names": ["name", "shortName", "flagged", "flags"],
|
|
825
|
+
"none": []
|
|
824
826
|
},
|
|
825
|
-
writeFilter: {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
827
|
+
"writeFilter": {
|
|
828
|
+
"admin": ["name", "shortName", "start", "people", "documentSlugs", "fundsInvested", "contact", "distributions", "k1", "entered", "status", "flagged", "flags", "notes"],
|
|
829
|
+
"lp-full": ["name", "shortName", "start", "people", "documentSlugs", "fundsInvested", "contact", "distributions", "k1", "entered", "status", "flagged", "flags", "notes"],
|
|
830
|
+
"lp-names": ["flagged", "flags"],
|
|
831
|
+
"none": []
|
|
830
832
|
},
|
|
831
|
-
defaultFilterRole:
|
|
832
|
-
sanitize: false,
|
|
833
|
-
compat: false
|
|
833
|
+
"defaultFilterRole": "none",
|
|
834
|
+
"sanitize": false,
|
|
835
|
+
"compat": false
|
|
834
836
|
});
|
|
835
837
|
|
|
836
838
|
//////////////////////////////
|
package/lib/Organization.js
CHANGED
|
@@ -10,7 +10,6 @@ module.exports = function(mongoose, config) {
|
|
|
10
10
|
Schema = mongoose.Schema,
|
|
11
11
|
Flag = mongoose.model('Flag'),
|
|
12
12
|
Note = mongoose.model('Note'),
|
|
13
|
-
|
|
14
13
|
customerFunds = [],
|
|
15
14
|
customerPortfolio = [],
|
|
16
15
|
|
|
@@ -685,12 +684,20 @@ module.exports = function(mongoose, config) {
|
|
|
685
684
|
|
|
686
685
|
};
|
|
687
686
|
|
|
688
|
-
Organization.statics.findByLimitedPartner = function findByLimitedPartner(lpid, cb) {
|
|
687
|
+
Organization.statics.findByLimitedPartner = function findByLimitedPartner(lpid, options, cb) {
|
|
688
|
+
|
|
689
689
|
var self = this;
|
|
690
|
+
|
|
691
|
+
options = options || {};
|
|
692
|
+
options.role = options.role || 'none';
|
|
693
|
+
|
|
694
|
+
if (options.role == 'none') return cb(new Error('Access denied'), null);
|
|
695
|
+
|
|
690
696
|
self
|
|
691
697
|
.find({ 'lps': lpid, 'deleted': {$ne: true} })
|
|
692
698
|
.select('name logoUrl')
|
|
693
699
|
.exec(cb);
|
|
700
|
+
|
|
694
701
|
};
|
|
695
702
|
|
|
696
703
|
Organization.statics.findByPerson = function findByPerson(personId, cb) {
|
|
@@ -797,24 +804,28 @@ module.exports = function(mongoose, config) {
|
|
|
797
804
|
.exec(cb);
|
|
798
805
|
};
|
|
799
806
|
|
|
800
|
-
Organization.statics.getById = function getById(id, cb) {
|
|
807
|
+
Organization.statics.getById = function getById(id, options, cb) {
|
|
801
808
|
|
|
802
809
|
var self = this;
|
|
803
810
|
|
|
811
|
+
options = options || {};
|
|
812
|
+
options.role = options.role || 'none';
|
|
813
|
+
|
|
804
814
|
var lpPopulateOptions = { path: 'lps' };
|
|
805
815
|
if (config.CUSTOMER_ID != 'GLOBAL_PROCESS') lpPopulateOptions.match = { customer: config.CUSTOMER_ID };
|
|
806
816
|
|
|
807
|
-
self
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
817
|
+
var query = self.findById(id);
|
|
818
|
+
query.populate('people.person', 'name avatarUrl title doNotDisplay');
|
|
819
|
+
query.populate('related', 'name logoUrl');
|
|
820
|
+
query.populate('chairs.first', 'name avatarUrl title');
|
|
821
|
+
query.populate('chairs.second', 'name avatarUrl title');
|
|
822
|
+
query.populate('funds', 'name hexColorCode abbreviation closeDate');
|
|
823
|
+
query.populate('operating.acquired.public.by', 'name logoUrl');
|
|
824
|
+
query.populate('operating.acquired.private.by', 'name logoUrl');
|
|
825
|
+
|
|
826
|
+
if (options.role != 'none') query.populate(lpPopulateOptions);
|
|
827
|
+
|
|
828
|
+
query.exec(cb);
|
|
818
829
|
|
|
819
830
|
};
|
|
820
831
|
|
|
@@ -1146,7 +1157,7 @@ module.exports = function(mongoose, config) {
|
|
|
1146
1157
|
if (data.domain) {
|
|
1147
1158
|
data.domain = data.domain.toLowerCase();
|
|
1148
1159
|
var domainRegExp = options.fuzzy ? new RegExp(data.domain, 'i') : new RegExp('^' + data.domain + '$', 'i');
|
|
1149
|
-
query['$or'].push({ 'website': domainRegExp });
|
|
1160
|
+
query['$or'].push({ 'website': domainRegExp }, {'websiteAliases': domainRegExp});
|
|
1150
1161
|
}
|
|
1151
1162
|
|
|
1152
1163
|
// remove if unused
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhyasama/totem-models",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"author": "Jason Reynolds",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "Models for Totem platform",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@dhyasama/ffvc-crypto": "^1.0.0",
|
|
16
16
|
"@dhyasama/ffvc-geoip": "^1.0.0",
|
|
17
17
|
"@dhyasama/ffvc-s3": "^1.0.0",
|
|
18
|
-
"@dhyasama/ffvc-utilities": "^2.
|
|
18
|
+
"@dhyasama/ffvc-utilities": "^2.2.0",
|
|
19
19
|
"async": "^2.6.0",
|
|
20
20
|
"awesome-phonenumber": "^1.0.14",
|
|
21
21
|
"bcrypt": "^0.8.0",
|
package/test/Interaction.js
CHANGED
|
@@ -15,7 +15,7 @@ var totemCustomerId2 = new mongoose.Types.ObjectId();
|
|
|
15
15
|
var externalAttendee1 = new mongoose.Types.ObjectId();
|
|
16
16
|
var externalAttendee2 = new mongoose.Types.ObjectId();
|
|
17
17
|
|
|
18
|
-
describe
|
|
18
|
+
describe('Interaction', function() {
|
|
19
19
|
|
|
20
20
|
before(function(done) {
|
|
21
21
|
if (mongoose.connection.db) return done();
|
package/test/Organization.js
CHANGED
|
@@ -20,7 +20,7 @@ var flagId;
|
|
|
20
20
|
var someOtherFund;
|
|
21
21
|
var someOtherLp;
|
|
22
22
|
|
|
23
|
-
describe('Organization', function() {
|
|
23
|
+
describe.only('Organization', function() {
|
|
24
24
|
|
|
25
25
|
var org1, org2, org3, org4, org5;
|
|
26
26
|
var mergeId = new mongoose.Types.ObjectId();
|
|
@@ -488,7 +488,7 @@ describe('Organization', function() {
|
|
|
488
488
|
|
|
489
489
|
it('gets an org by id', function(done) {
|
|
490
490
|
|
|
491
|
-
Organization.getById(org1.id, function(err, org) {
|
|
491
|
+
Organization.getById(org1.id, { role: 'lp-full' }, function(err, org) {
|
|
492
492
|
should.not.exist(err);
|
|
493
493
|
should.exist(org);
|
|
494
494
|
org1 = org;
|
|
@@ -582,7 +582,7 @@ describe('Organization', function() {
|
|
|
582
582
|
|
|
583
583
|
it('gets the board of a company', function(done) {
|
|
584
584
|
|
|
585
|
-
Organization.getById(org3.id, function(err, result) {
|
|
585
|
+
Organization.getById(org3.id, { role: 'lp-full' }, function(err, result) {
|
|
586
586
|
should.not.exist(err);
|
|
587
587
|
should.exist(result);
|
|
588
588
|
var board = result.board;
|
|
@@ -615,7 +615,7 @@ describe('Organization', function() {
|
|
|
615
615
|
updatedOrg.people.length.should.equal(1);
|
|
616
616
|
|
|
617
617
|
// get populated org
|
|
618
|
-
Organization.getById(org1.id, function(err, org) {
|
|
618
|
+
Organization.getById(org1.id, { role: 'lp-full' }, function(err, org) {
|
|
619
619
|
|
|
620
620
|
should.not.exist(err);
|
|
621
621
|
should.exist(org);
|
|
@@ -793,7 +793,7 @@ describe('Organization', function() {
|
|
|
793
793
|
result.websiteAliases.indexOf('abc.subdomain.com').should.not.equal(-1);
|
|
794
794
|
result.websiteAliases.indexOf('trailingslash.edu').should.not.equal(-1);
|
|
795
795
|
|
|
796
|
-
Organization.getById(temp._id, function(err, result) {
|
|
796
|
+
Organization.getById(temp._id, { role: 'lp-full' }, function(err, result) {
|
|
797
797
|
|
|
798
798
|
should.not.exist(err);
|
|
799
799
|
should.exist(result);
|
|
@@ -832,14 +832,21 @@ describe('Organization', function() {
|
|
|
832
832
|
should.not.exist(err);
|
|
833
833
|
should.exist(orgResult);
|
|
834
834
|
|
|
835
|
-
Organization.getById(orgResult._id, function(err, result) {
|
|
835
|
+
Organization.getById(orgResult._id, { role: 'lp-full' }, function(err, result) {
|
|
836
836
|
|
|
837
837
|
should.not.exist(err);
|
|
838
838
|
should.exist(result);
|
|
839
839
|
result.lps.length.should.equal(1);
|
|
840
840
|
result.lps[0]._id.toString().should.equal(lpResult._id.toString());
|
|
841
841
|
|
|
842
|
-
|
|
842
|
+
Organization.getById(orgResult._id, { role: 'none' }, function(err, result) {
|
|
843
|
+
|
|
844
|
+
should.not.exist(err);
|
|
845
|
+
should.exist(result);
|
|
846
|
+
result.lps.length.should.equal(0);
|
|
847
|
+
done();
|
|
848
|
+
|
|
849
|
+
});
|
|
843
850
|
|
|
844
851
|
});
|
|
845
852
|
|