Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-812] Remove project establishment and seed collection from workday collections #144

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/Console/Commands/Migration/RolesMigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public function handle()

User::whereIn('role', ['user','admin', 'terrafund-admin'])->get()
->each(function (User $user) {
assignSpatieRole($user);
if ($user->primary_role == null) {
assignSpatieRole($user);
}
});

if ($this->option('log')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public function __invoke(Request $request, string $entity, string $framework)
private function getSlug(string $framework)
{
$frameworkModel = Framework::where('access_code', $framework)->firstOrFail();

return $frameworkModel->slug;
}

private function getForm(string $modelClass, string $framework)
{
return Form::where('model', $modelClass)
Expand Down
20 changes: 0 additions & 20 deletions app/Models/V2/Projects/ProjectReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,6 @@ public function treeSpecies()
return $this->morphMany(TreeSpecies::class, 'speciesable');
}

public function workdaysPaidProjectEstablishment()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_PAID_PROJECT_ESTABLISHMENT);
}

public function workdaysPaidNurseryOperations()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_PAID_NURSERY_OPRERATIONS);
Expand All @@ -254,21 +249,11 @@ public function workdaysPaidProjectManagement()
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_PAID_PROJECT_MANAGEMENT);
}

public function workdaysPaidSeedCollection()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_PAID_SEED_COLLECTION);
}

public function workdaysPaidOtherActivities()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_PAID_OTHER);
}

public function workdaysVolunteerProjectEstablishment()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_VOLUNTEER_PROJECT_ESTABLISHMENT);
}

public function workdaysVolunteerNurseryOperations()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_VOLUNTEER_NURSERY_OPRERATIONS);
Expand All @@ -279,11 +264,6 @@ public function workdaysVolunteerProjectManagement()
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_VOLUNTEER_PROJECT_MANAGEMENT);
}

public function workdaysVolunteerSeedCollection()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_VOLUNTEER_SEED_COLLECTION);
}

public function workdaysVolunteerOtherActivities()
{
return $this->morphMany(Workday::class, 'workdayable')->where('collection', Workday::COLLECTION_PROJECT_VOLUNTEER_OTHER);
Expand Down
8 changes: 0 additions & 8 deletions app/Models/V2/Workdays/Workday.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,19 @@ class Workday extends Model
'indigeneity',
];

public const COLLECTION_PROJECT_PAID_PROJECT_ESTABLISHMENT = 'paid-project-establishment';
public const COLLECTION_PROJECT_PAID_NURSERY_OPRERATIONS = 'paid-nursery-operations';
public const COLLECTION_PROJECT_PAID_PROJECT_MANAGEMENT = 'paid-project-management';
public const COLLECTION_PROJECT_PAID_SEED_COLLECTION = 'paid-seed-collection';
public const COLLECTION_PROJECT_PAID_OTHER = 'paid-other-activities';
public const COLLECTION_PROJECT_VOLUNTEER_PROJECT_ESTABLISHMENT = 'volunteer-project-establishment';
public const COLLECTION_PROJECT_VOLUNTEER_NURSERY_OPRERATIONS = 'volunteer-nursery-operations';
public const COLLECTION_PROJECT_VOLUNTEER_PROJECT_MANAGEMENT = 'volunteer-project-management';
public const COLLECTION_PROJECT_VOLUNTEER_SEED_COLLECTION = 'volunteer-seed-collection';
public const COLLECTION_PROJECT_VOLUNTEER_OTHER = 'volunteer-other-activities';

public static $projectCollections = [
self::COLLECTION_PROJECT_PAID_PROJECT_ESTABLISHMENT => 'Paid Project Establishment',
self::COLLECTION_PROJECT_PAID_NURSERY_OPRERATIONS => 'Paid Nursery Operations',
self::COLLECTION_PROJECT_PAID_PROJECT_MANAGEMENT => 'Paid Project Management',
self::COLLECTION_PROJECT_PAID_SEED_COLLECTION => 'Paid Seed Collection',
self::COLLECTION_PROJECT_PAID_OTHER => 'Paid Other Activities',
self::COLLECTION_PROJECT_VOLUNTEER_PROJECT_ESTABLISHMENT => 'Volunteer Project Establishment',
self::COLLECTION_PROJECT_VOLUNTEER_NURSERY_OPRERATIONS => 'Volunteer Nursery Operations',
self::COLLECTION_PROJECT_VOLUNTEER_PROJECT_MANAGEMENT => 'Volunteer Project Management',
self::COLLECTION_PROJECT_VOLUNTEER_SEED_COLLECTION => 'Volunteer Seed Collection',
self::COLLECTION_PROJECT_VOLUNTEER_OTHER => 'Volunteer Other Activities',
];

