WIP: Road to 1.0.0 #1

Draft
miguel456 wants to merge 123 commits from develop into master
14 changed files with 265 additions and 88 deletions
Showing only changes of commit d5d23b7dbd - Show all commits

View File

@ -1,5 +1,24 @@
<?php <?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; namespace App\Console\Commands;
use App\Facades\UUID; use App\Facades\UUID;
@ -23,6 +42,7 @@ class CreateUser extends Command
* @var string * @var string
*/ */
protected $description = 'Creates an application user. Seeding the database is for testing environments, so use this command in production for your first admin user.'; protected $description = 'Creates an application user. Seeding the database is for testing environments, so use this command in production for your first admin user.';
/** /**
* Create a new command instance. * Create a new command instance.
* *
@ -40,9 +60,7 @@ class CreateUser extends Command
*/ */
public function handle() public function handle()
{ {
do {
do
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
system('cls'); system('cls');
} else { } else {
@ -53,60 +71,43 @@ class CreateUser extends Command
$this->info('We\'ll ask some questions to get you started.'); $this->info('We\'ll ask some questions to get you started.');
$username = $this->ask('Username'); $username = $this->ask('Username');
do do {
{
$password = $this->secret('Password'); $password = $this->secret('Password');
$password_confirm = $this->secret('Confirm Password'); $password_confirm = $this->secret('Confirm Password');
if ($password === $password_confirm) if ($password === $password_confirm) {
{
$password = Hash::make($password); $password = Hash::make($password);
$matches = true; $matches = true;
} } else {
else
{
$this->error('Password doesn\'t match. Please try again.'); $this->error('Password doesn\'t match. Please try again.');
$matches = false; $matches = false;
} }
} } while (! $matches);
while(!$matches);
$email = $this->ask('E-mail address'); $email = $this->ask('E-mail address');
$name = $this->ask('First/Last Name'); $name = $this->ask('First/Last Name');
do do {
{ try {
try
{
$uuid = UUID::toUUID($this->ask('Minecraft username (Must be a valid Premium account)')); $uuid = UUID::toUUID($this->ask('Minecraft username (Must be a valid Premium account)'));
} } catch (\InvalidArgumentException $e) {
catch (\InvalidArgumentException $e)
{
$this->error($e->getMessage()); $this->error($e->getMessage());
$hasError = true; $hasError = true;
} }
if (isset($hasError)) if (isset($hasError)) {
{
$continue = true; $continue = true;
} } else {
else
{
$continue = false; $continue = false;
} }
unset($hasError); unset($hasError);
} } while ($continue);
while($continue);
$this->info('Please check if these details are correct: '); $this->info('Please check if these details are correct: ');
$this->info('Username: ' . $username); $this->info('Username: '.$username);
$this->info('Email: ' . $email); $this->info('Email: '.$email);
$this->info('Name: ' . $name); $this->info('Name: '.$name);
} while (! $this->confirm('Create user now? You can go back to correct any details.'));
}
while(!$this->confirm('Create user now? You can go back to correct any details.'));
$user = User::create([ $user = User::create([
'uuid' => $uuid, 'uuid' => $uuid,
@ -114,11 +115,10 @@ class CreateUser extends Command
'email' => $email, 'email' => $email,
'username' => $username, 'username' => $username,
'originalIP' => '127.0.0.1', 'originalIP' => '127.0.0.1',
'password' => $password 'password' => $password,
]); ]);
if ($user) if ($user) {
{
$user->assignRole('admin', 'reviewer', 'user', 'hiringManager'); $user->assignRole('admin', 'reviewer', 'user', 'hiringManager');
Profile::create([ Profile::create([
'profileShortBio' => 'Random data '.rand(0, 1000), 'profileShortBio' => 'Random data '.rand(0, 1000),
@ -128,13 +128,12 @@ class CreateUser extends Command
'userID' => $user->id, 'userID' => $user->id,
]); ]);
$this->info('Account created! You may now login at ' . route('login') . '. Enjoy the app!'); $this->info('Account created! You may now login at '.route('login').'. Enjoy the app!');
return 0; return 0;
} } else {
else
{
$this->error('There was an unknown problem creating the user. There might have been errors above. Please try again.'); $this->error('There was an unknown problem creating the user. There might have been errors above. Please try again.');
return 1; return 1;
} }
} }

