diff --git a/app/Http/Controllers/V2/Dashboard/ViewProjectController.php b/app/Http/Controllers/V2/Dashboard/ViewProjectController.php index 8e2cee69b..e8beba8ee 100644 --- a/app/Http/Controllers/V2/Dashboard/ViewProjectController.php +++ b/app/Http/Controllers/V2/Dashboard/ViewProjectController.php @@ -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) diff --git a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php index 322de1448..262687b1c 100755 --- a/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php +++ b/app/Http/Controllers/V2/Terrafund/TerrafundCreateGeometryController.php @@ -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) { @@ -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) { @@ -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),