Skip to content

Commit

Permalink
Merge pull request #339 from wri/fix/TM-1093-restoration-in-progress
Browse files Browse the repository at this point in the history
[TM-1093] Sites in restoration-in-progress need to count as approved.
  • Loading branch information
roguenet authored Jul 9, 2024
2 parents aa58170 + d5b1622 commit 89e852e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/Models/V2/Projects/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use App\Models\V2\TreeSpecies\TreeSpecies;
use App\Models\V2\Workdays\Workday;
use App\Models\V2\Workdays\WorkdayDemographic;
use App\StateMachines\EntityStatusStateMachine;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -498,7 +497,7 @@ private function submittedSiteReports(): HasManyThrough
// a status field.
return $this
->siteReports()
->where('v2_sites.status', EntityStatusStateMachine::APPROVED)
->whereIn('v2_sites.status', Site::$approvedStatuses)
->whereNotIn('v2_site_reports.status', SiteReport::UNSUBMITTED_STATUSES);
}

Expand Down
7 changes: 6 additions & 1 deletion app/Models/V2/Sites/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class Site extends Model implements MediaModel, AuditableContract, EntityModel,
submitForApproval as entityStatusSubmitForApproval;
}

public static array $approvedStatuses = [
EntityStatusStateMachine::APPROVED,
SiteStatusStateMachine::RESTORATION_IN_PROGRESS,
];

public static array $statuses = [
EntityStatusStateMachine::STARTED => 'Started',
EntityStatusStateMachine::AWAITING_APPROVAL => 'Awaiting approval',
Expand Down Expand Up @@ -200,7 +205,7 @@ public function toSearchableArray()
*/
public function scopeIsApproved(Builder $query): Builder
{
return $query->whereIn('status', [EntityStatusStateMachine::APPROVED, SiteStatusStateMachine::RESTORATION_IN_PROGRESS]);
return $query->whereIn('status', self::$approvedStatuses);
}

/** RELATIONS */
Expand Down

0 comments on commit 89e852e

Please sign in to comment.