Remove remove_bid_after_accept setting (#1100)
* Remove "Remove bid on accept" setting and remove bids after PIREP was filed fixes #1039 * Add migration to remove setting from database * fix migration naming and remove obsolete code Co-authored-by: Andreas Palm <ap@ewsp.de>
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class RemoveSettingRemoveBidOnAccept extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
DB::table('settings')
|
||||||
|
->where(['key' => 'pireps.remove_bid_on_accept'])
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -263,13 +263,6 @@
|
|||||||
options: ''
|
options: ''
|
||||||
type: boolean
|
type: boolean
|
||||||
description: 'Only allow aircraft that are at the departure airport'
|
description: 'Only allow aircraft that are at the departure airport'
|
||||||
- key: pireps.remove_bid_on_accept
|
|
||||||
name: 'Remove bid on accept'
|
|
||||||
group: pireps
|
|
||||||
value: false
|
|
||||||
options: ''
|
|
||||||
type: boolean
|
|
||||||
description: 'When a PIREP is accepted, remove the bid, if it exists'
|
|
||||||
- key: pireps.advanced_fuel
|
- key: pireps.advanced_fuel
|
||||||
name: 'Advanced Fuel Calculations'
|
name: 'Advanced Fuel Calculations'
|
||||||
group: pireps
|
group: pireps
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Contracts\Listener;
|
use App\Contracts\Listener;
|
||||||
use App\Events\PirepAccepted;
|
use App\Events\PirepFiled;
|
||||||
use App\Events\PirepRejected;
|
|
||||||
use App\Services\BidService;
|
use App\Services\BidService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,8 +12,7 @@ use App\Services\BidService;
|
|||||||
class BidEventHandler extends Listener
|
class BidEventHandler extends Listener
|
||||||
{
|
{
|
||||||
public static $callbacks = [
|
public static $callbacks = [
|
||||||
PirepAccepted::class => 'onPirepAccept',
|
PirepFiled::class => 'onPirepFiled',
|
||||||
PirepRejected::class => 'onPirepReject',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
private $bidSvc;
|
private $bidSvc;
|
||||||
@@ -25,29 +23,15 @@ class BidEventHandler extends Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a PIREP is accepted, remove any bids
|
* When a PIREP is filed, remove any bids
|
||||||
*
|
*
|
||||||
* @param PirepAccepted $event
|
* @param PirepFiled $event
|
||||||
*
|
*
|
||||||
* @throws \UnexpectedValueException
|
* @throws \UnexpectedValueException
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function onPirepAccept(PirepAccepted $event): void
|
public function onPirepFiled(PirepFiled $event): void
|
||||||
{
|
|
||||||
$this->bidSvc->removeBidForPirep($event->pirep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When a PIREP is accepted, remove any bids
|
|
||||||
*
|
|
||||||
* @param PirepRejected $event
|
|
||||||
*
|
|
||||||
* @throws \UnexpectedValueException
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function onPirepReject(PirepRejected $event): void
|
|
||||||
{
|
{
|
||||||
$this->bidSvc->removeBidForPirep($event->pirep);
|
$this->bidSvc->removeBidForPirep($event->pirep);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,10 +169,6 @@ class BidService extends Service
|
|||||||
*/
|
*/
|
||||||
public function removeBidForPirep(Pirep $pirep)
|
public function removeBidForPirep(Pirep $pirep)
|
||||||
{
|
{
|
||||||
if (!setting('pireps.remove_bid_on_accept')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$flight = $pirep->flight;
|
$flight = $pirep->flight;
|
||||||
if (!$flight) {
|
if (!$flight) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -528,7 +528,6 @@ class PIREPTest extends TestCase
|
|||||||
{
|
{
|
||||||
$bidSvc = app(BidService::class);
|
$bidSvc = app(BidService::class);
|
||||||
$flightSvc = app(FlightService::class);
|
$flightSvc = app(FlightService::class);
|
||||||
$this->settingsRepo->store('pireps.remove_bid_on_accept', true);
|
|
||||||
|
|
||||||
$user = factory(User::class)->create([
|
$user = factory(User::class)->create([
|
||||||
'flight_time' => 0,
|
'flight_time' => 0,
|
||||||
@@ -549,7 +548,7 @@ class PIREPTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$pirep = $this->pirepSvc->create($pirep, []);
|
$pirep = $this->pirepSvc->create($pirep, []);
|
||||||
$this->pirepSvc->changeState($pirep, PirepState::ACCEPTED);
|
$this->pirepSvc->submit($pirep);
|
||||||
|
|
||||||
$user_bid = Bid::where([
|
$user_bid = Bid::where([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
|
|||||||
Reference in New Issue
Block a user