Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - High priority issuses #544

Merged
merged 21 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cd9542f
Make the invitation routes unprotected (as in not auth required)
v-stamenova Sep 16, 2024
aa24cf1
Make sure that the canceled presentations are marked in red when canc…
v-stamenova Sep 16, 2024
d70902c
Add colors of presentations in crew schedule to safelist
v-stamenova Sep 18, 2024
aad09ff
Show speakers and presentations before programme release
v-stamenova Sep 18, 2024
bcceade
Sponsors block on welcome page visible only when such sponsors exist
v-stamenova Sep 18, 2024
caf8978
Fix postcode issue on company registration
v-stamenova Sep 18, 2024
75d1447
Remove pending booth owner/speaker from assign crew roles
v-stamenova Sep 18, 2024
c58163f
Restrict the room deletion to not be possible if there is a presentat…
v-stamenova Sep 18, 2024
eb915d2
Replace the booth create page with a livewire component to be able to…
v-stamenova Sep 18, 2024
ae3e441
Fix lint and unit tests
v-stamenova Sep 18, 2024
1932756
Comment out tests on unused route in `BoothController`
v-stamenova Sep 18, 2024
dfa8084
Restrict access to programme if it is not released
IGORnvk Sep 18, 2024
f27035f
Fix dark mode styling on companies page
IGORnvk Sep 18, 2024
b6e2592
Fix the http to be https in the links
v-stamenova Sep 25, 2024
2bbbe72
Merge branch 'bugfix/high-priority-small-issuses' of https://github.c…
v-stamenova Sep 25, 2024
c3332b8
Remove the https and make sure that the seeded data has it instead
v-stamenova Sep 25, 2024
430cfb9
Remove the "booth" mistake from the presentation logging
v-stamenova Sep 25, 2024
7f443b8
Put a bit more explanation on the select representative in the crew c…
v-stamenova Sep 25, 2024
543f7d1
Fix condition in show method for presentation
IGORnvk Sep 25, 2024
e03a043
Fix order of instructions in README
IGORnvk Sep 25, 2024
229e624
Fix wording in emails
IGORnvk Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ docker run --rm \
```
4. Install the NPM packages - `npm install`
5. Set up the environment variables - `cp .env.example .env`
6. Add the app key - `./vendor/bin/sail artisan key:generate`
7. After the dependencies are installed run `./vendor/bin/sail up -d`
6. After the dependencies are installed run `./vendor/bin/sail up -d`
7. Add the app key - `./vendor/bin/sail artisan key:generate`
8. After the creation of the containers run `./vendor/bin/sail artisan migrate`
9. Run `npm run dev`

Expand Down
3 changes: 3 additions & 0 deletions app/Http/Controllers/Crew/BoothController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function create()
*/
public function store(Request $request)
{
// CURRENTLY NOT IN USE
abort(404);

if ($request->user()->cannot('create', Booth::class)) {
abort(403);
}
Expand Down
11 changes: 9 additions & 2 deletions app/Http/Controllers/Crew/CrewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@ class CrewController extends Controller
* Returns the main page of the crew page
* @return View
*/
public function index() : View
public function index(): View
{
if (!Gate::authorize('view-crew')) {
abort(403);
}

$roles = Role::whereNotIn(
'name',
['participant', 'company representative', 'company member', 'booth owner']
[
'participant',
'company representative',
'company member',
'booth owner',
'pending booth owner',
'pending speaker'
]
)->get();

return view('crew.crew.index', compact('roles'));
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Crew/RoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function show(Room $room)
*/
public function destroy(Room $room): RedirectResponse // TODO: Refactor the FK constraints in the db
{
if (Auth::user()->cannot('delete', Room::class)) {
if (Auth::user()->cannot('delete', $room)) {
abort(403);
}

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Edition;
use App\Models\Company;
use App\Models\Sponsorship;
use Illuminate\Http\Request;
use Illuminate\View\View;

Expand All @@ -16,11 +17,12 @@ class HomeController extends Controller
public function index() : View
{
$edition = Edition::current();
$anySponsorships = Sponsorship::doesntHave('companies')->count() === Sponsorship::count();
$goldSponsorCompany = Company::where('is_approved', 1)
->where('sponsorship_id', 1)
->where('is_sponsorship_approved', 1)
->first();

return view('welcome', compact(['edition', 'goldSponsorCompany']));
return view('welcome', compact(['edition', 'goldSponsorCompany', 'anySponsorships']));
}
}
9 changes: 9 additions & 0 deletions app/Http/Controllers/ProgrammeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers;

use App\Models\Edition;
use App\Models\Presentation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand All @@ -16,6 +17,10 @@ class ProgrammeController extends Controller
*/
public function index(): View
{
if (!optional(Edition::current())->is_programme_released) {
abort(404);
}

$lectures = Presentation::where('type', 'lecture')
->whereNotNull('room_id')
->whereNotNull('timeslot_id')
Expand Down Expand Up @@ -47,6 +52,10 @@ public function index(): View
*/
public function show(Presentation $presentation): View
{
if (!$presentation->is_approved) {
abort(404);
}

$styles = [
1 => [
'borderColor' => 'bg-gradient-to-r from-yellow-300 to-yellow-600', // Gold
Expand Down
31 changes: 18 additions & 13 deletions app/Http/Controllers/SpeakerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,34 @@ class SpeakerController extends Controller
*/
public function index()
{
$speakers = collect();
$edition = Edition::current();
$query = UserPresentation::where('role', 'speaker');

if (!$edition) {
return redirect(route('welcome'))
->dangerBanner("Speakers are not available yet.");
}

// If the final program is released, filter by room_id and timeslot_id
if (optional(Edition::current())->is_final_programme_released) {
$speakers = UserPresentation::where('role', 'speaker')
->whereHas('presentation', function ($query) {
$query->whereNotNull('room_id')
->whereNotNull('timeslot_id');
})
->get()
->sortBy(function ($speaker) {
if ($speaker->user->company && $speaker->user->company->is_sponsorship_approved) {
return $speaker->user->company->sponsorship_id;
}
return 999; // Assign a high value to non-sponsored speakers
});
$query->whereHas('presentation', function ($query) {
$query->whereNotNull('room_id')
->whereNotNull('timeslot_id');
});
} else {
// Otherwise, filter by is_approved
$query->whereHas('presentation', function ($query) {
$query->where('is_approved', true);
});
}

$speakers = $query->get()->sortBy(function ($speaker) {
if ($speaker->user->company && $speaker->user->company->is_sponsorship_approved) {
return $speaker->user->company->sponsorship_id;
}
return 999; // Assign a high value to non-sponsored speakers
});

return view('speakers.index', compact('speakers', 'edition'));
}
}
142 changes: 142 additions & 0 deletions app/Livewire/Booth/CreateBooth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php

namespace App\Livewire\Booth;

use App\Livewire\Forms\BoothForm;
use App\Models\Booth;
use App\Models\Company;
use App\Models\User;
use Illuminate\View\View;
use Livewire\Attributes\Validate;
use Livewire\Component;

class CreateBooth extends Component
{
#[Validate(['required', 'numeric', 'min:1', 'max:10'])]
public $width;

#[Validate(['required', 'numeric', 'min:1', 'max:10'])]
public $length;

#[Validate(['nullable', 'max:255'])]
public $additionalInformation;

public $company;
public $companies;
public $companyId;

public $searchValue;
public $isDropdownVisible;
public $users;
public $selectedUser;

/**
* Initializes the component
* @return void
*/
public function mount()
{
$this->companies = Company::whereDoesntHave('booth')->where('is_approved', '=', '1')->get();
$this->company = $this->companies->first();
$this->isDropdownVisible = false;
$this->users = optional($this->company)->users;
$this->searchValue = '';
}

/**
* Creates the entity
* @return void
*/
public function save()
{
$this->validate();

$this->validate([
'company' => 'required',
'selectedUser' => 'required'
]);

$boothData = [
'width' => $this->width,
'length' => $this->length,
'additional_information' => $this->additionalInformation,
'company_id' => $this->company->id,
'is_approved' => true
];

Booth::create($boothData);

$this->selectedUser->assignRole('booth owner');

if ($this->selectedUser->hasRole('pending booth owner')) {
$this->selectedUser->removeRole('pending booth owner');
}

$this->redirect(route('moderator.booths.index'));
}

/**
* Triggers the filtering function if the email/name is being changed
*
* @return void
*/
public function updatedSearchValue() : void
{
$this->users = $this->company->users;
if (!empty($this->searchValue)) {
$this->users = $this->users->filter(function ($user) {
$nameMatch = stripos($user->name, $this->searchValue) !== false;
$emailMatch = stripos($user->email, $this->searchValue) !== false;

return $nameMatch || $emailMatch;
});
}
}

/**
* Handles the update of the company id
* @return void
*/
public function updatedCompanyId() : void
{
$this->company = Company::find($this->companyId);
$this->users = $this->company->users;
$this->searchValue = '';
$this->updatedSearchValue();
$this->selectedUser = null;
$this->isDropdownVisible = false;
}

/**
* Triggered when the user chooses the assignee
*
* @param $id
* @return void
*/
public function selectUser($id) : void
{
$this->selectedUser = User::find($id);
$this->searchValue = $this->selectedUser->name;
$this->updatedSearchValue();
$this->isDropdownVisible = false;
}

/**
* Responsible for the visibility status of the dropdown
*
* @return void
*/
public function toggleDropdown() : void
{
$this->isDropdownVisible = !$this->isDropdownVisible;
}

/**
* Renders the component
* @return View
*/
public function render() : View
{
return view('livewire.booth.create-booth');
}
}
2 changes: 1 addition & 1 deletion app/Livewire/Company/AddMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function invite(): void
$this->validate();
if ($this->currentRole == 'speaker') {
$this->currentRole = 'pending speaker';
} else if ($this->currentRole == 'booth owner') {
} elseif ($this->currentRole == 'booth owner') {
$this->currentRole = 'pending booth owner';
}

Expand Down
2 changes: 1 addition & 1 deletion app/Mail/BoothDisapprovedMailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(Company $company)
public function envelope(): Envelope
{
return new Envelope(
subject: 'Booth Disapproved',
subject: 'Booth Refused',
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Mail/PresentationDisapprovedMailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct()
public function envelope(): Envelope
{
return new Envelope(
subject: 'Presentation Disapproved',
subject: 'Presentation Refused',
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Mail/SponsorshipDisapprovedMailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(Company $company)
public function envelope(): Envelope
{
return new Envelope(
subject: 'Sponsorship Disapproved',
subject: 'Sponsorship Refused',
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Models/Presentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logAll()
->setDescriptionForEvent(fn(string $eventName) => "{$this->name} booth has been {$eventName} by " . Auth::user()->name)
->setDescriptionForEvent(fn(string $eventName) => "Presentation {$this->name} has been {$eventName} by " . Auth::user()->name)
->logOnlyDirty()
->dontLogIfAttributesChangedOnly(['is_approved']);
}
Expand Down
9 changes: 7 additions & 2 deletions app/Policies/RoomPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Policies;

use App\Models\Room;
use App\Models\User;

class RoomPolicy
Expand Down Expand Up @@ -56,8 +57,12 @@ public function update(User $user): bool
* @param User $user
* @return bool
*/
public function delete(User $user)
public function delete(User $user, Room $room)
{
return $user->can('delete room');
if (!$user->can('delete room')) {
return false;
}

return $room->presentations->count() == 0 && $room->defaultPresentations->count() == 0;
}
}
2 changes: 1 addition & 1 deletion database/factories/CompanyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function definition(): array
{
return [
'name' => $this->faker->unique()->company(),
'website' => 'www.example.com',
'website' => 'https://www.example.com',
'description' => $this->faker->paragraph(),
'motivation' => $this->faker->paragraph(),
'phone_number' => $this->faker->phoneNumber,
Expand Down
Loading
Loading