-
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 #572 from wri/feat/TM-1469-test-proj-org
[TM-1469] Introduce an is_test flag to orgs and projects
- Loading branch information
Showing
22 changed files
with
2,878 additions
and
2 deletions.
There are no files selected for viewing
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]); | ||
} | ||
} | ||
} |
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); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
app/Http/Requests/V2/Projects/AdminUpdateProjectRequest.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,15 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\V2\Projects; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class AdminUpdateProjectRequest extends FormRequest | ||
{ | ||
public function rules() | ||
{ | ||
return [ | ||
'is_test' => 'sometimes|boolean', | ||
]; | ||
} | ||
} |
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
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
33 changes: 33 additions & 0 deletions
33
database/migrations/2024_11_14_173836_add_is_test_proj_org.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,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('organisations', function (Blueprint $table) { | ||
$table->boolean('is_test')->default(false); | ||
}); | ||
Schema::table('v2_projects', function (Blueprint $table) { | ||
$table->boolean('is_test')->default(false); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('organisations', function (Blueprint $table) { | ||
$table->dropColumn('is_test'); | ||
}); | ||
Schema::table('v2_projects', function (Blueprint $table) { | ||
$table->dropColumn('is_test'); | ||
}); | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ properties: | |
type: string | ||
uuid: | ||
type: string | ||
is_test: | ||
type: boolean | ||
status: | ||
type: string | ||
organisation: | ||
|
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ properties: | |
type: string | ||
uuid: | ||
type: string | ||
is_test: | ||
type: boolean | ||
status: | ||
type: string | ||
name: | ||
|
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 |
---|---|---|
|
@@ -9,6 +9,8 @@ properties: | |
type: string | ||
type: | ||
type: string | ||
is_test: | ||
type: boolean | ||
private: | ||
type: boolean | ||
name: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
title: V2AdminProjectUpdate | ||
type: object | ||
properties: | ||
is_test: | ||
type: boolean |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
summary: Updates a specific project | ||
operationId: put-v2-admin-project | ||
tags: | ||
- V2 Projects | ||
parameters: | ||
- in: body | ||
name: body | ||
schema: | ||
$ref: '../../definitions/_index.yml#/V2AdminProjectUpdate' | ||
- type: string | ||
in: path | ||
name: UUID | ||
required: true | ||
responses: | ||
'200': | ||
description: OK | ||
schema: | ||
type: array | ||
items: | ||
$ref: '../../definitions/_index.yml#/ProjectFullRead' |
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
Oops, something went wrong.