Skip to content

Commit

Permalink
Merge pull request #551 from EotvosCollegium/staging
Browse files Browse the repository at this point in the history
Deploy recent changes
  • Loading branch information
horcsinbalint authored Jun 16, 2024
2 parents 1d19b76 + d717805 commit 7f26e65
Show file tree
Hide file tree
Showing 106 changed files with 3,279 additions and 1,429 deletions.
17 changes: 17 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-GB"
tone_instructions: "I would rather you spoke with a polite and serious British accent"
early_access: false
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: false
poem: false
review_status: false
collapse_walkthrough: true
auto_review:
enabled: true
drafts: true
chat:
auto_reply: true

11 changes: 3 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_TEST_ADMIN=example@eotvos.elte.hu
MAIL_ACTIVE=false
MAIL_DRIVER=smtp
MAIL_ACTIVE=true
MAIL_MAILER=log # rewrite this to smtp in production
MAIL_LOG_CHANNEL=mail
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
Expand Down Expand Up @@ -88,15 +89,9 @@ PDFLATEX_COMMAND=/usr/bin/pdflatex
WORKSHOP_BALANCE_EXTERN=0.45
WORKSHOP_BALANCE_RESIDENT=0.6

APPLICATION_DEADLINE=
APPLICATION_EXTENDED=false

GITHUB_AUTH_TOKEN=
GITHUB_REPO=EotvosCollegium/mars

MR_AND_MISS_DEADLINE="2020-03-15 00:00:00"
SEMESTER_EVALUATION_DEADLINE="2020-06-15 23:59:00"

BACKUP_PATH=
RADIUS_LOG_PATH=/var/log/freeradius/radius.log.1 #yesterday's log
DHCP_LEASES_PATH=/var/lib/dhcp/dhcpd.leases
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
/resources/lang/la
/resources/lang/sp
/vendor
/data
.env
.env.backup
.phpunit.cache/
.phpunit.result.cache
Homestead.json
Homestead.yaml
Expand All @@ -30,3 +32,4 @@ _ide_helper.php
_ide_helper_models.php
.phpstorm.meta.php
*.DS_Store
.vscode
50 changes: 0 additions & 50 deletions app/Console/Commands/RefreshEventTriggers.php

This file was deleted.

60 changes: 60 additions & 0 deletions app/Exports/UsersSheets/AnonymousQuestionsExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Exports\UsersSheets;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithHeadings;

use App\Models\AnonymousQuestions\AnswerSheet;
use App\Models\Semester;

/**
* Exports all answers to anonymous questions of a given semester.
*/
class AnonymousQuestionsExport implements FromCollection, WithMapping, WithHeadings
{
/**
* The semester whose questions are queried.
*/
private Semester $semester;

public function __construct(Semester $semester)
{
$this->semester = $semester;
}

/**
* The collection on which we are going to work.
*
* @return \Illuminate\Support\Collection
*/
public function collection(): \Illuminate\Support\Collection
{
return $this->semester->answerSheets()
->orderBy('year_of_acceptance')
->inRandomOrder() // so that they cannot be tracked as easily
->get();
}

/**
* The way we create a row from an element.
*
* @param AnswerSheet $answerSheet
*/
public function map($answerSheet): array
{
return $answerSheet->toArray();
}

/**
* The first row of the spreadsheet.
*/
public function headings(): array
{
return array_merge([
__('general.semester'),
__('user.year_of_acceptance')
], $this->semester->questions()->orderBy('id')->pluck('title')->all());
}
}
78 changes: 46 additions & 32 deletions app/Http/Controllers/Auth/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,59 @@
use App\Http\Controllers\Controller;
use App\Models\ApplicationForm;
use App\Models\Faculty;
use App\Models\User;
use App\Models\Workshop;
use App\Models\RoleUser;
use App\Models\File;
use App\Models\Role;
use App\Models\RoleUser;
use App\Models\Semester;
use App\Models\User;
use App\Models\Workshop;
use App\Utils\HasPeriodicEvent;
use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use Maatwebsite\Excel\Facades\Excel;

