Skip to content

Commit

Permalink
Merge pull request #197 from wri/feat/TM-904-hbf-admin
Browse files Browse the repository at this point in the history
[TM-904] Add HBF as a framework permission and admin type.
  • Loading branch information
roguenet authored May 15, 2024
2 parents 6e45220 + 991afeb commit cd6b3ec
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 11 deletions.
7 changes: 6 additions & 1 deletion app/Console/Commands/Migration/RolesMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/FrameworkPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
2 changes: 1 addition & 1 deletion app/Policies/V2/FundingProgrammePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
2 changes: 1 addition & 1 deletion app/Policies/V2/Nurseries/NurseryPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/Nurseries/NurseryReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/Projects/ProjectPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/Projects/ProjectReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/Sites/SitePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/Sites/SiteReportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/Tasks/TaskPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/V2/UpdateRequests/UpdateRequestPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/wri/permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit cd6b3ec

Please sign in to comment.