-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #591 from wri/release/tacky-teak
[RELEASE] Tacky Teak
- Loading branch information
Showing
69 changed files
with
4,860 additions
and
246 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
app/Console/Commands/ExportApprovedDashboardDataCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Helpers\TerrafundDashboardQueryHelper; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Http\Request; | ||
|
||
class ExportApprovedDashboardDataCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:export-approved-dashboard-data-command'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'return CSV for approved projects'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$request = new Request(['filter' => []]); | ||
$projects = TerrafundDashboardQueryHelper::buildQueryFromRequest($request) | ||
->with(['organisation:id,type,name']) | ||
->select([ | ||
'v2_projects.uuid', | ||
'v2_projects.id', | ||
]) | ||
->get(); | ||
$csvFile = fopen('projects_report.csv', 'w'); | ||
fputcsv($csvFile, ['Project UUID', 'Trees Planted to Date', 'Hectares Under Restoration', 'Jobs Created']); | ||
|
||
foreach ($projects as $project) { | ||
fputcsv($csvFile, [ | ||
$project->uuid, | ||
$project->approved_trees_planted_count, | ||
$project->total_hectares_restored_sum, | ||
$project->total_approved_jobs_created, | ||
]); | ||
} | ||
fclose($csvFile); | ||
|
||
echo "CSV file 'projects_report.csv' created successfully."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands\OneOff; | ||
|
||
use App\Models\V2\Organisation; | ||
use App\Models\V2\Projects\Project; | ||
use Illuminate\Console\Command; | ||
|
||
class BackfillTestProjectsOrgs extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'one-off:backfill-test-projects-orgs'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Sets the is_test flag on test projects and organisations'; | ||
|
||
// In addition to these orgs, all projects within these orgs will get marked with is_test = true | ||
private const TEST_ORGS = [ | ||
'7150d4ef-c785-49ed-9fb6-a28ef48ffb98', // 3SC PRODUCTION ORG (GT) - PLEASE IGNORE | ||
'15c2a8dc-d395-11ed-8014-0682e69bfbec', // TM Org | ||
'2470ced8-dc03-4d1e-9c64-b6445ac2c558', // test 0709 | ||
'f936d363-8409-401e-8711-708909cfa205', // Edward's Testing Playground | ||
'15c07e71-d395-11ed-8014-0682e69bfbec', // Claire Trees Org | ||
]; | ||
|
||
// These test projects are in an org that is not itself a test org | ||
private const TEST_PROJECTS = [ | ||
'be1d70ad-9f0e-486f-a85a-86c075d6a4d1', // Conservation International test project | ||
]; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
foreach (Organisation::whereIn('uuid', self::TEST_ORGS)->get() as $organisation) { | ||
$organisation->update(['is_test' => true]); | ||
|
||
foreach ($organisation->projects as $project) { | ||
$project->update(['is_test' => true]); | ||
} | ||
} | ||
|
||
foreach (Project::whereIn('uuid', self::TEST_PROJECTS)->get() as $project) { | ||
$project->update(['is_test' => true]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/Http/Controllers/V2/Projects/AdminUpdateProjectController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\V2\Projects; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\V2\Projects\AdminUpdateProjectRequest; | ||
use App\Http\Resources\V2\Projects\ProjectResource; | ||
use App\Models\V2\Projects\Project; | ||
|
||
class AdminUpdateProjectController extends Controller | ||
{ | ||
public function __invoke(Project $project, AdminUpdateProjectRequest $request): ProjectResource | ||
{ | ||
$this->authorize('update', $project); | ||
|
||
$project->update($request->validated()); | ||
|
||
return new ProjectResource($project); | ||
} | ||
} |
Oops, something went wrong.