23 Commits

Author SHA1 Message Date
Proximity
bf9b6d43f3 Update from GitHub to Gitea 2020-12-20 15:37:30 +00:00
Proximity
7fef7a0ac7 Added APP_NAME/URL to main page footer. 2020-12-20 15:36:32 +00:00
Proximity
37c22f4377 Merge branch 'develop' into develop 2020-12-20 11:30:19 +00:00
Proximity
d3d1f6f2b1 Update 'README.md' 2020-12-20 11:29:44 +00:00
Proximity
36f9e4f9f0 Added links to used 2020-12-20 11:28:57 +00:00
Proximity
d8dac401cb Make pretty 2020-12-20 05:55:03 +00:00
Miguel Nogueira
a04510ac36 Merge pull request 'Fixed carousel width' (#3) from Proximity/staffmanager:develop into develop
Reviewed-on: https://code.spacejewel-hosting.com/spacejewelhosting/staffmanager/pulls/3
2020-12-20 04:40:54 +00:00
Proximity
a7d0e05188 Fixed carousel width 2020-12-20 04:37:00 +00:00
975f0a69c7 Removed now-unsupported message option 2020-12-19 15:37:15 +00:00
a1edef026f Fix naming typo 2020-12-19 04:09:32 +00:00
cf65569702 Un-hardcode configuration value 2020-12-19 03:13:27 +00:00
0c667d74ef Refactored seeders 2020-12-08 14:56:19 +00:00
a206782187 Added TeamFile Authorization Policy 2020-12-08 03:09:17 +00:00
7323ffec2b Added Team Authorization Policy 2020-12-08 02:58:10 +00:00
6518ad3447 Fixed #2
This method would always fail for cached options because at the end it was expecting an Eloquent model, which would never be populated if the requested value was cached in the first place.

Uncached requests wouldn't fail because the exec path would lead to $value being a Model.

Also removed reference to old feature causing application page to crash.
2020-12-08 00:07:53 +00:00
8882804c6e Menu changes 2020-12-07 20:28:18 +00:00
1fae91a62b Remove view file button 2020-12-07 18:42:56 +00:00
0bdb6cf2fb Minor fixes 2020-12-07 17:48:15 +00:00
32c01f6e0b Removed useless feature 2020-11-03 03:00:03 +00:00
d53e8135ee Reverted recent accidental changes 2020-11-02 22:04:57 +00:00
e4fb438721 Merge remote-tracking branch 'origin/develop' into develop
# Conflicts:
#	app/Http/Controllers/TeamFileController.php
#	app/TeamFile.php
#	config/adminlte.php
#	routes/web.php
2020-11-02 21:50:30 +00:00
96aa01b9c6 Recent changes 2020-11-02 21:44:05 +00:00
2bdb2f2dce Merged in analysis-aoLDWj (pull request #5)
Apply fixes from StyleCI
2020-10-11 01:56:01 +00:00
510 changed files with 607 additions and 815 deletions

0
.editorconfig Normal file → Executable file
View File

4
.env.example Normal file → Executable file
View File

@@ -7,6 +7,10 @@ APP_LOGO="https://www.raspberrypi.org/app/uploads/2020/05/Raspberry-Pi-OS-downlo
APP_SITEHOMEPAGE=""
# This can be your main homepage, other than this site itself
# Forces ssl connections even if the environment is set to "local".
# Void if env is production.
NONPROD_FORCE_SECURE=false
LOG_CHANNEL=stack
DB_CONNECTION=mysql

0
.gitattributes vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/feature_request.md vendored Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
.idea/hrm-mcserver.iml generated Normal file → Executable file
View File

0
.idea/laravel-plugin.xml generated Normal file → Executable file
View File

0
.idea/misc.xml generated Normal file → Executable file
View File

0
.idea/modules.xml generated Normal file → Executable file
View File

0
.idea/php.xml generated Normal file → Executable file
View File

0
.idea/phpunit.xml generated Normal file → Executable file
View File

0
.idea/vcs.xml generated Normal file → Executable file
View File

0
.phive/phars.xml Normal file → Executable file
View File

0
.styleci.yml Normal file → Executable file
View File

0
.vscode/launch.json vendored Normal file → Executable file
View File

0
CODE_OF_CONDUCT.md Normal file → Executable file
View File

0
CONTRIBUTING.md Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
Procfile Normal file → Executable file
View File

8
README.md Normal file → Executable file
View File

@@ -43,10 +43,10 @@ Many other features are currently planned for this app, such as:
Tech stack:
- [Laravel 7](https://laravel.com/)
- Eloquent ORM
- AdminLTE / Bootstrap 4
- jQuery / Plain Javascript
- vueJS (in the future)
- [Eloquent ORM](https://laravel.com/docs/5.0/eloquent)
- [AdminLTE](https://adminlte.io/) / [Bootstrap 4](https://getbootstrap.com/docs/4.0/getting-started/introduction/)
- [jQuery](https://jquery.com/) / [Plain Javascript](https://www.javascript.com/)
- [vueJS](https://vuejs.org/) (in the future)
# Stability

0
SECURITY.md Normal file → Executable file
View File

0
app/Application.php Normal file → Executable file
View File

0
app/Appointment.php Normal file → Executable file
View File

0
app/Ban.php Normal file → Executable file
View File

0
app/Comment.php Normal file → Executable file
View File

0
app/Console/Commands/CountVotes.php Normal file → Executable file
View File

0
app/Console/Commands/CreateUser.php Normal file → Executable file
View File

4
app/Console/Commands/Install.php Normal file → Executable file
View File

@@ -61,9 +61,7 @@ class Install extends Command
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!',
]);
$this->call('down');
copy($basePath.'/.env.example', $basePath.'/.env');
$this->call('key:generate');

0
app/Console/Commands/MakeFile.php Normal file → Executable file
View File

0
app/Console/Commands/SetEnv.php Normal file → Executable file
View File

0
app/Console/Kernel.php Normal file → Executable file
View File

0
app/CustomFacades/IP.php Normal file → Executable file
View File

0
app/Events/ApplicationApprovedEvent.php Normal file → Executable file
View File

0
app/Events/ApplicationDeniedEvent.php Normal file → Executable file
View File

0
app/Events/NewApplicationEvent.php Normal file → Executable file
View File

0
app/Events/UserBannedEvent.php Normal file → Executable file
View File

0
app/Exceptions/Handler.php Normal file → Executable file
View File

0
app/Facades/ContextAwareValidation.php Normal file → Executable file
View File

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class DigitalStorageHelper extends Facade
{
protected static function getFacadeAccessor()
{
return 'digitalStorageHelperFacadeRoot';
}
}

0
app/Facades/IP.php Normal file → Executable file
View File

0
app/Facades/Options.php Normal file → Executable file
View File

0
app/Facades/UUID.php Normal file → Executable file
View File

0
app/Form.php Normal file → Executable file
View File

0
app/Helpers/ContextAwareValidator.php Normal file → Executable file
View File

View File

@@ -0,0 +1,107 @@
<?php declare(strict_types=1);
namespace App\Helpers;
/**
* Class DigitalStorageHelper
*
* The digital storage helper class helps you convert bytes into several other units.
* It should be used whenever you need to display a file's size in a human readable way.
*
* It's framework agnostic, meaning you can take it out of context and it'll still work; However, you'll have to instantiate it first.
* @package App\Helpers
*/
class DigitalStorageHelper
{
/**
* The digital storage value to be manipulated.
* @var $value
*/
protected $value;
/**
* Sets the digital storage value for manipulation.
*
* @param int $value The digital storage value in bytes
* @return $this The current instance
*/
public function setValue(int $value): DigitalStorageHelper
{
$this->value = $value;
return $this;
}
/**
* Converts the digital storage value to kilobytes.
*
* @return float|int
*/
public function toKilobytes(): float
{
return $this->value / 1000;
}
/**
* Converts the digital storage value to megabytes.
*
* @return float|int
*/
public function toMegabytes(): float
{
return $this->value / (1 * pow(10, 6)); // 1 times 10 to the power of 6
}
/**
* Convert the digital storage value to gigabytes. Might be an approximation
*
* @return float
*/
public function toGigabytes(): float
{
return $this->value / (1 * pow(10, 9));
}
/**
* Convert the digital storage value to terabytes.
*
* @return float
*/
public function toTerabytes(): float
{
return $this->value / (1 * pow(10, 12));
}
/**
* Format the digital storage value to one of the units: b, kb, mb, gb and tb.
* The method has been adapted to use both MiB and MB values.
*
* @param int $precision The rounding precision
* @param bool $si Use international system units. Defaults to false
* @return string The human readable digital storage value, in either, for instance, MB or MiB
* @see https://stackoverflow.com/a/2510459/11540218 StackOverflow question regarding unit conversion
* @since 7.3.23
*/
public function formatBytes($precision = 2, $si = false): string
{
$units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
if ($si)
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$bytes = max($this->value, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(($si) ? 1000 : 1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(($si) ? 1000 : 1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
}

4
app/Helpers/Options.php Normal file → Executable file
View File

@@ -39,9 +39,11 @@ class Options
}
Cache::put($option, $value);
Cache::put($option.'_desc', 'Undefined description');
return $value->option_value;
}
return $value->option_value;
return $value;
}
public function setOption(string $option, string $value, string $description)

52
app/Http/Controllers/ApplicationController.php Normal file → Executable file
View File

@@ -35,7 +35,7 @@ use Illuminate\Support\Facades\Log;
class ApplicationController extends Controller
{
private function canVote($votes)
private function canVote($votes): bool
{
$allvotes = collect([]);
@@ -85,56 +85,6 @@ class ApplicationController extends Controller
->with('applications', Application::paginate(6));
}
public function showAllPendingApps()
{
$this->authorize('viewAny', Application::class);
return view('dashboard.appmanagement.outstandingapps')
->with('applications', Application::where('applicationStatus', 'STAGE_SUBMITTED')->get());
}
public function showPendingInterview()
{
$this->authorize('viewAny', Application::class);
$applications = Application::with('appointment', 'user')->get();
$count = 0;
$pendingInterviews = collect([]);
$upcomingInterviews = collect([]);
foreach ($applications as $application) {
if (! is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED') {
$count = +1;
}
switch ($application->applicationStatus) {
case 'STAGE_INTERVIEW':
$upcomingInterviews->push($application);
break;
case 'STAGE_INTERVIEW_SCHEDULED':
$pendingInterviews->push($application);
break;
}
}
return view('dashboard.appmanagement.interview')
->with([
'finishedCount' => $count,
'applications' => $pendingInterviews,
'upcomingApplications' => $upcomingInterviews,
]);
}
public function showPeerReview()
{
$this->authorize('viewAny', Application::class);
return view('dashboard.appmanagement.peerreview')
->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get());
}
public function renderApplicationForm(Request $request, $vacancySlug)
{

0
app/Http/Controllers/AppointmentController.php Normal file → Executable file
View File

View File

0
app/Http/Controllers/Auth/ForgotPasswordController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/LoginController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/RegisterController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/ResetPasswordController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/TwofaController.php Normal file → Executable file
View File

0
app/Http/Controllers/Auth/VerificationController.php Normal file → Executable file
View File

0
app/Http/Controllers/BanController.php Normal file → Executable file
View File

0
app/Http/Controllers/CommentController.php Normal file → Executable file
View File

0
app/Http/Controllers/ContactController.php Normal file → Executable file
View File

0
app/Http/Controllers/Controller.php Normal file → Executable file
View File

0
app/Http/Controllers/DashboardController.php Normal file → Executable file
View File

0
app/Http/Controllers/DevToolsController.php Normal file → Executable file
View File

0
app/Http/Controllers/FormController.php Normal file → Executable file
View File

0
app/Http/Controllers/HomeController.php Normal file → Executable file
View File

0
app/Http/Controllers/OptionsController.php Normal file → Executable file
View File

0
app/Http/Controllers/ProfileController.php Normal file → Executable file
View File

0
app/Http/Controllers/ResponseController.php Normal file → Executable file
View File

0
app/Http/Controllers/StaffProfileController.php Normal file → Executable file
View File

36
app/Http/Controllers/TeamController.php Normal file → Executable file
View File

@@ -44,22 +44,14 @@ class TeamController extends Controller
*/
public function index()
{
$this->authorize('index');
$teams = Team::with('users.roles')->get();
return view('dashboard.teams.teams')
->with('teams', $teams);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
@@ -68,6 +60,8 @@ class TeamController extends Controller
*/
public function store(NewTeamRequest $request)
{
$this->authorize('create');
$team = Team::create([
'name' => $request->teamName,
'owner_id' => Auth::user()->id,
@@ -80,17 +74,6 @@ class TeamController extends Controller
return redirect()->back();
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
@@ -99,6 +82,8 @@ class TeamController extends Controller
*/
public function edit(Team $team)
{
$this->authorize('update', $team);
return view('dashboard.teams.edit-team')
->with('team', $team)
->with('users', User::all())
@@ -114,6 +99,9 @@ class TeamController extends Controller
*/
public function update(EditTeamRequest $request, Team $team)
{
$this->authorize('update', $team);
$team->description = $request->teamDescription;
$team->openJoin = $request->joinType;
@@ -137,6 +125,8 @@ class TeamController extends Controller
public function invite(SendInviteRequest $request, Team $team)
{
$this->authorize('invite', $team);
$user = User::findOrFail($request->user);
if (! $team->openJoin) {
@@ -196,6 +186,8 @@ class TeamController extends Controller
public function switchTeam(Request $request, Team $team)
{
$this->authorize('switchTeam', $team);
try {
Auth::user()->switchTeam($team);
@@ -210,6 +202,8 @@ class TeamController extends Controller
// Since it's a separate form, we shouldn't use the same update method
public function assignVacancies(Request $request, Team $team)
{
$this->authorize('update', $team);
// P.S. To future developers
// This method gave me a lot of trouble lol. It's hard to write code when you're half asleep.
// There may be an n+1 query in the view and I don't think there's a way to avoid that without writing a lot of extra code.

142
app/Http/Controllers/TeamFileController.php Normal file → Executable file
View File

@@ -1,31 +1,26 @@
<?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;
// Most of these namespaces have no effect on the code, however, they're used by IDEs so they can resolve return types and for PHPDocumentor as well
use App\TeamFile;
use Illuminate\Http\Request;
use App\Http\Requests\UploadFileRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\FileNotFoundException;
// Documentation-purpose namespaces
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class TeamFileController extends Controller
{
@@ -33,68 +28,84 @@ class TeamFileController extends Controller
* Display a listing of the resource.
*
* @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\Response
* @return Application|Factory|View|Response
*/
public function index(Request $request)
{
if (is_null(Auth::user()->currentTeam)) {
$request->session()->flash('error', 'Please choose a team before viewing it\'s files.');
$this->authorize('index');
if (is_null(Auth::user()->currentTeam))
{
$request->session()->flash('error', 'Please choose a team before viewing it\'s files.');
return redirect()->to(route('teams.index'));
}
return view('dashboard.teams.team-files')
->with('files', TeamFile::with('team', 'uploader')->paginate(20));
->with('files', TeamFile::with('team', 'uploader')->paginate(6));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @param UploadFileRequest $request
* @return RedirectResponse
*/
public function store(Request $request)
public function store(UploadFileRequest $request)
{
//
$this->authorize('store');
$upload = $request->file('file');
$file = $upload->store('uploads');
$originalFileName = $upload->getClientOriginalName();
$originalFileExtension = $upload->extension();
$originalFileSize = $upload->getSize();
$fileEntry = TeamFile::create([
'uploaded_by' => Auth::user()->id,
'team_id' => Auth::user()->currentTeam->id,
'name' => $originalFileName,
'caption' => $request->caption,
'description' => $request->description,
'fs_location' => $file,
'extension' => $originalFileExtension,
'size' => $originalFileSize
]);
if ($fileEntry && !is_bool($file))
{
$request->session()->flash('success', 'File uploaded successfully!');
return redirect()->back();
}
$request->session()->flash('error', 'There was an unknown error whilst trying to upload your file.');
return redirect()->back();
}
public function download(Request $request, TeamFile $teamFile)
{
try {
return Storage::download('uploads/'.$teamFile->name);
} 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.');
$this->authorize('download');
return redirect()->back();
try
{
return Storage::download($teamFile->fs_location, $teamFile->name);
}
}
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.');
return redirect()->back();
/**
* Display the specified resource.
*
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
*/
public function show(TeamFile $teamFile)
{
//
}
}
/**
* Show the form for editing the specified resource.
*
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
* @return Response
*/
public function edit(TeamFile $teamFile)
{
@@ -106,7 +117,7 @@ class TeamFileController extends Controller
*
* @param \Illuminate\Http\Request $request
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
* @return Response
*/
public function update(Request $request, TeamFile $teamFile)
{
@@ -116,11 +127,26 @@ class TeamFileController extends Controller
/**
* Remove the specified resource from storage.
*
* @param \App\TeamFile $teamFile
* @return \Illuminate\Http\Response
* @param Request $request
* @param \App\TeamFile $teamFile
* @return RedirectResponse
*/
public function destroy(TeamFile $teamFile)
public function destroy(Request $request, TeamFile $teamFile)
{
//
$this->authorize('delete');
try
{
Storage::delete($teamFile->fs_location);
$teamFile->delete();
$request->session()->flash('success', 'File deleted successfully.');
}
catch (\Exception $ex)
{
$request->session()->flash('error', 'There was an error deleting the file: ' . $ex->getMessage());
}
return redirect()->back();
}
}

0
app/Http/Controllers/UserController.php Normal file → Executable file
View File

0
app/Http/Controllers/VacancyController.php Normal file → Executable file
View File

0
app/Http/Controllers/VoteController.php Normal file → Executable file
View File

0
app/Http/Kernel.php Normal file → Executable file
View File

0
app/Http/Middleware/ApplicationEligibility.php Normal file → Executable file
View File

0
app/Http/Middleware/Authenticate.php Normal file → Executable file
View File

0
app/Http/Middleware/Bancheck.php Normal file → Executable file
View File

0
app/Http/Middleware/CheckForMaintenanceMode.php Normal file → Executable file
View File

0
app/Http/Middleware/EncryptCookies.php Normal file → Executable file
View File

0
app/Http/Middleware/ForceLogoutMiddleware.php Normal file → Executable file
View File

0
app/Http/Middleware/RedirectIfAuthenticated.php Normal file → Executable file
View File

0
app/Http/Middleware/TrimStrings.php Normal file → Executable file
View File

0
app/Http/Middleware/TrustProxies.php Normal file → Executable file
View File

0
app/Http/Middleware/UsernameUUID.php Normal file → Executable file
View File

0
app/Http/Middleware/VerifyCsrfToken.php Normal file → Executable file
View File

0
app/Http/Requests/Add2FASecretRequest.php Normal file → Executable file
View File

0
app/Http/Requests/BanUserRequest.php Normal file → Executable file
View File

0
app/Http/Requests/ChangeEmailRequest.php Normal file → Executable file
View File

0
app/Http/Requests/ChangePasswordRequest.php Normal file → Executable file
View File

0
app/Http/Requests/DeleteUserRequest.php Normal file → Executable file
View File

0
app/Http/Requests/EditTeamRequest.php Normal file → Executable file
View File

0
app/Http/Requests/FlushSessionsRequest.php Normal file → Executable file
View File

0
app/Http/Requests/NewCommentRequest.php Normal file → Executable file
View File

0
app/Http/Requests/NewTeamRequest.php Normal file → Executable file
View File

0
app/Http/Requests/ProfileSave.php Normal file → Executable file
View File

0
app/Http/Requests/Remove2FASecretRequest.php Normal file → Executable file
View File

0
app/Http/Requests/SaveNotesRequest.php Normal file → Executable file
View File

0
app/Http/Requests/SearchPlayerRequest.php Normal file → Executable file
View File

0
app/Http/Requests/SendInviteRequest.php Normal file → Executable file
View File

0
app/Http/Requests/UpdateUserRequest.php Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More