Don't allow cancels from certain states (#396)

* Don't allow cancels from certain states

* Unused imports

* Don't reset the state doubly

* Move SetUserActive into listener; code cleanup

* Unused imports

* Add missing files into htaccess

* Move Command contract to correct folder
This commit is contained in:
Nabeel S
2019-09-16 13:08:26 -04:00
committed by GitHub
parent 41baefbf4a
commit aedb1f22b6
61 changed files with 231 additions and 138 deletions

View File

@@ -10,14 +10,17 @@ use App\Models\Traits\FilesTrait;
/**
* @property int id
* @property mixed subfleet_id
* @property string airport_id The apt where the aircraft is
* @property string name
* @property string icao
* @property string registration
* @property int flight_time
* @property string hex_code
* @property Airport airport
* @property Subfleet subfleet
* @property int status
* @property int state
* @property Carbon landing_time
*/
class Aircraft extends Model
{

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class AcarsType
*/
class AcarsType extends Enum
{
public const FLIGHT_PATH = 0;

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class ActiveState
*/
class ActiveState extends Enum
{
public const INACTIVE = 0;

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class AircraftState
*/
class AircraftState extends Enum
{
public const PARKED = 0;

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class AircraftState
*/
class AircraftStatus extends Enum
{
public const ACTIVE = 'A';

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class AnalyticsDimensions
*/
class AnalyticsDimensions extends Enum
{
public const PHP_VERSION = 1;

View File

@@ -5,7 +5,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class AnalyticsMetrics
* Metrics IDs used in Google Analytics
*/
class AnalyticsMetrics extends Enum

View File

@@ -5,7 +5,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class Days
* Start on Monday - ISO8601
*/
class Days extends Enum

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class ExpenseType
*/
class ExpenseType extends Enum
{
public const FLIGHT = 'F';

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class FlightType
*/
class FlightType extends Enum
{
public const SCHED_PAX = 'J';

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class FuelType
*/
class FuelType extends Enum
{
public const LOW_LEAD = 0;

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class JournalType
*/
class JournalType extends Enum
{
public const AIRLINE = 0;

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class AcarsType
*/
class PirepFieldSource extends Enum
{
public const MANUAL = 0;

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class PirepSource
*/
class PirepSource extends Enum
{
public const MANUAL = 0;

View File

@@ -9,21 +9,21 @@ use App\Contracts\Enum;
*/
class PirepState extends Enum
{
public const REJECTED = -1;
public const IN_PROGRESS = 0; // flight is ongoing
public const PENDING = 1; // waiting admin approval
public const ACCEPTED = 2;
public const CANCELLED = 3;
public const DELETED = 4;
public const DRAFT = 5;
public const REJECTED = 6;
protected static $labels = [
self::REJECTED => 'pireps.state.rejected',
self::IN_PROGRESS => 'pireps.state.in_progress',
self::PENDING => 'pireps.state.pending',
self::ACCEPTED => 'pireps.state.accepted',
self::CANCELLED => 'pireps.state.cancelled',
self::DELETED => 'pireps.state.deleted',
self::DRAFT => 'pireps.state.draft',
self::REJECTED => 'pireps.state.rejected',
];
}

View File

@@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class UserState
*/
class UserState extends Enum
{
public const PENDING = 0;

View File

@@ -42,6 +42,7 @@ use Illuminate\Support\Collection;
* @property Collection fields
* @property int status
* @property bool state
* @property string source
* @property Carbon submitted_at
* @property Carbon created_at
* @property Carbon updated_at
@@ -130,7 +131,7 @@ class Pirep extends Model
'route' => 'nullable',
];
/**
/*
* If a PIREP is in these states, then it can't be changed.
*/
public static $read_only_states = [
@@ -139,6 +140,16 @@ class Pirep extends Model
PirepState::CANCELLED,
];
/*
* If a PIREP is in one of these states, it can't be cancelled
*/
public static $cancel_states = [
PirepState::ACCEPTED,
PirepState::REJECTED,
PirepState::CANCELLED,
PirepState::DELETED,
];
/**
* Get the flight ident, e.,g JBU1900
*

View File

@@ -11,6 +11,8 @@ use App\Models\Enums\PirepFieldSource;
* @property string slug
* @property string value
* @property string source
*
* @method static updateOrCreate(array $array, array $array1)
*/
class PirepFieldValue extends Model
{

View File

@@ -10,6 +10,8 @@ use App\Contracts\Model;
* @property float manual_base_pay_rate
* @property float acars_base_pay_rate
* @property bool auto_promote
* @property bool auto_approve_acars
* @property bool auto_approve_manual
*/
class Rank extends Model
{

View File

@@ -32,6 +32,7 @@ use Laratrust\Traits\LaratrustUserTrait;
* @property int rank_id
* @property int state
* @property bool opt_in
* @property string last_pirep_id
* @mixin \Illuminate\Notifications\Notifiable
* @mixin \Laratrust\Traits\LaratrustUserTrait
*/