Expand Down
32 changes: 0 additions & 32 deletions config/wri/linked-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,6 @@
'input_type' => 'treeSpecies',
'collection' => 'tree-planted',
],
// 'pro-rep-rel-paid-project-establishment' => [
// 'property' => 'workdaysPaidProjectEstablishment',
// 'label' => 'Paid Project Establishment',
// 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource',
// 'input_type' => 'workdays',
// 'collection' => 'paid-project-establishment',
// 'option_list_key' => 'workdays-ethnicity',
// ],
'pro-rep-rel-paid-nursery-operations' => [
'property' => 'workdaysPaidNurseryOperations',
'label' => 'Paid Nursery Operations',
Expand All @@ -448,14 +440,6 @@
'collection' => 'paid-project-management',
'option_list_key' => 'workdays-ethnicity',
],
// 'pro-rep-rel-paid-seed-collection' => [
// 'property' => 'workdaysPaidSeedCollection',
// 'label' => 'Paid Seed Collection',
// 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource',
// 'input_type' => 'workdays',
// 'collection' => 'paid-seed-collection',
// 'option_list_key' => 'workdays-ethnicity',
// ],
'pro-rep-rel-paid-other-activities' => [
'property' => 'workdaysPaidOtherActivities',
'label' => 'Paid Other Activities',
Expand All @@ -464,14 +448,6 @@
'collection' => 'paid-other-activities',
'option_list_key' => 'workdays-ethnicity',
],
// 'pro-rep-rel-volunteer-project-establishment' => [
// 'property' => 'workdaysVolunteerProjectEstablishment',
// 'label' => 'Volunteer Project Establishment',
// 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource',
// 'input_type' => 'workdays',
// 'collection' => 'volunteer-project-establishment',
// 'option_list_key' => 'workdays-ethnicity',
// ],
'pro-rep-rel-volunteer-nursery-operations' => [
'property' => 'workdaysVolunteerNurseryOperations',
'label' => 'Volunteer Nursery Operations',
Expand All @@ -488,14 +464,6 @@
'collection' => 'volunteer-project-management',
'option_list_key' => 'workdays-ethnicity',
],
// 'pro-rep-rel-volunteer-seed-collection' => [
// 'property' => 'workdaysVolunteerSeedCollection',
// 'label' => 'Volunteer Seed Collection',
// 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource',
// 'input_type' => 'workdays',
// 'collection' => 'volunteer-seed-collection',
// 'option_list_key' => 'workdays-ethnicity',
// ],
'pro-rep-rel-volunteer-other-activities' => [
'property' => 'workdaysVolunteerOtherActivities',
'label' => 'Volunteer Other Activities',
Expand Down
3 changes: 3 additions & 0 deletions tests/V2/Exports/ExportAllMonitoredEntitiesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Helpers\CustomFormHelper;
use App\Jobs\V2\GenerateAdminAllEntityRecordsExportJob;
use App\Models\Framework;
use App\Models\User;
use App\Models\V2\Nurseries\Nursery;
use App\Models\V2\Nurseries\NurseryReport;
Expand Down Expand Up @@ -31,6 +32,8 @@ public function test_an_admin_user_can_export_all_monitored_entities(string $per
$user = User::factory()->admin()->create();
$user->givePermissionTo($permission);

Framework::factory()->create(['slug' => $fmKey, 'access_code' => $fmKey]);

$testCases = [
'projects' => Project::factory()->count(5)->create(['framework_key' => $fmKey]),
'sites' => Site::factory()->count(5)->create(['framework_key' => $fmKey]),
Expand Down
Loading