Skip to content

Commit

Permalink
[TM-1489] rollback dashboard funder and government permissions (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarLima1 authored Nov 19, 2024
1 parent 3b75b5a commit b94b5b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 9 additions & 2 deletions app/Http/Controllers/V2/Dashboard/ViewProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ public function getIfUserIsAllowedToProject(String $uuid)
$response = (object)[
'allowed' => false,
];
} elseif ($user->hasRole('government') || $user->hasRole('funder')) {
} elseif ($user->hasRole('government')) {
$response = (object)[
'allowed' => true,
'allowed' => false,
];
} elseif ($user->hasRole('funder')) {
$isAllowed = Project::where('uuid', $uuid)
->where('framework_key', $user->program)
->exists();
$response = (object)[
'allowed' => $isAllowed,
];
} elseif ($user->hasRole('project-developer')) {
$projectId = Project::where('uuid', $uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,12 +1050,18 @@ public function downloadAllActivePolygonsByFramework(Request $request)
{
ini_set('max_execution_time', '-1');
ini_set('memory_limit', '-1');
ini_set('post_max_size', '300M');
ini_set('upload_max_filesize', '300M');
if (! ini_set('max_execution_time', 60)) {
Log::info('Failed to set max_execution_time');
}

$framework = $request->query('framework');

try {
$sitesFromFramework = Site::where('framework_key', $framework)->pluck('uuid');

$activePolygonIds = SitePolygon::wherein('site_id', $sitesFromFramework)->active()->pluck('poly_id');
$activePolygonIds = SitePolygon::wherein('site_id', $sitesFromFramework)->where('status', 'approved')->active()->pluck('poly_id');
Log::info('count of active polygons: ', ['count' => count($activePolygonIds)]);
$features = [];
foreach ($activePolygonIds as $polygonUuid) {
Expand Down Expand Up @@ -1095,7 +1101,7 @@ public function downloadGeojsonAllActivePolygons()
ini_set('memory_limit', '-1');

try {
$activePolygonIds = SitePolygon::active()->pluck('poly_id');
$activePolygonIds = SitePolygon::active()->where('status', 'approved')->pluck('poly_id');

$features = [];
foreach ($activePolygonIds as $polygonUuid) {
Expand All @@ -1110,7 +1116,7 @@ public function downloadGeojsonAllActivePolygons()
continue;
}
$sitePolygon = SitePolygon::where('poly_id', $polygonUuid)->first();
$properties = $sitePolygon ? $sitePolygon->only(['poly_name', 'plantstart', 'plantend', 'practice', 'target_sys', 'distr', 'num_trees', 'site_id', 'uuid']) : [];
$properties = $sitePolygon ? $sitePolygon->only(['poly_name', 'plantstart', 'plantend', 'practice', 'target_sys', 'distr', 'num_trees', 'site_id', 'uuid', 'id']) : [];
$feature = [
'type' => 'Feature',
'geometry' => json_decode($polygonGeometry->geojsonGeom),
Expand Down

0 comments on commit b94b5b9

Please sign in to comment.