diff --git a/app/models/form.server.model.js b/app/models/form.server.model.js index e276ead6..8ff34a77 100644 --- a/app/models/form.server.model.js +++ b/app/models/form.server.model.js @@ -95,18 +95,14 @@ var FormSchema = new Schema({ }, font: String, -<<<<<<< HEAD backgroundImage: { type: Schema.Types.Mixed } -======= - backgroundImage: type: Schema.Types.Mixed ->>>>>>> 33243bea2a1f74f8f417b240f5ad068c1d05c6bd } }); //Delete template PDF of current Form FormSchema.pre('remove', function (next) { - if(this.pdf){ + if(this.pdf && process.env.NODE_ENV === 'development'){ //Delete template form fs.unlink(this.pdf.path, function(err){ if (err) throw err; diff --git a/app/models/user.server.model.js b/app/models/user.server.model.js index 4c593cf4..1a46350e 100755 --- a/app/models/user.server.model.js +++ b/app/models/user.server.model.js @@ -106,23 +106,26 @@ UserSchema.virtual('displayName').get(function () { //Create folder for user's pdfs UserSchema.pre('save', function (next) { - if(!this.username || this.username !== this.email){ - this.username = this.email; - } - var newDestination = path.join(config.pdfUploadPath, this.username.replace(/ /g,'')), - stat = null; + if(process.env.NODE_ENV === 'development'){ + if(!this.username || this.username !== this.email){ + this.username = this.email; + } + var newDestination = path.join(config.pdfUploadPath, this.username.replace(/ /g,'')), + stat = null; - try { - stat = fs.statSync(newDestination); - } catch (err) { - fs.mkdirSync(newDestination); - } - if (stat && !stat.isDirectory()) { - // console.log('Directory cannot be created'); - next( new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"') ); - }else{ - next(); - } + try { + stat = fs.statSync(newDestination); + } catch (err) { + fs.mkdirSync(newDestination); + } + if (stat && !stat.isDirectory()) { + // console.log('Directory cannot be created'); + next( new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"') ); + }else{ + next(); + } + } + next(); }); /**