class ApplicationController extends Controller
{
use HasPeriodicEvent;

private const EDUCATIONAL_ROUTE = 'educational';
private const QUESTIONS_ROUTE = 'questions';
private const FILES_ROUTE = 'files';
private const DELETE_FILE_ROUTE = 'files.delete';
private const ADD_PROFILE_PIC_ROUTE = 'files.profile';
private const SUBMIT_ROUTE = 'submit';

/**
* Update the PeriodicEvent connected to the applications.
* @throws AuthorizationException
*/
public function updateApplicationPeriod(Request $request): RedirectResponse
{
$this->authorize('finalize', ApplicationForm::class);

$request->validate([
'semester_id' => 'required|exists:semesters,id',
'start_date' => 'required|date',
'end_date' => 'required|date|after:now|after:start_date',
'extended_end_date' => 'nullable|date|after:end_date',
]);

$this->updatePeriodicEvent(
Semester::find($request->semester_id),
Carbon::parse($request->start_date),
Carbon::parse($request->end_date),
$request->extended_end_date ? Carbon::parse($request->extended_end_date) : null
);

return back()->with('message', __('general.successful_modification'));
}

/**
* Return the view based on the request's page parameter.
* @param Request $request
Expand All @@ -48,8 +77,8 @@ public function showApplicationForm(Request $request): View|RedirectResponse
$data = [
'workshops' => Workshop::all(),
'faculties' => Faculty::all(),
'deadline' => self::getApplicationDeadline(),
'deadline_extended' => self::isDeadlineExtended(),
'deadline' => $this->getDeadline(),
'deadline_extended' => $this->isExtended(),
'user' => user(),
];
switch ($request->input('page')) {
Expand All @@ -74,7 +103,7 @@ public function storeApplicationForm(Request $request)
{
$user = $request->user();

if (now() > self::getApplicationDeadline()) {
if (now() > $this->getDeadline()) {
return redirect()->route('application')->with('error', 'A jelentkezési határidő lejárt');
}

Expand Down Expand Up @@ -113,13 +142,13 @@ public function showApplications(Request $request): View
if ($request->has('id')) { // return one application in detail
$user = User::withoutGlobalScope('verified')
->with('application')->findOrFail($request->input('id'));
$this->authorize('viewApplication', $user);
$this->authorize('view', $user->application);
return view('auth.application.applications_details', [
'user' => $user,
]);
} else { //return all applications that can be visible
$this->authorize('viewSomeApplication', User::class);
if($authUser->can('viewAllApplications', User::class)) {
$this->authorize('viewSome', ApplicationForm::class);
if($authUser->can('viewAll', ApplicationForm::class)) {
$workshops = Workshop::all();
} else {
$workshops = $authUser->roleWorkshops->concat($authUser->applicationCommitteWorkshops);
Expand Down Expand Up @@ -150,7 +179,8 @@ public function showApplications(Request $request): View
'workshop' => $request->input('workshop'), //filtered workshop
'workshops' => $workshops, //workshops that can be chosen to filter
'status' => $request->input('status'), //filtered status
'applicationDeadline' => self::getApplicationDeadline(),
'applicationDeadline' => $this->getDeadline(),
'periodicEvent' => $this->periodicEvent()
]);
}
}
Expand All @@ -163,7 +193,7 @@ public function showApplications(Request $request): View
*/
public function editApplication(Request $request): RedirectResponse
{
$this->authorize('viewSomeApplication', User::class);
$this->authorize('viewSome', ApplicationForm::class);
$application = ApplicationForm::findOrFail($request->input('application'));
$newStatus = $request->input('status_'.$application->user->id);
if ($request->has('note')) {
Expand All @@ -181,7 +211,7 @@ public function editApplication(Request $request): RedirectResponse
*/
public function finalizeApplicationProcess()
{
$this->authorize('finalizeApplicationProcess', User::class);
$this->authorize('finalize', ApplicationForm::class);
Cache::forget('collegists');
$not_handled_applicants = User::query()->withoutGlobalScope('verified')
->where('verified', 0)
Expand Down Expand Up @@ -223,22 +253,6 @@ public function finalizeApplicationProcess()
return back()->with('message', 'Sikeresen jóváhagyta az elfogadott jelentkezőket');
}

/**
* @return Carbon the application deadline set in .env
*/
public static function getApplicationDeadline(): Carbon
{
return Carbon::parse(config('custom.application_deadline'));
}

/**
* @return bool if the deadline has been extended or not
*/
public static function isDeadlineExtended(): bool
{
return config('custom.application_extended');
}


/**
* @param Request $request
Expand Down Expand Up @@ -314,7 +328,7 @@ public function submitApplication(User $user)
if ($user->application->missingData() == []) {
$user->application->update(['status' => ApplicationForm::STATUS_SUBMITTED]);
$user->internetAccess->setWifiCredentials($user->educationalInformation->neptun);
$user->internetAccess()->update(['has_internet_until' => $this::getApplicationDeadline()->addMonth(1)]);
$user->internetAccess()->update(['has_internet_until' => $this->getDeadline()?->addMonth()]);
return back()->with('message', 'Sikeresen véglegesítette a jelentkezését!');
} else {
return back()->with('error', 'Hiányzó adatok!');
Expand All @@ -326,7 +340,7 @@ public function submitApplication(User $user)
*/
public function exportApplications()
{
$this->authorize('viewAllApplications', User::class);
$this->authorize('viewAll', ApplicationForm::class);

$applications = ApplicationForm::with('user')
->where('status', ApplicationForm::STATUS_SUBMITTED)
Expand Down
Loading

0 comments on commit 7f26e65

Please sign in to comment.