Skip to content

Commit

Permalink
Merge pull request #340 from wri/release/hotfix-jj-2024-07-09
Browse files Browse the repository at this point in the history
[RELEASE] Hotfix JJ 2024 07 09
  • Loading branch information
roguenet authored Jul 10, 2024
2 parents df1dc23 + 89e852e commit 6dd7f4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 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
13 changes: 13 additions & 0 deletions 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 @@ -195,6 +200,14 @@ public function toSearchableArray()
];
}

/**
* Overrides the method from HasEntityStatusScopesAndTransitions
*/
public function scopeIsApproved(Builder $query): Builder
{
return $query->whereIn('status', self::$approvedStatuses);
}

/** RELATIONS */
public function framework(): BelongsTo
{
Expand Down

0 comments on commit 6dd7f4c

Please sign in to comment.