View File

@ -1,12 +1,29 @@
<?php <?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; namespace App\Console\Commands;
use Faker\Factory; use Faker\Factory;
use Faker\Generator; use Faker\Generator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
class MakeFile extends Command class MakeFile extends Command
@ -25,7 +42,6 @@ class MakeFile extends Command
*/ */
protected $description = 'Generates test files for the TeamFile model. Use in conjunction with it\'s factory.'; protected $description = 'Generates test files for the TeamFile model. Use in conjunction with it\'s factory.';
/** /**
* The faker instance used to obtain dummy text. * The faker instance used to obtain dummy text.
* *
@ -53,15 +69,14 @@ class MakeFile extends Command
public function handle() public function handle()
{ {
$count = $this->argument('count'); $count = $this->argument('count');
$this->info('Creating ' . $this->argument('count') . ' files!'); $this->info('Creating '.$this->argument('count').' files!');
for ($max = 1; $max < $count; $max++)
{
Storage::disk('local')->put('factory_files/testfile_' . rand(0, 5000) . '.txt', $this->faker->paragraphs(40, true));
for ($max = 1; $max < $count; $max++) {
Storage::disk('local')->put('factory_files/testfile_'.rand(0, 5000).'.txt', $this->faker->paragraphs(40, true));
} }
$this->info('Finished creating files! They will be randomly picked by the factory.'); $this->info('Finished creating files! They will be randomly picked by the factory.');
return 0; return 0;
} }
} }

View File

@ -1,5 +1,24 @@
<?php <?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\Http\Controllers; namespace App\Http\Controllers;
use App\TeamFile; use App\TeamFile;
@ -18,9 +37,9 @@ class TeamFileController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
if (is_null(Auth::user()->currentTeam)) if (is_null(Auth::user()->currentTeam)) {
{
$request->session()->flash('error', 'Please choose a team before viewing it\'s files.'); $request->session()->flash('error', 'Please choose a team before viewing it\'s files.');
return redirect()->to(route('teams.index')); return redirect()->to(route('teams.index'));
} }
@ -49,18 +68,14 @@ class TeamFileController extends Controller
// //
} }
public function download(Request $request, TeamFile $teamFile) public function download(Request $request, TeamFile $teamFile)
{ {
try try {
{ return Storage::download('uploads/'.$teamFile->name);
return Storage::download('uploads/' . $teamFile->name); } catch (FileNotFoundException $ex) {
}
catch (FileNotFoundException $ex)
{
$request->session()->flash('error', 'Sorry, but the requested file could not be found in storage. Sometimes, files may be physically deleted by admins, but not from the app\'s database.'); $request->session()->flash('error', 'Sorry, but the requested file could not be found in storage. Sometimes, files may be physically deleted by admins, but not from the app\'s database.');
return redirect()->back();
return redirect()->back();
} }
} }

View File

@ -37,7 +37,6 @@ class Team extends TeamworkTeam
return $this->belongsToMany('App\Vacancy', 'team_has_vacancy'); return $this->belongsToMany('App\Vacancy', 'team_has_vacancy');
} }
public function files() public function files()
{ {
return $this->hasMany('App\TeamFile', 'team_id'); return $this->hasMany('App\TeamFile', 'team_id');

View File

@ -1,5 +1,24 @@
<?php <?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; namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
@ -10,13 +29,12 @@ class TeamFile extends Model
{ {
use HasFactory, UsedByTeams; use HasFactory, UsedByTeams;
protected $fillable = [ protected $fillable = [
'uploaded_by', 'uploaded_by',
'team_id', 'team_id',
'name', 'name',
'fs_location', 'fs_location',
'extension' 'extension',
]; ];
public function uploader() public function uploader()

View File

@ -616,14 +616,14 @@ return [
[ [
'type' => 'js', 'type' => 'js',
'asset' => false, 'asset' => false,
'location' => '/js/plugins/dropzone.min.js' 'location' => '/js/plugins/dropzone.min.js',
], ],
[ [
'type' => 'css', 'type' => 'css',
'asset' => false, 'asset' => false,
'location' => '/css/dropzone.min.css' 'location' => '/css/dropzone.min.css',
] ],
] ],
] ],
], ],
]; ];

View File

@ -1,5 +1,24 @@
<?php <?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/>.
*/
return [ return [
/* /*

View File

@ -1,5 +1,24 @@
<?php <?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/>.
*/
return [ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -1,6 +1,25 @@
<?php <?php
return array( /*
* 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/>.
*/
return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| One Signal App Id | One Signal App Id
@ -19,5 +38,5 @@ return array(
| |
*/ */
'rest_api_key' => 'YOUR-REST-API-KEY-HERE', 'rest_api_key' => 'YOUR-REST-API-KEY-HERE',
'user_auth_key' => 'YOUR-USER-AUTH-KEY' 'user_auth_key' => 'YOUR-USER-AUTH-KEY',
); ];

View File

@ -1,5 +1,24 @@
<?php <?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 Database\Factories; namespace Database\Factories;
use App\TeamFile; use App\TeamFile;
@ -27,12 +46,12 @@ class TeamFileFactory extends Factory
return [ return [
'uploaded_by' => rand(1, 10), // Also assuming that the user seeder has ran before 'uploaded_by' => rand(1, 10), // Also assuming that the user seeder has ran before
'team_id' => rand(1, 3), // Assuming you create 3 teams beforehand 'team_id' => rand(1, 3), // Assuming you create 3 teams beforehand
'name' => $this->faker->file($prefix . 'factory_files', $prefix . 'uploads', false), 'name' => $this->faker->file($prefix.'factory_files', $prefix.'uploads', false),
'caption' => $this->faker->sentence(), 'caption' => $this->faker->sentence(),
'description' => $this->faker->paragraphs(3, true), 'description' => $this->faker->paragraphs(3, true),
'fs_location' => $this->faker->file($prefix . 'factory_files', $prefix . 'uploads'), 'fs_location' => $this->faker->file($prefix.'factory_files', $prefix.'uploads'),
'extension' => 'txt', 'extension' => 'txt',
'size' => rand(1, 1000) // random fake size between 0 bytes and 1 mb 'size' => rand(1, 1000), // random fake size between 0 bytes and 1 mb
]; ];
} }
} }

