Merge pull request #4410 from turbo124/v5-develop

V5 develop
This commit is contained in:
David Bomba 2020-12-02 08:32:45 +11:00 committed by GitHub
commit 66fc75bb83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 12 deletions

View File

@ -26,7 +26,7 @@ BROADCAST_DRIVER=log
LOG_CHANNEL=stack LOG_CHANNEL=stack
CACHE_DRIVER=file CACHE_DRIVER=file
QUEUE_CONNECTION=database QUEUE_CONNECTION=database
SESSION_DRIVER=file SESSION_DRIVER=cookie
SESSION_LIFETIME=120 SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1 REDIS_HOST=127.0.0.1
@ -46,7 +46,6 @@ POSTMARK_API_TOKEN=
REQUIRE_HTTPS=false REQUIRE_HTTPS=false
GOOGLE_MAPS_API_KEY= GOOGLE_MAPS_API_KEY=
API_SECRET=superdoopersecrethere
ERROR_EMAIL= ERROR_EMAIL=
TRUSTED_PROXIES= TRUSTED_PROXIES=

View File

@ -1,7 +1,7 @@
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine On RewriteEngine On
RewriteRule "^.env" - [F,L] RewriteRule "^.env" - [F,L]
RewriteRule "^storage" - [F,L] # RewriteRule "^storage" - [F,L]
RewriteRule ^(.well-known)($|/) - [L] RewriteRule ^(.well-known)($|/) - [L]
RewriteRule ^(.*)$ public/$1 [L] RewriteRule ^(.*)$ public/$1 [L]

View File

@ -12,7 +12,15 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\Exceptions\MigrationValidatorFailed;
use App\Exceptions\NonExistingMigrationFile;
use App\Exceptions\ProcessingMigrationArchiveFailed;
use App\Exceptions\ResourceDependencyMissing;
use App\Exceptions\ResourceNotAvailableForMigration;
use App\Jobs\Util\Import;
use App\Jobs\Util\StartMigration; use App\Jobs\Util\StartMigration;
use App\Libraries\MultiDB;
use App\Mail\MigrationFailed;
use App\Models\Account; use App\Models\Account;
use App\Models\Company; use App\Models\Company;
use App\Models\CompanyToken; use App\Models\CompanyToken;
@ -24,6 +32,7 @@ use Faker\Factory;
use Faker\Generator; use Faker\Generator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use ZipArchive;
class ImportMigrations extends Command class ImportMigrations extends Command
{ {
@ -69,17 +78,45 @@ class ImportMigrations extends Command
public function handle() public function handle()
{ {
$this->buildCache(); $this->buildCache();
$path = $this->option('path') ?? storage_path('migrations/import'); $path = $this->option('path') ?? public_path('storage/migrations/import');
$directory = new DirectoryIterator($path); $directory = new DirectoryIterator($path);
foreach ($directory as $file) { foreach ($directory as $file) {
if ($file->getExtension() === 'zip') { if ($file->getExtension() === 'zip') {
$user = $this->getUser();
$company = $this->getUser()->companies()->first();
$this->info('Started processing: '.$file->getBasename().' at '.now()); $this->info('Started processing: '.$file->getBasename().' at '.now());
StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first());
} $zip = new ZipArchive();
} $archive = $zip->open($file->getRealPath());
try {
if (! $archive) {
throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.');
}
$filename = pathinfo($file->getRealPath(), PATHINFO_FILENAME);
$zip->extractTo(public_path("storage/migrations/{$filename}"));
$zip->close();
$import_file = public_path("storage/migrations/$filename/migration.json");
Import::dispatch($import_file, $this->getUser()->companies()->first(), $this->getUser());
// StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first());
}
catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) {
\Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage()));
if (app()->environment() !== 'production') {
info($e->getMessage());
}
}}}
} }
public function getUser(): User public function getUser(): User

View File

@ -55,7 +55,7 @@ class CompanySettings extends BaseSettings
public $default_task_rate = 0; // @TODO Where do we inject this? public $default_task_rate = 0; // @TODO Where do we inject this?
public $payment_terms = ''; //@implemented public $payment_terms = ''; //@implemented
public $send_reminders = false; //@TODO public $send_reminders = true; //@TODO
public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending
public $custom_message_unpaid_invoice = ''; public $custom_message_unpaid_invoice = '';

View File

@ -22,6 +22,6 @@ class ShowInvoiceRequest extends Request
*/ */
public function authorize() : bool public function authorize() : bool
{ {
return auth('contact')->user()->client->id === $this->invoice->client_id; return auth('contact')->user()->client->id == $this->invoice->client_id;
} }
} }

View File

@ -177,6 +177,9 @@ class Import implements ShouldQueue
{ {
set_time_limit(0); set_time_limit(0);
auth()->login($this->user, false);
auth()->user()->setCompany($this->company);
// $jsonStream = \JsonMachine\JsonMachine::fromFile($this->file_path, "/data"); // $jsonStream = \JsonMachine\JsonMachine::fromFile($this->file_path, "/data");
$array = json_decode(file_get_contents($this->file_path), 1); $array = json_decode(file_get_contents($this->file_path), 1);
$data = $array['data']; $data = $array['data'];

View File

@ -39,6 +39,7 @@ class ActivityTransformer extends EntityTransformer
'company_id' => $activity->company_id ? (string) $this->encodePrimaryKey($activity->company_id) : '', 'company_id' => $activity->company_id ? (string) $this->encodePrimaryKey($activity->company_id) : '',
'user_id' => (string) $this->encodePrimaryKey($activity->user_id), 'user_id' => (string) $this->encodePrimaryKey($activity->user_id),
'invoice_id' => $activity->invoice_id ? (string) $this->encodePrimaryKey($activity->invoice_id) : '', 'invoice_id' => $activity->invoice_id ? (string) $this->encodePrimaryKey($activity->invoice_id) : '',
'quote_id' => $activity->quote_id ? (string) $this->encodePrimaryKey($activity->quote_id) : '',
'payment_id' => $activity->payment_id ? (string) $this->encodePrimaryKey($activity->payment_id) : '', 'payment_id' => $activity->payment_id ? (string) $this->encodePrimaryKey($activity->payment_id) : '',
'credit_id' => $activity->credit_id ? (string) $this->encodePrimaryKey($activity->credit_id) : '', 'credit_id' => $activity->credit_id ? (string) $this->encodePrimaryKey($activity->credit_id) : '',
'updated_at' => (int) $activity->updated_at, 'updated_at' => (int) $activity->updated_at,

View File

@ -75,7 +75,6 @@ return [
], ],
], ],
], ],
's3' => [ 's3' => [
'driver' => 's3', 'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'), 'key' => env('AWS_ACCESS_KEY_ID'),

View File

@ -88,7 +88,7 @@
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
window.addEventListener('load', function () { window.addEventListener('load', function () {
navigator.serviceWorker.register('/flutter_service_worker.js?v={{ config('ninja.app_version') }}'); navigator.serviceWorker.register('flutter_service_worker.js?v={{ config('ninja.app_version') }}');
}); });
} }