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

Update team names & youtube social #124

Merged
merged 5 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions app/Http/Controllers/Web/Tournament/TournamentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public function update(Request $request, Tournament $tournament)
'prize' => ['nullable', 'array'],
'rank' => ['nullable', 'array'],
'register' => ['nullable', 'array'],
'discord' => ['nullable'],
'twitch' => ['nullable'],
'spreadsheet' => ['nullable'],
'twitter' => ['nullable'],
'discord' => ['nullable', 'url'],
'twitch' => ['nullable', 'url'],
'spreadsheet' => ['nullable', 'url'],
'twitter' => ['nullable', 'url'],
'youtube' => ['nullable', 'url'],
'information' => ['nullable'],
'discord_webhook_registrations' => ['nullable'],
'discord_webhook_matches' => ['nullable'],
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Web/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function update(Request $request)
foreach ($tournaments as $tournament) {
$team = $loggedUser->teams()->firstWhere('tournament_id', $tournament->id);
$team->timezone_offset = $loggedUser->timezone_offset;
$team->name = $loggedUser->username;
$team->save();
}
});
Expand Down
13 changes: 13 additions & 0 deletions app/Jobs/UserUpdateJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Jobs;

use App\Enums\TournamentFormat;
use App\Enums\TournamentStatus;
use App\Enums\UserRoles;
use App\Http\QuaverApi\QuaverApi;
use App\Models\User;
Expand Down Expand Up @@ -38,6 +40,17 @@ public function handle(): void
foreach ($this->user->teams as $team) {
$team->updateTeamRank();
}

// Update team names
$tournaments = $this->user->participatedTournaments()
->where('status', '!=', TournamentStatus::Concluded)
->where('format', TournamentFormat::Solo);

foreach ($tournaments as $tournament) {
$team = $this->user->teams()->firstWhere('tournament_id', $tournament->id);
$team->name = $this->user->username;
$team->save();
}
}
} catch (\Exception $e) {
$this->user->roles()->create(['role' => UserRoles::Blacklisted]);
Expand Down
6 changes: 3 additions & 3 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public function register()
*/
public function boot()
{
if (config('app.env') == "local") {
Model::preventLazyLoading();
}
// if (config('app.env') == "local") {
// Model::preventLazyLoading();
// }

if (config('app.env') == 'production') {
\URL::forceScheme('https');
Expand Down
11 changes: 8 additions & 3 deletions resources/views/web/tournaments/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

<hr>

<div class="row">
<div class="row gy-3">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label">{{ __('Discord URL') }}</label>
Expand All @@ -135,9 +135,7 @@
{{ Form::text('twitch', $tournament->getMeta('twitch')??"", ['class' => 'form-control']) }}
</div>
</div>
</div>

<div class="row mt-2">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label">{{ __('Spreadsheet URL') }}</label>
Expand All @@ -151,6 +149,13 @@
{{ Form::text('twitter', $tournament->getMeta('twitter')??"", ['class' => 'form-control']) }}
</div>
</div>

<div class="col-lg-6">
<div class="form-group">
<label class="form-label">{{ __('YouTube URL') }}</label>
{{ Form::text('youtube', $tournament->getMeta('youtube')??"", ['class' => 'form-control']) }}
</div>
</div>
</div>

<hr>
Expand Down
8 changes: 8 additions & 0 deletions resources/views/web/tournaments/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
{{ __('Twitch') }}
</a>
@endif
@if($tournament->getMeta('youtube'))
<a href="{{ $tournament->getMeta('youtube') }}" class="btn btn-youtube btn-sm"
target="_blank"
rel="noreferrer">
<i class="bi bi-youtube"></i>
{{ __('YouTube') }}
</a>
@endif
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion resources/views/web/user/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class="btn btn-discord"
</div>
@endif
</div>
<small>{{ __('If you have linked the wrong Discord account, please contact tournament organizer or site admins!') }}</small>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/TournamentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public function testEditAndUpdate()
$this->tournament->refresh();
$this->assertEquals(TournamentStatus::RegistrationsOpen, $this->tournament->status);

$data = ['discord' => 'ababa'];
$data = ['discord' => 'https://discord.com'];
$this->actingAs($this->organizer)
->put(route('web.tournaments.update', $this->tournament), $data)->assertRedirect();
$this->tournament->refresh();
$this->assertEquals('ababa', $this->tournament->discord);
$this->assertEquals('https://discord.com', $this->tournament->discord);
}

public function testDelete()
Expand Down
Loading