1
- var Applicant = require ( 'mongoose' ) . model ( 'Applicant' ) ;
1
+ const Applicant = require ( 'mongoose' ) . model ( 'Applicant' ) ;
2
2
3
- var utils = require ( '../utils/utils' ) ;
3
+ const utils = require ( '../utils/utils' ) ;
4
4
5
- module . exports . updateApplicant = function ( req , res , next ) {
6
- var applicantId = req . params . id ;
5
+ module . exports . updateApplicant = ( req , res , next ) => {
6
+ const applicantId = req . params . id ;
7
7
8
- var applicant = req . body . applicant ;
8
+ let applicant = req . body . applicant ;
9
9
10
10
applicant . updatedAt = Date . now ( ) ;
11
11
12
- var populateFields = [ { path : "user" , select : "_id google.id facebook.id facebook.firstName facebook.pictureUrl facebook.likes facebook.location facebook.birthday description" , options : { lean : true } } ] ;
12
+ const populateFields = [ { path : "user" , select : "_id google.id facebook.id facebook.firstName facebook.pictureUrl facebook.likes facebook.location facebook.birthday description status " , options : { lean : true } } ] ;
13
13
14
14
Applicant . findOneAndUpdate ( { _id : applicantId } , applicant , {
15
15
upsert : false ,
@@ -22,24 +22,24 @@ module.exports.updateApplicant = function (req, res, next) {
22
22
}
23
23
else {
24
24
res . format ( {
25
- json : function ( ) {
25
+ json : ( ) => {
26
26
res . json ( applicant ) ;
27
27
}
28
28
} ) ;
29
29
}
30
30
} ) ;
31
31
} ;
32
32
33
- module . exports . statusApplicants = function ( req , res , next ) {
34
- var itemId = req . body . itemId ;
35
- var currentStatusList = req . body . currentStatus . split ( ',' ) ;
33
+ module . exports . statusApplicants = ( req , res , next ) => {
34
+ const itemId = req . body . itemId ;
35
+ const currentStatusList = req . body . currentStatus . split ( ',' ) ;
36
36
37
- var newStatus = req . body . newStatus ;
37
+ const newStatus = req . body . newStatus ;
38
38
39
- var applicantId = req . body . applicantId ;
40
- var notApplicantId = req . body . notApplicantId ;
39
+ const applicantId = req . body . applicantId ;
40
+ const notApplicantId = req . body . notApplicantId ;
41
41
42
- var query = { item : itemId , status : { "$in" : currentStatusList } } ;
42
+ let query = { item : itemId , status : { "$in" : currentStatusList } } ;
43
43
44
44
if ( ! utils . isStringEmpty ( applicantId ) ) {
45
45
query [ "_id" ] = applicantId ;
@@ -49,14 +49,14 @@ module.exports.statusApplicants = function (req, res, next) {
49
49
query [ "_id" ] = { $ne : notApplicantId } ;
50
50
}
51
51
52
- Applicant . update ( query , { status : newStatus } , { multi : true , upsert : false } ) . exec ( function ( err , result ) {
52
+ Applicant . update ( query , { status : newStatus } , { multi : true , upsert : false } ) . exec ( ( err , result ) => {
53
53
if ( err ) {
54
54
res . status ( 500 ) . json ( {
55
55
error : "There was a problem updating the applicants into the database."
56
56
} ) ;
57
57
} else {
58
58
res . format ( {
59
- json : function ( ) {
59
+ json : ( ) => {
60
60
res . json ( result ) ;
61
61
}
62
62
} ) ;
0 commit comments