@dhyasama/totem-models 6.16.0 → 6.16.2
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/Organization.js +11 -13
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -822,13 +822,13 @@ module.exports = function(mongoose, config) {
|
|
|
822
822
|
var self = this;
|
|
823
823
|
|
|
824
824
|
if (self.ipo.ticker) return 'IPO';
|
|
825
|
-
else if (self.acquired.by) return 'Acquired';
|
|
825
|
+
else if (self.acquired.by || self.acquired.on) return 'Acquired';
|
|
826
826
|
else if (self.shutdown) return 'Shutdown';
|
|
827
827
|
else if (self.inactive) return 'Inactive';
|
|
828
828
|
else return 'Active';
|
|
829
829
|
|
|
830
830
|
});
|
|
831
|
-
|
|
831
|
+
|
|
832
832
|
Organization.virtual('websites').get(function () {
|
|
833
833
|
|
|
834
834
|
var self = this;
|
|
@@ -1818,20 +1818,18 @@ module.exports = function(mongoose, config) {
|
|
|
1818
1818
|
this.collection.stats(cb);
|
|
1819
1819
|
};
|
|
1820
1820
|
|
|
1821
|
-
|
|
1821
|
+
Organization.statics.upsert = function(org, username, cb) {
|
|
1822
1822
|
|
|
1823
|
-
if (!
|
|
1824
|
-
if (!username) { return cb(new Error('
|
|
1823
|
+
if (!org) { return cb(new Error('Organization is required'), null); }
|
|
1824
|
+
if (!username) { return cb(new Error('Username is required'), null); }
|
|
1825
1825
|
|
|
1826
|
-
|
|
1827
|
-
|
|
1826
|
+
org.entered.by = username;
|
|
1827
|
+
org.entered.on = new Date();
|
|
1828
1828
|
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
return cb(null, result);
|
|
1834
|
-
});
|
|
1829
|
+
// Clean up missing references
|
|
1830
|
+
org.people = _.reject(org.people, function(item) { return !item.person; });
|
|
1831
|
+
|
|
1832
|
+
org.save(cb);
|
|
1835
1833
|
|
|
1836
1834
|
};
|
|
1837
1835
|
|