<commit_before>const auth = require('@feathersjs/authentication');
const { BadRequest } = require('@feathersjs/errors');
const hooks = require('feathers-hooks-common');
const globalHooks = require('../../../hooks');
const { schoolModel: School } = require('../model');

const lookupSchool = async (context) => {
	if (!context.params || !context.params.route) {
		throw new BadRequest('Missing request params');
	}
	const { schoolId } = context.params.route;
	context.params.school = await School
		.findById(schoolId)
		.select(['name', 'currentYear', 'inMaintenanceSince', 'inMaintenance'])
		.populate(['currentYear', 'systems'])
		.lean({ virtuals: true })
		.exec();
	return context;
};

module.exports = {
	before: {
		all: [
			globalHooks.ifNotLocal(auth.hooks.authenticate('jwt')),
			globalHooks.ifNotLocal(globalHooks.restrictToCurrentSchool),
			lookupSchool,
		],
		find: [],
		create: [
			globalHooks.ifNotLocal(globalHooks.hasPermission('SCHOOL_CREATE')),
		],
		update: [
			globalHooks.ifNotLocal(globalHooks.hasPermission('SCHOOL_CREATE')),
		],
		get: [hooks.disallow()],
		patch: [hooks.disallow()],
		remove: [hooks.disallow()],
	},
};
<commit_msg>Require SCHOOL_EDIT permission instead of CREATE<commit_after>const auth = require('@feathersjs/authentication');
const { BadRequest } = require('@feathersjs/errors');
const hooks = require('feathers-hooks-common');
const globalHooks = require('../../../hooks');
const { schoolModel: School } = require('../model');

const lookupSchool = async (context) => {
	if (!context.params || !context.params.route) {
		throw new BadRequest('Missing request params');
	}
	const { schoolId } = context.params.route;
	context.params.school = await School
		.findById(schoolId)
		.select(['name', 'currentYear', 'inMaintenanceSince', 'inMaintenance'])
		.populate(['currentYear', 'systems'])
		.lean({ virtuals: true })
		.exec();
	return context;
};

module.exports = {
	before: {
		all: [
			globalHooks.ifNotLocal(auth.hooks.authenticate('jwt')),
			globalHooks.ifNotLocal(globalHooks.restrictToCurrentSchool),
			lookupSchool,
		],
		find: [],
		create: [
			globalHooks.ifNotLocal(globalHooks.hasPermission('SCHOOL_EDIT')),
		],
		update: [
			globalHooks.ifNotLocal(globalHooks.hasPermission('SCHOOL_EDIT')),
		],
		get: [hooks.disallow()],
		patch: [hooks.disallow()],
		remove: [hooks.disallow()],
	},
};

{'fraction_non_alphanumeric': 0.17644575770367243, 'fraction_numerical': 0.0, 'mean_word_length': 5.0152284263959395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3300031', 'n_tokens_mistral': 841, 'n_tokens_neox': 792, 'n_words': 133}