@@ -73,16 +73,16 @@ var youthBlackList = ['name'];
73
73
74
74
// var allowedOptionalFieldsYouth = ['dojos', 'linkedin', 'twitter', 'badges'];
75
75
var allowedOptionalFieldsYouth = _ . filter ( hiddenFields , function ( field ) {
76
- if ( _ . contains ( field . allowedUserTypes , 'attendee-o13' ) ) return field . modelName ;
76
+ if ( _ . includes ( field . allowedUserTypes , 'attendee-o13' ) ) return field . modelName ;
77
77
} ) ;
78
78
79
79
// var allowedOptionalFieldsChampion = ['notes', 'projects'];
80
80
var allowedOptionalFieldsChampion = _ . map ( hiddenFields , function ( field ) {
81
- if ( _ . contains ( field . allowedUserTypes , 'champion' ) ) return field . modelName ;
81
+ if ( _ . includes ( field . allowedUserTypes , 'champion' ) ) return field . modelName ;
82
82
} ) ;
83
83
84
84
var allowedOptionalFieldsMentor = _ . map ( hiddenFields , function ( field ) {
85
- if ( _ . contains ( field . allowedUserTypes , 'mentor' ) ) return field . modelName ;
85
+ if ( _ . includes ( field . allowedUserTypes , 'mentor' ) ) return field . modelName ;
86
86
} ) ;
87
87
88
88
var allowedOptionalFields = {
@@ -207,7 +207,7 @@ function cmd_user_profile_data (args, done) {
207
207
if ( _ . isEmpty ( usersDojos ) ) {
208
208
profile . userTypes . push ( profile . userType ) ;
209
209
} else {
210
- profile . userTypes = _ . flatten ( _ . pluck ( usersDojos , ' userTypes' ) ) ;
210
+ profile . userTypes = _ . flatten ( usersDojos . map ( ud => ud . userTypes ) ) ;
211
211
profile . userTypes . push ( profile . userType ) ;
212
212
}
213
213
profile . userTypes = _ . uniq ( profile . userTypes ) ;
@@ -219,14 +219,14 @@ function cmd_user_profile_data (args, done) {
219
219
function addFlags ( profile , done ) {
220
220
var userId = args . user ? args . user . id : null ;
221
221
flags . user . ownProfile = profile && profile . userId === userId ;
222
- flags . user . myChild = _ . contains ( profile . parents , userId ) ;
222
+ flags . user . myChild = _ . includes ( profile . parents , userId ) ;
223
223
flags . user . isTicketingAdmin = _ . find ( profile . userPermissions , function ( profileUserPermission ) {
224
224
return profileUserPermission . name === 'ticketing-admin' ;
225
225
} ) ;
226
226
if ( userId ) {
227
227
seneca . act ( { role : 'cd-users' , cmd : 'load' , id : userId } , function ( err , user ) {
228
228
if ( err ) return done ( err ) ;
229
- if ( _ . contains ( user . roles , 'cdf-admin' ) ) flags . requestingUser . isCDF = true ;
229
+ if ( _ . includes ( user . roles , 'cdf-admin' ) ) flags . requestingUser . isCDF = true ;
230
230
return done ( null , profile ) ;
231
231
} ) ;
232
232
} else {
@@ -279,15 +279,15 @@ function cmd_user_profile_data (args, done) {
279
279
280
280
// We look at viewer rights
281
281
_ . each ( requestingUserSharedDojos , function ( requestingUserDojo ) {
282
- if ( _ . contains ( requestingUserDojo . userTypes , 'champion' ) ) flags . requestingUser . isChampionOf = true ;
283
- if ( _ . contains ( requestingUserDojo . userTypes , 'mentor' ) ) flags . requestingUser . isMentorOf = true ;
282
+ if ( _ . includes ( requestingUserDojo . userTypes , 'champion' ) ) flags . requestingUser . isChampionOf = true ;
283
+ if ( _ . includes ( requestingUserDojo . userTypes , 'mentor' ) ) flags . requestingUser . isMentorOf = true ;
284
284
if ( _ . find ( requestingUserDojo . userPermissions , { 'title' : 'Dojo Admin' , 'name' : 'dojo-admin' } ) ) flags . requestingUser . isDojoAdminOf = true ;
285
285
if ( _ . find ( requestingUserDojo . userPermissions , { 'title' : 'Ticketing Admin' , 'name' : 'ticketing-admin' } ) ) flags . requestingUser . isTicketingAdminOf = true ;
286
286
} ) ;
287
287
288
288
// Viewed user flags
289
289
_ . each ( profileDojos , function ( profileDojo ) {
290
- if ( _ . contains ( profileDojo . userTypes , 'champion' ) ) flags . user . isChampion = true ;
290
+ if ( _ . includes ( profileDojo . userTypes , 'champion' ) ) flags . user . isChampion = true ;
291
291
if ( _ . find ( profileDojo . userPermissions , { 'title' : 'Dojo Admin' , 'name' : 'dojo-admin' } ) ) flags . user . isDojoAdmin = true ;
292
292
if ( _ . find ( profileDojo . userPermissions , { 'title' : 'Ticketing Admin' , 'name' : 'ticketing-admin' } ) ) flags . user . isTicketingAdmin = true ;
293
293
} ) ;
@@ -307,23 +307,23 @@ function cmd_user_profile_data (args, done) {
307
307
function filterFields ( err , profile , requestingUserProfile ) {
308
308
var allowedFields = [ ] ;
309
309
310
- if ( _ . contains ( profile . userTypes , 'attendee-o13' ) ) {
310
+ if ( _ . includes ( profile . userTypes , 'attendee-o13' ) ) {
311
311
allowedFields = _ . union ( allowedFields , allowedOptionalFields [ 'attendee-o13' ] ) ;
312
312
}
313
313
314
- if ( _ . contains ( profile . userTypes , 'champion' ) ) {
314
+ if ( _ . includes ( profile . userTypes , 'champion' ) ) {
315
315
allowedFields = _ . union ( allowedFields , allowedOptionalFields [ 'champion' ] ) ;
316
316
}
317
317
318
- if ( _ . contains ( profile . userTypes , 'mentor' ) ) {
318
+ if ( _ . includes ( profile . userTypes , 'mentor' ) ) {
319
319
allowedFields = _ . union ( allowedFields , allowedOptionalFields [ 'mentor' ] ) ;
320
320
}
321
321
322
322
var keysToOmit = [ ] ;
323
323
if ( ! flags . user . ownProfile && ! flags . user . myChild && ! flags . requestingUser . isTicketingAdmin &&
324
324
! flags . requestingUser . isChampionOf && ! flags . requestingUser . isDojoAdminOf && ! flags . requestingUser . isCDF ) {
325
325
_ . forOwn ( profile . optionalHiddenFields , function ( value , key ) {
326
- if ( value && _ . contains ( allowedFields , key ) ) {
326
+ if ( value && _ . includes ( allowedFields , key ) ) {
327
327
keysToOmit . push ( key ) ;
328
328
}
329
329
} ) ;
@@ -380,13 +380,13 @@ function cmd_user_profile_data (args, done) {
380
380
* @return {[type] } [description]
381
381
*/
382
382
function publicProfilesFilter ( profile , done ) {
383
- if ( ! flags . requestingUser . canBypassFilter && ! _ . contains ( profile . userTypes , 'attendee-u13' ) ) {
383
+ if ( ! flags . requestingUser . canBypassFilter && ! _ . includes ( profile . userTypes , 'attendee-u13' ) ) {
384
384
// Build the list of fields to pick
385
385
_ . each ( profile . userTypes , function ( userType ) {
386
386
publicFields = _ . union ( publicFields , fieldWhiteList [ userType ] ) ;
387
387
} ) ;
388
388
389
- if ( _ . contains ( profile . userTypes , 'attendee-o13' ) ) {
389
+ if ( _ . includes ( profile . userTypes , 'attendee-o13' ) ) {
390
390
publicFields = _ . remove ( publicFields , function ( publicField ) {
391
391
var idx = youthBlackList . indexOf ( publicField ) ;
392
392
return ! ( idx > - 1 ) ;
@@ -414,7 +414,7 @@ function cmd_user_profile_data (args, done) {
414
414
* @return {[type] } [description]
415
415
*/
416
416
function under13Filter ( profile , done ) {
417
- if ( _ . contains ( profile . userTypes , 'attendee-u13' ) && ! flags . requestingUser . canBypassFilter ) {
417
+ if ( _ . includes ( profile . userTypes , 'attendee-u13' ) && ! flags . requestingUser . canBypassFilter ) {
418
418
profile = { } ;
419
419
}
420
420
return done ( null , profile ) ;
0 commit comments