Merge with master

This commit is contained in:
Dan Zajdband
2016-12-05 16:39:00 -05:00
49 changed files with 907 additions and 384 deletions
+4 -4
View File
@@ -38,11 +38,11 @@ SettingSchema.statics.getSettings = function () {
};
/**
* Gets the moderation settings and sends it back
* Gets the settings visible to the public
* @return {Promise} moderation the settings for how to moderate comments
*/
SettingSchema.statics.getModerationSetting = function () {
return this.findOne({id: '1'}).select('moderation');
SettingSchema.statics.getPublicSettings = function () {
return this.findOne({id: '1'}).select('moderation infoBoxEnable infoBoxContent');
};
/**
@@ -50,7 +50,7 @@ SettingSchema.statics.getModerationSetting = function () {
* @return {Promise} content the content of the info Box
*/
SettingSchema.statics.getInfoBoxSetting = function () {
return this.findOne({id: '1'}).select('infoBoxEnable', 'infoBoxContent');
return this.findOne({id: '1'}).select('infoBoxEnable infoBoxContent');
};
/**
+26 -1
View File
@@ -74,7 +74,15 @@ const UserSchema = new mongoose.Schema({
// Roles provides an array of roles (as strings) that is associated with a
// user.
roles: [String]
roles: [String],
// User's settings
settings: {
bio: {
type: String,
default: ''
}
}
}, {
// This will ensure that we have proper timestamps available on this model.
@@ -522,3 +530,20 @@ UserService.count = () => {
UserService.all = () => {
return UserModel.find();
};
/**
* Adds a new User bio
* @return {Promise}
*/
UserService.addBio = (id, bio) => (
UserModel.findOneAndUpdate({
id
}, {
$set: {
'settings.bio': bio
}
}, {
new: true
})
);