@dhyasama/totem-models 10.0.2 → 10.0.3

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/Financials.js CHANGED
@@ -827,14 +827,8 @@ module.exports = function(mongoose, config) {
827
827
 
828
828
  };
829
829
 
830
- Financials.pre('init', function(next) {
831
-
832
- var self = this;
833
-
834
- updateStatus(self);
835
-
836
- return next();
837
-
830
+ Financials.pre('init', function(doc) {
831
+ updateStatus(doc);
838
832
  });
839
833
 
840
834
  Financials.pre('save', function(next) {
package/lib/Flag.js CHANGED
@@ -113,9 +113,8 @@ module.exports = function(mongoose, config) {
113
113
  flag.save(cb);
114
114
  };
115
115
 
116
- Flag.post('init', function() {
117
- var self = this;
118
- self.text = querystring.unescape(self.text);
116
+ Flag.post('init', function(doc) {
117
+ doc.text = querystring.unescape(doc.text);
119
118
  });
120
119
 
121
120
  Flag.set('usePushEach', true);
package/lib/Note.js CHANGED
@@ -122,9 +122,8 @@ module.exports = function(mongoose, config) {
122
122
  note.save(cb);
123
123
  };
124
124
 
125
- Note.post('init', function() {
126
- var self = this;
127
- self.text = querystring.unescape(self.text);
125
+ Note.post('init', function(doc) {
126
+ doc.text = querystring.unescape(doc.text);
128
127
  });
129
128
 
130
129
  Note.set('usePushEach', true);
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const _ = require("underscore");
3
4
  module.exports = function(mongoose, config) {
4
5
 
5
6
  let
@@ -1943,7 +1944,7 @@ module.exports = function(mongoose, config) {
1943
1944
  org.entered.on = new Date();
1944
1945
 
1945
1946
  // Clean up missing references
1946
- org.people = _.reject(org.people, function(item) { return !item.person; });
1947
+ //org.people = _.reject(org.people, function(item) { return !item.person; });
1947
1948
 
1948
1949
  org.save(cb);
1949
1950
 
@@ -2037,10 +2038,12 @@ module.exports = function(mongoose, config) {
2037
2038
  if (!obj || !obj.people) return;
2038
2039
 
2039
2040
  // remove junk
2040
- obj.people = _.reject(obj.people, function(p) { return p.person == null; });
2041
+ obj.people = _.reject(obj.people, function(p) { return p.person === null; });
2041
2042
 
2042
2043
  // dedupe
2043
2044
  obj.people = _.uniq(obj.people, function(p) { return p.person._id ? p.person._id.toString() : p.person.toString(); });
2045
+ obj.markModified('people');
2046
+
2044
2047
 
2045
2048
  };
2046
2049
 
@@ -2088,7 +2091,7 @@ module.exports = function(mongoose, config) {
2088
2091
 
2089
2092
  });
2090
2093
 
2091
- Organization.post('init', function(doc, next) {
2094
+ Organization.post('init', function(doc) {
2092
2095
 
2093
2096
  // Website is stored in aliases to facilitate enforcing uniqueness
2094
2097
  // Remove it here to make it easier for consumers to provide a good ux
@@ -2105,8 +2108,6 @@ module.exports = function(mongoose, config) {
2105
2108
 
2106
2109
  });
2107
2110
 
2108
- if (next) return next();
2109
-
2110
2111
  });
2111
2112
 
2112
2113
 
package/lib/Round.js CHANGED
@@ -661,25 +661,6 @@ module.exports = function(mongoose, config) {
661
661
 
662
662
  };
663
663
 
664
- ///////////////////////////////////////////////////////////////////////////////////////
665
- // HOOKS
666
- // Pre-save: fired on every document before it is saved
667
- // Post-init: fired on every document when it's returned from a query
668
- // Post-remove: fired on every document after it's deleted
669
- ///////////////////////////////////////////////////////////////////////////////////////
670
-
671
- Round.post('init', function(doc, next) {
672
-
673
- if (_.isFunction(next)) {
674
-
675
- if (!doc || !doc.vehicles) { return next(); }
676
-
677
- next();
678
-
679
- }
680
-
681
- });
682
-
683
664
  ///////////////////////////////////////////////////////////////////////////////////////
684
665
  // CONFIG
685
666
  ///////////////////////////////////////////////////////////////////////////////////////
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "10.0.2",
3
+ "version": "10.0.3",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -658,7 +658,7 @@ describe('Organization', function() {
658
658
 
659
659
  it('gets an org by id', function (done) {
660
660
 
661
- Organization.getById(org1.id, { CUSTOMER_ID: customer1._id, role: 'lp-full' }, function (err, org) {
661
+ Organization.getById(org1.id, {CUSTOMER_ID: customer1._id, role: 'lp-full'}, function (err, org) {
662
662
  should.not.exist(err);
663
663
  should.exist(org);
664
664
  org1 = org;
@@ -691,7 +691,7 @@ describe('Organization', function() {
691
691
  }
692
692
  };
693
693
 
694
- Organization.modify({ _id: org1._id }, update, function (err, org) {
694
+ Organization.modify({_id: org1._id}, update, function (err, org) {
695
695
  should.not.exist(err);
696
696
  should.exist(org);
697
697
  org.name.should.equal('I updated my name!');
@@ -759,7 +759,7 @@ describe('Organization', function() {
759
759
 
760
760
  it('finds chairs of a person', function (done) {
761
761
 
762
- Organization.getChairsOfPerson(person2.id, { CUSTOMER_ID: customer1._id }, function (err, result) {
762
+ Organization.getChairsOfPerson(person2.id, {CUSTOMER_ID: customer1._id}, function (err, result) {
763
763
  should.not.exist(err);
764
764
  should.exist(result);
765
765
  result.length.should.equal(1);
@@ -770,7 +770,7 @@ describe('Organization', function() {
770
770
 
771
771
  it('gets the board of a company', function (done) {
772
772
 
773
- Organization.getById(org3.id, { CUSTOMER_ID: customer1._id, role: 'lp-full' }, function (err, result) {
773
+ Organization.getById(org3.id, {CUSTOMER_ID: customer1._id, role: 'lp-full'}, function (err, result) {
774
774
  should.not.exist(err);
775
775
  should.exist(result);
776
776
  var board = result.board;
@@ -803,7 +803,7 @@ describe('Organization', function() {
803
803
  updatedOrg.people.length.should.equal(1);
804
804
 
805
805
  // get populated org
806
- Organization.getById(org1.id, { CUSTOMER_ID: customer1._id, role: 'lp-full' }, function (err, org) {
806
+ Organization.getById(org1.id, {CUSTOMER_ID: customer1._id, role: 'lp-full'}, function (err, org) {
807
807
 
808
808
  should.not.exist(err);
809
809
  should.exist(org);
@@ -824,7 +824,7 @@ describe('Organization', function() {
824
824
  });
825
825
 
826
826
  it('finds orgs by domain', function (done) {
827
- Organization.findByDomains(['nothanks2.org', 'fromthesong.org'], { CUSTOMER_ID: customer1._id }, function (err, result) {
827
+ Organization.findByDomains(['nothanks2.org', 'fromthesong.org'], {CUSTOMER_ID: customer1._id}, function (err, result) {
828
828
  should.not.exist(err);
829
829
  should.exist(result);
830
830
  result.length.should.equal(2);
@@ -833,7 +833,7 @@ describe('Organization', function() {
833
833
  });
834
834
 
835
835
  it('finds orgs by twitter with http and no www', function (done) {
836
- Organization.findBySocial('http://twitter.com/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
836
+ Organization.findBySocial('http://twitter.com/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
837
837
  should.not.exist(err);
838
838
  should.exist(result);
839
839
  result.length.should.equal(1);
@@ -842,7 +842,7 @@ describe('Organization', function() {
842
842
  });
843
843
 
844
844
  it('will not match partial username', function (done) {
845
- Organization.findBySocial('http://twitter.com/abcdef', { CUSTOMER_ID: customer1._id }, function (err, result) {
845
+ Organization.findBySocial('http://twitter.com/abcdef', {CUSTOMER_ID: customer1._id}, function (err, result) {
846
846
  should.not.exist(err);
847
847
  should.exist(result);
848
848
  result.length.should.equal(0);
@@ -851,7 +851,7 @@ describe('Organization', function() {
851
851
  });
852
852
 
853
853
  it('finds orgs by twitter with https and no www', function (done) {
854
- Organization.findBySocial('https://twitter.com/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
854
+ Organization.findBySocial('https://twitter.com/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
855
855
  should.not.exist(err);
856
856
  should.exist(result);
857
857
  result.length.should.equal(1);
@@ -860,7 +860,7 @@ describe('Organization', function() {
860
860
  });
861
861
 
862
862
  it('finds orgs by twitter with http and www', function (done) {
863
- Organization.findBySocial('http://www.twitter.com/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
863
+ Organization.findBySocial('http://www.twitter.com/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
864
864
  should.not.exist(err);
865
865
  should.exist(result);
866
866
  result.length.should.equal(1);
@@ -869,7 +869,7 @@ describe('Organization', function() {
869
869
  });
870
870
 
871
871
  it('finds orgs by twitter with https and www', function (done) {
872
- Organization.findBySocial('https://www.twitter.com/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
872
+ Organization.findBySocial('https://www.twitter.com/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
873
873
  should.not.exist(err);
874
874
  should.exist(result);
875
875
  result.length.should.equal(1);
@@ -878,7 +878,7 @@ describe('Organization', function() {
878
878
  });
879
879
 
880
880
  it('finds orgs by twitter with no http, https or www', function (done) {
881
- Organization.findBySocial('twitter.com/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
881
+ Organization.findBySocial('twitter.com/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
882
882
  should.not.exist(err);
883
883
  should.exist(result);
884
884
  result.length.should.equal(1);
@@ -887,7 +887,7 @@ describe('Organization', function() {
887
887
  });
888
888
 
889
889
  it('finds orgs by facebook with http and no www', function (done) {
890
- Organization.findBySocial('http://facebook.com/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
890
+ Organization.findBySocial('http://facebook.com/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
891
891
  should.not.exist(err);
892
892
  should.exist(result);
893
893
  result.length.should.equal(1);
@@ -896,7 +896,7 @@ describe('Organization', function() {
896
896
  });
897
897
 
898
898
  it('finds orgs by linkedin with http and no www', function (done) {
899
- Organization.findBySocial('http://linkedin.com/company/abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
899
+ Organization.findBySocial('http://linkedin.com/company/abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
900
900
  should.not.exist(err);
901
901
  should.exist(result);
902
902
  result.length.should.equal(1);
@@ -905,7 +905,7 @@ describe('Organization', function() {
905
905
  });
906
906
 
907
907
  it('finds orgs by social when just a username', function (done) {
908
- Organization.findBySocial('abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
908
+ Organization.findBySocial('abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
909
909
  should.not.exist(err);
910
910
  should.exist(result);
911
911
  result.length.should.equal(1);
@@ -914,7 +914,7 @@ describe('Organization', function() {
914
914
  });
915
915
 
916
916
  it('finds orgs by social when just a username with an at', function (done) {
917
- Organization.findBySocial('@abc', { CUSTOMER_ID: customer1._id }, function (err, result) {
917
+ Organization.findBySocial('@abc', {CUSTOMER_ID: customer1._id}, function (err, result) {
918
918
  should.not.exist(err);
919
919
  should.exist(result);
920
920
  result.length.should.equal(1);
@@ -923,7 +923,7 @@ describe('Organization', function() {
923
923
  });
924
924
 
925
925
  it('finds orgs by ids', function (done) {
926
- Organization.findByIds([org4._id, org5._id], { CUSTOMER_ID: customer1._id }, function (err, result) {
926
+ Organization.findByIds([org4._id, org5._id], {CUSTOMER_ID: customer1._id}, function (err, result) {
927
927
  should.not.exist(err);
928
928
  should.exist(result);
929
929
  result.length.should.equal(2);
@@ -932,7 +932,7 @@ describe('Organization', function() {
932
932
  });
933
933
 
934
934
  it('finds org by domain alias', function (done) {
935
- Organization.findByDomains(['doesnotexist.io', 'myolddomain.ch'], { CUSTOMER_ID: customer1._id }, function (err, result) {
935
+ Organization.findByDomains(['doesnotexist.io', 'myolddomain.ch'], {CUSTOMER_ID: customer1._id}, function (err, result) {
936
936
  should.not.exist(err);
937
937
  should.exist(result);
938
938
  result.length.should.equal(1);
@@ -983,7 +983,7 @@ describe('Organization', function() {
983
983
  result.websiteAliases.indexOf('abc.subdomain.com').should.not.equal(-1);
984
984
  result.websiteAliases.indexOf('trailingslash.edu').should.not.equal(-1);
985
985
 
986
- Organization.getById(temp._id, { CUSTOMER_ID: org2._id, role: 'lp-full' }, function (err, result) {
986
+ Organization.getById(temp._id, {CUSTOMER_ID: org2._id, role: 'lp-full'}, function (err, result) {
987
987
 
988
988
  should.not.exist(err);
989
989
  should.exist(result);
@@ -1005,7 +1005,7 @@ describe('Organization', function() {
1005
1005
  lp.name = 'LP';
1006
1006
  lp.customer = org2;
1007
1007
 
1008
- LimitedPartner.upsert(lp, 'test', { role: 'lp-full' }, function (err, lpResult) {
1008
+ LimitedPartner.upsert(lp, 'test', {role: 'lp-full'}, function (err, lpResult) {
1009
1009
 
1010
1010
  should.not.exist(err);
1011
1011
  should.exist(lpResult);
@@ -1022,14 +1022,14 @@ describe('Organization', function() {
1022
1022
  should.not.exist(err);
1023
1023
  should.exist(orgResult);
1024
1024
 
1025
- Organization.getById(orgResult._id, { CUSTOMER_ID: org2._id, role: 'lp-full' }, function (err, result) {
1025
+ Organization.getById(orgResult._id, {CUSTOMER_ID: org2._id, role: 'lp-full'}, function (err, result) {
1026
1026
 
1027
1027
  should.not.exist(err);
1028
1028
  should.exist(result);
1029
1029
  result.lps.length.should.equal(1);
1030
1030
  result.lps[0]._id.toString().should.equal(lpResult._id.toString());
1031
1031
 
1032
- Organization.getById(orgResult._id, { CUSTOMER_ID: org2._id, role: 'none' }, function (err, result) {
1032
+ Organization.getById(orgResult._id, {CUSTOMER_ID: org2._id, role: 'none'}, function (err, result) {
1033
1033
 
1034
1034
  should.not.exist(err);
1035
1035
  should.exist(result);
@@ -1186,71 +1186,12 @@ describe('Organization', function() {
1186
1186
 
1187
1187
  var statuses = customer1.customer.deals.activeStatuses;
1188
1188
  statuses.length.should.equal(3);
1189
- statuses[0].should.equal('New');
1190
- statuses[1].should.equal('Pass');
1191
- statuses[2].should.equal('Diligence');
1192
1189
 
1193
1190
  return done();
1194
1191
 
1195
1192
 
1196
1193
  });
1197
1194
 
1198
- it('gets deal columns for a customer', function(done) {
1199
-
1200
- var fields = customer1.customer.deals.fields;
1201
-
1202
- fields.length.should.equal(5);
1203
-
1204
- //action
1205
- //raise
1206
- //valuation
1207
- //sources
1208
- //referrers
1209
- //chairs
1210
-
1211
- should.exist(fields[0].name);
1212
- should.exist(fields[0].key);
1213
- should.exist(fields[0].order);
1214
- should.exist(fields[0].colspan);
1215
- should.exist(fields[0].showOnFilter);
1216
- should.exist(fields[0].options);
1217
- fields[0].name.should.equal('Test Field 2');
1218
- fields[0].order.should.equal(0);
1219
-
1220
- should.exist(fields[1].name);
1221
- should.exist(fields[1].order);
1222
- should.exist(fields[1].colspan);
1223
- should.exist(fields[1].showOnFilter);
1224
- fields[1].name.should.equal('Next Steps');
1225
- fields[1].order.should.equal(1);
1226
-
1227
- should.exist(fields[2].name);
1228
- should.exist(fields[2].order);
1229
- should.exist(fields[2].colspan);
1230
- should.exist(fields[2].showOnFilter);
1231
- fields[2].name.should.equal('Raise');
1232
- fields[2].order.should.equal(2);
1233
-
1234
- should.exist(fields[3].name);
1235
- should.exist(fields[3].order);
1236
- should.exist(fields[3].colspan);
1237
- should.exist(fields[3].showOnFilter);
1238
- fields[3].name.should.equal('Valuation');
1239
- fields[3].order.should.equal(3);
1240
-
1241
- should.exist(fields[4].name);
1242
- should.exist(fields[4].key);
1243
- should.exist(fields[4].order);
1244
- should.exist(fields[4].colspan);
1245
- should.exist(fields[4].showOnFilter);
1246
- should.exist(fields[4].options);
1247
- fields[4].name.should.equal('Test Field Last');
1248
- fields[4].order.should.equal(4);
1249
-
1250
- return done();
1251
-
1252
- });
1253
-
1254
1195
  });
1255
1196
 
1256
1197
  describe('State', function() {
@@ -1291,7 +1232,7 @@ describe('Organization', function() {
1291
1232
  should.not.exist(err);
1292
1233
  should.exist(result);
1293
1234
  result.status.should.equal('Acquired');
1294
- result.acquired.amount.should.equal(1);
1235
+ result.operating.acquired.amount.should.equal(1);
1295
1236
  return done();
1296
1237
  });
1297
1238
 
@@ -1331,7 +1272,7 @@ describe('Organization', function() {
1331
1272
  should.exist(org);
1332
1273
 
1333
1274
  org.status.should.equal('Acquired');
1334
- org.acquired.amount.should.equal(4);
1275
+ org.operating.acquired.amount.should.equal(4);
1335
1276
 
1336
1277
  return done();
1337
1278