From 991afeb1bca5a974dc48a6e92640b226d706901c Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Tue, 14 May 2024 16:45:23 -0700 Subject: [PATCH] [TM-904] Add HBF as a framework permission and admin type. --- app/Console/Commands/Migration/RolesMigrationCommand.php | 7 ++++++- app/Policies/FrameworkPolicy.php | 2 +- app/Policies/V2/FundingProgrammePolicy.php | 2 +- app/Policies/V2/Nurseries/NurseryPolicy.php | 2 +- app/Policies/V2/Nurseries/NurseryReportPolicy.php | 2 +- app/Policies/V2/Projects/ProjectPolicy.php | 2 +- app/Policies/V2/Projects/ProjectReportPolicy.php | 2 +- app/Policies/V2/Sites/SitePolicy.php | 2 +- app/Policies/V2/Sites/SiteReportPolicy.php | 2 +- app/Policies/V2/Tasks/TaskPolicy.php | 2 +- app/Policies/V2/UpdateRequests/UpdateRequestPolicy.php | 2 +- config/wri/permissions.php | 1 + 12 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/Migration/RolesMigrationCommand.php b/app/Console/Commands/Migration/RolesMigrationCommand.php index a0f1a4b41..9855a097c 100644 --- a/app/Console/Commands/Migration/RolesMigrationCommand.php +++ b/app/Console/Commands/Migration/RolesMigrationCommand.php @@ -52,7 +52,7 @@ public function handle() if (Role::where('name', 'admin-super')->count() === 0) { $role = Role::create(['name' => 'admin-super']); - $role->givePermissionTo(['framework-terrafund', 'framework-ppc', 'framework-terrafund-enterprises', 'custom-forms-manage', 'users-manage', 'monitoring-manage', 'reports-manage']); + $role->givePermissionTo(['framework-terrafund', 'framework-ppc', 'framework-terrafund-enterprises', 'framework-hbf', 'custom-forms-manage', 'users-manage', 'monitoring-manage', 'reports-manage']); } if (Role::where('name', 'admin-ppc')->count() === 0) { @@ -65,6 +65,11 @@ public function handle() $role->givePermissionTo(['framework-terrafund', 'framework-terrafund-enterprises', 'custom-forms-manage', 'users-manage', 'monitoring-manage', 'reports-manage']); } + if (Role::where('name', 'admin-hbf')->count() === 0) { + $role = Role::create(['name' => 'admin-hbf']); + $role->givePermissionTo(['framework-hbf', 'custom-forms-manage', 'users-manage', 'monitoring-manage', 'reports-manage']); + } + if (Role::where('name', 'project-developer')->count() === 0) { $role = Role::create(['name' => 'project-developer']); $role->givePermissionTo(['manage-own']); diff --git a/app/Policies/FrameworkPolicy.php b/app/Policies/FrameworkPolicy.php index 1bd9d1f48..977f26a3f 100644 --- a/app/Policies/FrameworkPolicy.php +++ b/app/Policies/FrameworkPolicy.php @@ -8,6 +8,6 @@ class FrameworkPolicy extends Policy { public function update(?UserModel $user): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } } diff --git a/app/Policies/V2/FundingProgrammePolicy.php b/app/Policies/V2/FundingProgrammePolicy.php index d41deaa8d..28ce24739 100644 --- a/app/Policies/V2/FundingProgrammePolicy.php +++ b/app/Policies/V2/FundingProgrammePolicy.php @@ -10,6 +10,6 @@ class FundingProgrammePolicy extends Policy { public function uploadFiles(?User $user, ?FundingProgramme $model = null): bool { - return $this->isVerifiedAdmin($user) || $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $this->isVerifiedAdmin($user) || $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } } diff --git a/app/Policies/V2/Nurseries/NurseryPolicy.php b/app/Policies/V2/Nurseries/NurseryPolicy.php index d036703b9..bb7a96a33 100644 --- a/app/Policies/V2/Nurseries/NurseryPolicy.php +++ b/app/Policies/V2/Nurseries/NurseryPolicy.php @@ -25,7 +25,7 @@ public function read(?User $user, ?Nursery $nursey = null): bool public function readAll(?User $user, ?Nursery $nursey = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?Nursery $nursey = null): bool diff --git a/app/Policies/V2/Nurseries/NurseryReportPolicy.php b/app/Policies/V2/Nurseries/NurseryReportPolicy.php index d0a7fe012..cdecf2454 100644 --- a/app/Policies/V2/Nurseries/NurseryReportPolicy.php +++ b/app/Policies/V2/Nurseries/NurseryReportPolicy.php @@ -25,7 +25,7 @@ public function read(?User $user, ?NurseryReport $report = null): bool public function readAll(?User $user, ?NurseryReport $report = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?NurseryReport $report = null): bool diff --git a/app/Policies/V2/Projects/ProjectPolicy.php b/app/Policies/V2/Projects/ProjectPolicy.php index 0418ac7c4..307c5e73f 100644 --- a/app/Policies/V2/Projects/ProjectPolicy.php +++ b/app/Policies/V2/Projects/ProjectPolicy.php @@ -30,7 +30,7 @@ public function read(?User $user, ?Project $project = null): bool public function readAll(?User $user, ?Project $project = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?Project $project = null): bool diff --git a/app/Policies/V2/Projects/ProjectReportPolicy.php b/app/Policies/V2/Projects/ProjectReportPolicy.php index 81b8b1e7e..cd83e87e4 100644 --- a/app/Policies/V2/Projects/ProjectReportPolicy.php +++ b/app/Policies/V2/Projects/ProjectReportPolicy.php @@ -25,7 +25,7 @@ public function read(?User $user, ?ProjectReport $report = null): bool public function readAll(?User $user, ?ProjectReport $report = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?ProjectReport $report = null): bool diff --git a/app/Policies/V2/Sites/SitePolicy.php b/app/Policies/V2/Sites/SitePolicy.php index 153f6c065..2b7b22a52 100644 --- a/app/Policies/V2/Sites/SitePolicy.php +++ b/app/Policies/V2/Sites/SitePolicy.php @@ -25,7 +25,7 @@ public function read(?User $user, ?Site $site = null): bool public function readAll(?User $user, ?Site $site = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?Site $site = null): bool diff --git a/app/Policies/V2/Sites/SiteReportPolicy.php b/app/Policies/V2/Sites/SiteReportPolicy.php index 17047eea0..74a2a2fdd 100644 --- a/app/Policies/V2/Sites/SiteReportPolicy.php +++ b/app/Policies/V2/Sites/SiteReportPolicy.php @@ -25,7 +25,7 @@ public function read(?User $user, ?SiteReport $report = null): bool public function readAll(?User $user, ?SiteReport $report = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?SiteReport $report = null): bool diff --git a/app/Policies/V2/Tasks/TaskPolicy.php b/app/Policies/V2/Tasks/TaskPolicy.php index 6029d8220..ccba44a67 100644 --- a/app/Policies/V2/Tasks/TaskPolicy.php +++ b/app/Policies/V2/Tasks/TaskPolicy.php @@ -24,7 +24,7 @@ public function read(?User $user, ?Task $task = null): bool public function readAll(?User $user, ?Task $task = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?Task $task = null): bool diff --git a/app/Policies/V2/UpdateRequests/UpdateRequestPolicy.php b/app/Policies/V2/UpdateRequests/UpdateRequestPolicy.php index 32eeb9608..227fa6c18 100644 --- a/app/Policies/V2/UpdateRequests/UpdateRequestPolicy.php +++ b/app/Policies/V2/UpdateRequests/UpdateRequestPolicy.php @@ -29,7 +29,7 @@ public function read(?User $user, ?UpdateRequest $updateRequest = null): bool public function readAll(?User $user, ?UpdateRequest $updateRequest = null): bool { - return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc']); + return $user->hasAnyPermission(['framework-terrafund', 'framework-ppc', 'framework-hbf']); } public function update(?User $user, ?UpdateRequest $updateRequest = null): bool diff --git a/config/wri/permissions.php b/config/wri/permissions.php index 840b63edb..3e3f29c99 100644 --- a/config/wri/permissions.php +++ b/config/wri/permissions.php @@ -4,6 +4,7 @@ 'framework-ppc' => 'Framework PPC', 'framework-terrafund' => 'Framework Terrafund', 'framework-terrafund-enterprises' => 'Framework Terrafund Enterprises', + 'framework-hbf' => 'Framework Harit Bharat Fund', 'custom-forms-manage' => 'Manage custom forms', 'users-manage' => 'Manage users', 'monitoring-manage' => 'Manage monitoring',