forked from miguel456/rbrecruiter
Apply fixes from StyleCI
This commit is contained in:
@@ -1,5 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright © 2020 Miguel Nogueira
|
||||
*
|
||||
* This file is part of Raspberry Staff Manager.
|
||||
*
|
||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Application;
|
||||
@@ -43,28 +62,23 @@ class CountVotes extends Command
|
||||
$eligibleApps = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get();
|
||||
$pbar = $this->output->createProgressBar($eligibleApps->count());
|
||||
|
||||
if($eligibleApps->isEmpty())
|
||||
{
|
||||
if ($eligibleApps->isEmpty()) {
|
||||
$this->error('𐄂 There are no applications that need to be processed.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($eligibleApps as $application)
|
||||
{
|
||||
foreach ($eligibleApps as $application) {
|
||||
$votes = $application->votes;
|
||||
$voteCount = $application->votes->count();
|
||||
|
||||
$positiveVotes = 0;
|
||||
$negativeVotes = 0;
|
||||
|
||||
if ($voteCount > 5)
|
||||
{
|
||||
$this->info('Counting votes for application ID ' . $application->id);
|
||||
foreach ($votes as $vote)
|
||||
{
|
||||
switch ($vote->allowedVoteType)
|
||||
{
|
||||
if ($voteCount > 5) {
|
||||
$this->info('Counting votes for application ID '.$application->id);
|
||||
foreach ($votes as $vote) {
|
||||
switch ($vote->allowedVoteType) {
|
||||
case 'VOTE_APPROVE':
|
||||
$positiveVotes++;
|
||||
break;
|
||||
@@ -74,7 +88,7 @@ class CountVotes extends Command
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Total votes for application ID ' . $application->id . ': ' . $voteCount);
|
||||
$this->info('Total votes for application ID '.$application->id.': '.$voteCount);
|
||||
$this->info('Calculating criteria...');
|
||||
$negativeVotePercent = floor(($negativeVotes / $voteCount) * 100);
|
||||
$positiveVotePercent = floor(($positiveVotes / $voteCount) * 100);
|
||||
@@ -83,54 +97,43 @@ class CountVotes extends Command
|
||||
|
||||
$this->table([
|
||||
'% of approval votes',
|
||||
'% of denial votes'
|
||||
'% of denial votes',
|
||||
], [ // array of arrays, e.g. rows
|
||||
[
|
||||
$positiveVotePercent . "%",
|
||||
$negativeVotePercent . "%"
|
||||
]
|
||||
$positiveVotePercent.'%',
|
||||
$negativeVotePercent.'%',
|
||||
],
|
||||
]);
|
||||
|
||||
if ($pollResult)
|
||||
{
|
||||
$this->info('✓ Dispatched promotion event for applicant ' . $application->user->name);
|
||||
if (!$this->option('dryrun'))
|
||||
{
|
||||
if ($pollResult) {
|
||||
$this->info('✓ Dispatched promotion event for applicant '.$application->user->name);
|
||||
if (! $this->option('dryrun')) {
|
||||
$application->response->vacancy->vacancyCount -= 1;
|
||||
$application->response->vacancy->save();
|
||||
|
||||
event(new ApplicationApprovedEvent(Application::find($application->id)));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->warn('Dry run: Event won\'t be dispatched');
|
||||
}
|
||||
|
||||
$pbar->advance();
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
if (!$this->option('dryrun'))
|
||||
{
|
||||
} else {
|
||||
if (! $this->option('dryrun')) {
|
||||
event(new ApplicationDeniedEvent(Application::find($application->id)));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->warn('Dry run: Event won\'t be dispatched');
|
||||
}
|
||||
|
||||
$pbar->advance();
|
||||
$this->error('𐄂 Applicant ' . $application->user->name . ' does not meet vote criteria (Majority)');
|
||||
$this->error('𐄂 Applicant '.$application->user->name.' does not meet vote criteria (Majority)');
|
||||
}
|
||||
} else {
|
||||
$this->warn('Application ID'.$application->id.' did not have enough votes for processing (min 5)');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->warn("Application ID" . $application->id . " did not have enough votes for processing (min 5)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$pbar->finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright © 2020 Miguel Nogueira
|
||||
*
|
||||
* This file is part of Raspberry Staff Manager.
|
||||
*
|
||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
@@ -39,103 +58,89 @@ class Install extends Command
|
||||
public function handle()
|
||||
{
|
||||
$basePath = base_path();
|
||||
if (Storage::disk('local')->missing('INSTALLED'))
|
||||
{
|
||||
if (Storage::disk('local')->missing('INSTALLED')) {
|
||||
$this->info('[!! Welcome to Rasberry Teams !!]');
|
||||
$this->info('>> Installing...');
|
||||
$this->call('down', [
|
||||
'--message' => 'Down for maintenance. We\'ll be right back!',
|
||||
]);
|
||||
|
||||
copy($basePath.'/.env.example', $basePath.'/.env');
|
||||
$this->call('key:generate');
|
||||
|
||||
$this->info('[!! Welcome to Rasberry Teams !!]');
|
||||
$this->info('>> Installing...');
|
||||
$this->call('down', [
|
||||
'--message' => 'Down for maintenance. We\'ll be right back!'
|
||||
]);
|
||||
$this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.');
|
||||
|
||||
copy($basePath . '/.env.example', $basePath . '/.env');
|
||||
$this->call('key:generate');
|
||||
$npmOut = 0;
|
||||
$npmMessages = [];
|
||||
|
||||
$this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.');
|
||||
$npmBuildOut = 0;
|
||||
$npmBuildMessages = [];
|
||||
|
||||
$npmOut = 0;
|
||||
$npmMessages = [];
|
||||
exec('cd '.$basePath.' && npm install --silent', $npmBuildOut, $npmOut);
|
||||
exec('cd '.$basePath.'&& npm run dev --silent', $npmBuildMessages, $npmBuildOut);
|
||||
|
||||
$npmBuildOut = 0;
|
||||
$npmBuildMessages = [];
|
||||
if ($npmOut !== 0 && $npmBuildOut !== 0) {
|
||||
$this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.');
|
||||
$this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.');
|
||||
|
||||
exec('cd ' . $basePath . ' && npm install --silent', $npmBuildOut, $npmOut);
|
||||
exec('cd ' . $basePath . '&& npm run dev --silent', $npmBuildMessages, $npmBuildOut);
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = [];
|
||||
|
||||
if($npmOut !== 0 && $npmBuildOut !== 0)
|
||||
{
|
||||
$this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.');
|
||||
$this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.');
|
||||
$this->info('>> Configuring application - We\'re going to ask a few questions here!');
|
||||
do {
|
||||
$this->info('== Database Settings (1/6) ==');
|
||||
|
||||
return false;
|
||||
}
|
||||
$settings['DB_USERNAME'] = $this->ask('Database username');
|
||||
$settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)');
|
||||
$settings['DB_DATABASE'] = $this->ask('Database name');
|
||||
$settings['DB_PORT'] = $this->ask('Database port');
|
||||
$settings['DB_HOST'] = $this->ask('Database hostname');
|
||||
|
||||
$this->info('== Antispam Settings (2/6) (Recaptcha v2) ==');
|
||||
$settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key');
|
||||
$settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key');
|
||||
|
||||
$this->info('== IP Geolocation Settings (3/6) (refer to README.md) ==');
|
||||
$settings['IPGEO_API_KEY'] = $this->ask('API Key');
|
||||
|
||||
$settings = [];
|
||||
$this->info('== Notification Settings (4/6) (Email) ==');
|
||||
$settings['MAIL_USERNAME'] = $this->ask('SMTP Username');
|
||||
$settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)');
|
||||
$settings['MAIL_PORT'] = $this->ask('SMTP Server Port');
|
||||
$settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname');
|
||||
$settings['MAIL_FROM'] = $this->ask('E-mail address to send from: ');
|
||||
|
||||
$this->info('>> Configuring application - We\'re going to ask a few questions here!');
|
||||
do
|
||||
{
|
||||
$this->info('== Database Settings (1/6) ==');
|
||||
$this->info('== Notification Settings (5/6) (Slack) ==');
|
||||
$settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL');
|
||||
|
||||
$settings['DB_USERNAME'] = $this->ask('Database username');
|
||||
$settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)');
|
||||
$settings['DB_DATABASE'] = $this->ask('Database name');
|
||||
$settings['DB_PORT'] = $this->ask('Database port');
|
||||
$settings['DB_HOST'] = $this->ask('Database hostname');
|
||||
$this->info('== Web Settings (6/6) ==');
|
||||
$settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): ');
|
||||
$settings['APP_LOGO'] = $this->ask('App logo (Link to an image): ');
|
||||
$settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): ');
|
||||
} while (! $this->confirm('Are you sure you want to save these settings? You can always go back and try again.'));
|
||||
|
||||
$this->info('== Antispam Settings (2/6) (Recaptcha v2) ==');
|
||||
$settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key');
|
||||
$settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key');
|
||||
foreach ($settings as $keyname => $value) {
|
||||
$this->call('environment:modify', [
|
||||
'key' => $keyname,
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->info('== IP Geolocation Settings (3/6) (refer to README.md) ==');
|
||||
$settings['IPGEO_API_KEY'] = $this->ask('API Key');
|
||||
$this->info('>> Saved configuration settings!');
|
||||
$this->info('>> Preparing database...');
|
||||
|
||||
$this->info('== Notification Settings (4/6) (Email) ==');
|
||||
$settings['MAIL_USERNAME'] = $this->ask('SMTP Username');
|
||||
$settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)');
|
||||
$settings['MAIL_PORT'] = $this->ask('SMTP Server Port');
|
||||
$settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname');
|
||||
$settings['MAIL_FROM'] = $this->ask('E-mail address to send from: ');
|
||||
$this->callSilent('config:cache');
|
||||
$this->call('migrate');
|
||||
$this->call('db:seed');
|
||||
|
||||
$this->info('== Notification Settings (5/6) (Slack) ==');
|
||||
$settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL');
|
||||
touch($basePath.'/INSTALLED');
|
||||
|
||||
$this->info('== Web Settings (6/6) ==');
|
||||
$settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): ');
|
||||
$settings['APP_LOGO'] = $this->ask('App logo (Link to an image): ');
|
||||
$settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): ');
|
||||
|
||||
|
||||
} while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.'));
|
||||
|
||||
foreach($settings as $keyname => $value)
|
||||
{
|
||||
$this->call('environment:modify', [
|
||||
'key' => $keyname,
|
||||
'value' => $value
|
||||
]);
|
||||
}
|
||||
|
||||
$this->info('>> Saved configuration settings!');
|
||||
$this->info('>> Preparing database...');
|
||||
|
||||
$this->callSilent('config:cache');
|
||||
$this->call('migrate');
|
||||
$this->call('db:seed');
|
||||
|
||||
touch($basePath . '/INSTALLED');
|
||||
|
||||
$this->call('up');
|
||||
$this->info('>> All done! Visit ' . $basePath . ' to start using your brand new installation of Raspberry Teams!');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error('[!] The application is already installed!');
|
||||
$this->call('up');
|
||||
$this->info('>> All done! Visit '.$basePath.' to start using your brand new installation of Raspberry Teams!');
|
||||
} else {
|
||||
$this->error('[!] The application is already installed!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright © 2020 Miguel Nogueira
|
||||
*
|
||||
* This file is part of Raspberry Staff Manager.
|
||||
*
|
||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use GeoSot\EnvEditor\Facades\EnvEditor;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SetEnv extends Command
|
||||
{
|
||||
@@ -37,20 +56,16 @@ class SetEnv extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$path = base_path('/.env');
|
||||
$key = $this->argument('key');
|
||||
$value = $this->argument('value');
|
||||
$path = base_path('/.env');
|
||||
$key = $this->argument('key');
|
||||
$value = $this->argument('value');
|
||||
|
||||
if (file_exists($path)) {
|
||||
EnvEditor::editKey($key, $value);
|
||||
} else {
|
||||
$this->error('Cannot update a file that doesn\'t exist! Please create .env first.');
|
||||
|
||||
|
||||
if (file_exists($path))
|
||||
{
|
||||
EnvEditor::editKey($key, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error('Cannot update a file that doesn\'t exist! Please create .env first.');
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright © 2020 Miguel Nogueira
|
||||
*
|
||||
* This file is part of Raspberry Staff Manager.
|
||||
*
|
||||
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Jobs\CleanBans;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use App\Jobs\CleanBans;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
|
Reference in New Issue
Block a user