View File

@ -1,5 +1,24 @@
<?php <?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/>.
*/
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,24 @@
<?php <?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/>.
*/
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,24 @@
<?php <?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 Database\Seeders; namespace Database\Seeders;
use App\TeamFile; use App\TeamFile;

View File

@ -87,7 +87,6 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
Route::get('teams/invites/{action}/{token}', [TeamController::class, 'processInviteAction']) Route::get('teams/invites/{action}/{token}', [TeamController::class, 'processInviteAction'])
->name('processInvite'); ->name('processInvite');
Route::get('team/files', [TeamFileController::class, 'index']) Route::get('team/files', [TeamFileController::class, 'index'])
->name('showTeamFiles'); ->name('showTeamFiles');
@ -97,7 +96,6 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
Route::get('team/files/{teamFile}/download', [TeamFileController::class, 'download']) Route::get('team/files/{teamFile}/download', [TeamFileController::class, 'download'])
->name('downloadTeamFile'); ->name('downloadTeamFile');
Route::group(['prefix' => '/applications'], function () { Route::group(['prefix' => '/applications'], function () {
Route::get('/my-applications', [ApplicationController::class, 'showUserApps']) Route::get('/my-applications', [ApplicationController::class, 'showUserApps'])
->name('showUserApps') ->name('showUserApps')