Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(department): prevent deletion if there are users associated
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Dec 6, 2022
1 parent 11d5ca4 commit 62d29e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion routes/api/department/archive.delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ARCHIVE_AND_RESTORE } from "$/permissions/department_combinations"
import { department as permissionGroup } from "$/permissions/permission_list"

import exists from "!/validators/manager/exists"
import doNotHaveAnyOwnedUser from "!/validators/manager/do_not_have_any_owned_user"
import makeResourceIdentifierListDocumentRules
from "!/rule_sets/make_resource_identifier_list_document"

Expand All @@ -35,7 +36,11 @@ export default class extends JSONController {
}

makeBodyRuleGenerator(unusedRequest: Request): FieldRules {
return makeResourceIdentifierListDocumentRules("department", exists, DepartmentManager)
return makeResourceIdentifierListDocumentRules("department", exists, DepartmentManager, {
"postIDRules": {
"pipes": [ doNotHaveAnyOwnedUser ]
}
})
}

async handle(request: Request, unusedResponse: Response): Promise<NoContentResponseInfo> {
Expand Down

0 comments on commit 62d29e8

Please sign in to comment.