@dhyasama/totem-models 5.0.1 → 5.1.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.
@@ -570,45 +570,23 @@ module.exports = function(mongoose, config) {
570
570
  // Note that running a method on a document does not save it
571
571
  ///////////////////////////////////////////////////////////////////////////////////////
572
572
 
573
- Organization.methods.addDeal = function(status, customer, account) {
573
+ Organization.methods.addDeal = function(deal) {
574
574
 
575
575
  var self = this;
576
576
 
577
577
  // Validate inputs
578
- if (!customer) throw new Error('Customer is required');
579
- if (!status) throw new Error('Status is required');
580
- if (!account) throw new Error('Account is required');
581
-
582
- // Check if status exists and is active
583
- var statusMatch = _.find(customer.customer.deals.statuses, function(s) { return s.name.toLowerCase() == status.toLowerCase() && s.active; });
584
- if (!statusMatch) throw new Error('This deal status is not valid for this customer');
585
-
586
- // Prepare an entry to track history of deal
587
- var historyEntry = {
588
- timestamp: new Date(),
589
- account: account,
590
- status: status
591
- };
578
+ if (!deal) throw new Error('deal is required');
592
579
 
593
580
  // Check if this deal already exists
594
581
  var dealMatch = _.find(self.deals, function(d) {
595
- return utils.getIdAsString(d, 'customer') == customer._id.toString();
582
+ return d._id.toString() === deal._id.toString();
596
583
  });
597
584
 
598
585
  // Update the deal
599
- if (dealMatch) {
600
- dealMatch.status = status;
601
- dealMatch.history.push(historyEntry);
602
- }
586
+ if (dealMatch) { dealMatch = deal; }
603
587
 
604
588
  // Add the deal
605
- else {
606
- self.deals.push({
607
- customer: customer,
608
- status: status,
609
- history: [historyEntry]
610
- });
611
- }
589
+ else { self.deals.push(deal); }
612
590
 
613
591
  };
614
592
 
package/lib/Person.js CHANGED
@@ -748,6 +748,18 @@ module.exports = function(mongoose, config) {
748
748
  .exec(cb);
749
749
  };
750
750
 
751
+ Person.statics.getList = function getList(cb) {
752
+
753
+ var self = this;
754
+
755
+ self
756
+ .find({'deleted': {$ne: true}})
757
+ .select('name contact.email')
758
+ .lean()
759
+ .exec(cb);
760
+
761
+ };
762
+
751
763
  Person.statics.getFlags = function getFlags(personId, cb) {
752
764
 
753
765
  var self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
package/.npmignore DELETED
@@ -1,14 +0,0 @@
1
- lib-cov
2
- *.seed
3
- *.log
4
- *.csv
5
- *.dat
6
- *.out
7
- *.pid
8
- *.gz
9
-
10
- npm-debug.log
11
- node_modules
12
-
13
- .DS_Store
14
- .idea