<commit_before>const keystone		= require( 'keystone' ),
	  userService	= require( '../middleware/service_user' ),
	  listsService	= require( '../middleware/service_lists' ),
	  pageService	= require( '../middleware/service_page' );

exports = module.exports = ( req, res ) => {
	'use strict';

	const view		= new keystone.View( req, res ),
		  locals	= res.locals;

	// store user type for determining gallery permissions
	const userType = req.user ? req.user.get( 'userType' ) : 'anonymous';
	// store the gallery permissions in local variables
	const { canBookmarkChildren, canSearchForChildren, canSeeAdvancedSearchOptions } = userService.getGalleryPermissions( req.user );
	// store the gallery permissions on locals for templating
	locals.canBookmarkChildren			= canBookmarkChildren;
	locals.canSearchForChildren			= canSearchForChildren;
	locals.canSeeAdvancedSearchOptions	= canSeeAdvancedSearchOptions;
	
	// fetch all data needed to render this page
	let fetchDisabilities			= listsService.getAllDisabilities(),
		fetchFamilyConstellations	= listsService.getAllFamilyConstellations(),
		fetchGenders				= listsService.getAllGenders(),
		fetchLanguages				= listsService.getAllLanguages(),
		fetchRaces					= listsService.getAllRaces(),
		fetchSidebarItems			= pageService.getSidebarItems();

	Promise.all( [ fetchDisabilities, fetchFamilyConstellations, fetchGenders, fetchLanguages,
				   fetchRaces, fetchSidebarItems ] )
		.then( values => {
			// assign local variables to the values returned by the promises
			const [ disabilities, familyConstellations, genders, languages, races, sidebarItems ] = values;
			// the sidebar items are a success story and event in an array, assign local variables to the two objects
			const [ randomSuccessStory, randomEvent ] = sidebarItems;
			
			// assign properties to locals for access during templating
			locals.disabilities			= disabilities;
			locals.familyConstellations	= familyConstellations;
			locals.genders				= genders;
			locals.languages			= languages;
			locals.races				= races;
			locals.randomSuccessStory	= randomSuccessStory;
			locals.randomEvent			= randomEvent;

			// render the view using the waiting-child-profiles.hbs template
			view.render( 'waiting-child-profiles' );
		})
		.catch( err => {
			// log an error for debugging purposes
			console.error( `error loading data for the waiting child profiles page - ${ err }` );
			// render the view using the waiting-child-profiles.hbs template
			view.render( 'waiting-child-profiles' );
		});
	};<commit_msg>limit transgender search option in the gallery to admin, social workers, and families who meet the requirements<commit_after>const keystone		= require( 'keystone' ),
	  userService	= require( '../middleware/service_user' ),
	  listsService	= require( '../middleware/service_lists' ),
	  pageService	= require( '../middleware/service_page' );

exports = module.exports = ( req, res ) => {
	'use strict';

	const view		= new keystone.View( req, res ),
		  locals	= res.locals;

	// store user type for determining gallery permissions
	const userType = req.user ? req.user.get( 'userType' ) : 'anonymous';
	// store the gallery permissions in local variables
	const { canBookmarkChildren, canSearchForChildren, canSeeAdvancedSearchOptions } = userService.getGalleryPermissions( req.user );
	// store the gallery permissions on locals for templating
	locals.canBookmarkChildren			= canBookmarkChildren;
	locals.canSearchForChildren			= canSearchForChildren;
	locals.canSeeAdvancedSearchOptions	= canSeeAdvancedSearchOptions;
	
	// fetch all data needed to render this page
	let fetchDisabilities			= listsService.getAllDisabilities(),
		fetchFamilyConstellations	= listsService.getAllFamilyConstellations(),
		fetchGenders				= listsService.getAllGenders(),
		fetchLanguages				= listsService.getAllLanguages(),
		fetchRaces					= listsService.getAllRaces(),
		fetchSidebarItems			= pageService.getSidebarItems();

	Promise.all( [ fetchDisabilities, fetchFamilyConstellations, fetchGenders, fetchLanguages,
				   fetchRaces, fetchSidebarItems ] )
		.then( values => {
			// assign local variables to the values returned by the promises
			const [ disabilities, familyConstellations, genders, languages, races, sidebarItems ] = values;
			// the sidebar items are a success story and event in an array, assign local variables to the two objects
			const [ randomSuccessStory, randomEvent ] = sidebarItems;
			// assign properties to locals for access during templating
			locals.disabilities			= disabilities;
			locals.familyConstellations	= familyConstellations;
			// if the user doesn't have access to advanced search options, they shouldn't have access to the transgender option in the search form
			locals.genders				= locals.canSeeAdvancedSearchOptions ?
										  genders :
										  genders.filter( gender => gender.get( 'gender' ) !== 'transgender' );
			locals.languages			= languages;
			locals.races				= races;
			locals.randomSuccessStory	= randomSuccessStory;
			locals.randomEvent			= randomEvent;

			// render the view using the waiting-child-profiles.hbs template
			view.render( 'waiting-child-profiles' );
		})
		.catch( err => {
			// log an error for debugging purposes
			console.error( `error loading data for the waiting child profiles page - ${ err }` );
			// render the view using the waiting-child-profiles.hbs template
			view.render( 'waiting-child-profiles' );
		});
	};
{'fraction_non_alphanumeric': 0.09162688211531399, 'fraction_numerical': 0.0, 'mean_word_length': 4.129001883239171, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3087984', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1520, 'n_words': 438}