Skip to content

Commit

Permalink
Merge pull request #924 from Lan2Play/feature/enhancements-and-bugfix…
Browse files Browse the repository at this point in the history
…es-mawiguk0

Feature/enhancements and bugfixes by @Mawiguk0
  • Loading branch information
Apfelwurm authored Nov 13, 2024
2 parents 687c621 + f48257d commit ff9d285
Show file tree
Hide file tree
Showing 64 changed files with 3,189 additions and 2,038 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ folder-structure-prd:
mkdir -p /src/storage/app/public/images/venues/ && \
mkdir -p /src/storage/app/public/images/main/ && \
mkdir -p /src/storage/app/public/images/shop/ && \
mkdir -p /src/storage/app/public/images/avatars/ && \
mkdir -p /src/storage/app/public/attachments/help/"

folder-structure-dev:
Expand All @@ -232,6 +233,7 @@ folder-structure-dev:
mkdir -p /src/storage/app/public/images/venues/ && \
mkdir -p /src/storage/app/public/images/main/ && \
mkdir -p /src/storage/app/public/images/shop/ && \
mkdir -p /src/storage/app/public/images/avatars/ && \
mkdir -p /src/storage/app/public/attachments/help/"

# Create SSL Keypair for Development
Expand Down Expand Up @@ -426,6 +428,7 @@ purge-files:
touch /src/public/css/images/.gitkeep; \
rm -rf /src/storage/app/public/images/gallery ; \
rm -rf /src/storage/app/public/images/events ; \
rm -rf /src/storage/app/public/images/avatars ; \
rm -rf /src/storage/app/public/images/venues ; \
rm -rf /src/storage/app/public/images/main ; \
rm -rf /src/storage/user/scss/*.css ; \
Expand Down
4 changes: 4 additions & 0 deletions currentchangelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-Added Change for Events Venue after creating
-Added iCal for Events Information
-Added Tournament Participation Control for Staff and Freebie Event Participants
-Added Partials for Event Information, Event Information Card, Sponsors, Seating
-Added Multilanguage support on a per site bases
-Added Translation to german
-Added Gameserver Management per game (includes a management/Rcon feature and a api for the CS:go tournament plugin Get5)
Expand Down
66 changes: 65 additions & 1 deletion src/app/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Carbon\Carbon;

use Cviebrock\EloquentSluggable\Sluggable;

Expand Down Expand Up @@ -37,7 +38,11 @@ class Event extends Model
'seating_cap',
'spectator_cap',
'ticket_spectator',
'ticket_weekend'
'ticket_weekend',
'private_participants',
'matchmaking_enabled',
'tournaments_freebies',
'tournaments_staff'
];

/**
Expand Down Expand Up @@ -87,6 +92,36 @@ protected static function boot()
}
}


/**
* Scope a query to get the next upcoming event(s).
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $limit
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNextUpcoming(Builder $query, int $limit = 1): Builder
{
return $query->where('end', '>=', Carbon::now())
->orderByRaw('ABS(DATEDIFF(events.end, NOW()))')
->limit($limit);
}

/**
* Scope a query to get the current active event(s).
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param \Carbon\Carbon|null $now
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCurrent(Builder $query, Carbon $now = null): Builder
{
$now = $now ?? Carbon::now();
return $query->where('start', '<', $now)
->where('end', '>', $now)
->orderBy('id', 'desc');
}

/*
* Relationships
*/
Expand Down Expand Up @@ -330,4 +365,33 @@ public function addTagById($tag)
}
return true;
}

/**
* Get if Event is currently running
* @return Boolean
*/
public function isRunningCurrently()
{
return $this->isRunningOn(Carbon::now());
}

/**
* Get if Event is running on a specific date
* @param Carbon $date
* @return Boolean
*/
public function isRunningOn(Carbon $date)
{
return $date->between(Carbon::create($this->start),Carbon::create($this->end));
}

/**
* Get if Event has already ended
* @return Boolean
*/
public function hasEnded()
{
return Carbon::create($this->end)->greaterThan(Carbon::now());
}

}
28 changes: 20 additions & 8 deletions src/app/EventParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class EventParticipant extends Model
'event_id',
'ticket_id',
'purchase_id',
'staff',
'free',
];

public static function boot()
Expand Down Expand Up @@ -137,18 +139,15 @@ public function getGiftedByUser()
*/
public function generateQRCode($forcenewname = false)
{
if(Str::startsWith(config('app.url'), ['http://', 'https://'])) {
if (Str::startsWith(config('app.url'), ['http://', 'https://'])) {
$ticketUrl = config('app.url') . '/tickets/retrieve/' . $this->id;
} else {
$ticketUrl = 'https://' . config('app.url') . '/tickets/retrieve/' . $this->id;
}

if (isset($this->qrcode) && $this->qrcode != "" && !$forcenewname)
{
if (isset($this->qrcode) && $this->qrcode != "" && !$forcenewname) {
$qrCodeFullPath = $this->qrcode;
}
else
{
} else {
$qrCodePath = 'storage/images/events/' . $this->event->slug . '/qr/';
$qrCodeFileName = $this->event->slug . '-' . Str::random(32) . '.png';
if (!file_exists($qrCodePath)) {
Expand Down Expand Up @@ -203,7 +202,8 @@ public static function getNewParticipants($type = 'all')
return $particpants;
}

public function getPdf(): string {
public function getPdf(): string
{
$user = Auth::user();
$data = new \stdClass();
// TODO: Probably don't use str_replace
Expand Down Expand Up @@ -253,10 +253,22 @@ function setRevoked()
if (!$this->seat) {
return $this->save();
}
if (!$this->seat->delete()) {
if (!$this->seat->delete() || !$this->setSignIn(false)) {
$this->revoked = false;
return false;
}
return $this->save();
}

/**
* Check if participant is active
* @return Boolean
*/
public function isActive()
{

return ($this->signed_in || $this->event->online_event) &&
($this->free || $this->staff || $this->purchase->status == "Success") &&
(!$this->revoked);
}
}
12 changes: 12 additions & 0 deletions src/app/EventTimetableData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use App\EventTimetable;
use App\Http\Requests;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;


class EventTimetableData extends Model
{
Expand All @@ -22,4 +24,14 @@ public function timetable()
{
return $this->belongsTo('App\EventTimetable');
}


protected static function boot()
{
parent::boot();

static::addGlobalScope('start_time', function (Builder $builder) {
$builder->orderBy('start_time', 'asc');
});
}
}
59 changes: 58 additions & 1 deletion src/app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redirect;
use Session;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Settings;

use App\Rules\ValidLocale;

class AccountController extends Controller
{
Expand Down Expand Up @@ -236,7 +239,13 @@ public function removeSso(Request $request, $method)
case 'steam':
$user->steamname = "";
$user->steamid = "";
$user->avatar = "";
$user->steam_avatar = "";

if ($user->selected_avatar == 'steam')
{
$user->selected_avatar = 'local';
}

break;
default:
return Redirect::back()->withError('no valid sso method selected');
Expand Down Expand Up @@ -267,6 +276,7 @@ public function update(Request $request)
'surname' => 'filled',
'password1' => 'same:password2',
'password2' => 'same:password1',
'locale' => ['nullable', new ValidLocale]
];
$messages = [
'firstname.filled' => 'Firstname Cannot be blank.',
Expand Down Expand Up @@ -295,6 +305,10 @@ public function update(Request $request)

$user->firstname = @$request->firstname;
$user->surname = @$request->surname;

if (isset($request->locale)) {
$user->locale = @$request->locale;
}

if (!$user->save()) {
return Redirect::back()->withFail("Oops, Something went Wrong.");
Expand Down Expand Up @@ -343,4 +357,47 @@ public function updateMail(Request $request)
}
return redirect('/');
}

public function update_local_avatar(Request $request) {
$this->validate($request, [
'avatar' => 'required|image|mimes:jpg,png,jpeg,gif,svg|max:2048',
]);

if(!$path = Storage::putFile(
'public/images/avatars', $request->file('avatar')
))
{
Session::flash('alert-danger', 'Oops,Something went wrong while uploading the File on the custom avatar upload.');
return Redirect::back();
}
$user = Auth::user();
$user->local_avatar = '/storage/images/avatars/' . basename($path);
$user->selected_avatar = 'local';
if (!$user->save()) {
Session::flash('alert-danger', 'Oops, Something went wrong while updating the user on the custom avatar upload.');
return Redirect::back();
}

Session::flash('alert-success', 'Custom avatar successfully updated!');
return Redirect::back();
}

public function update_selected_avatar(Request $request) {

$this->validate($request, [
'selected_avatar' => 'required|in:steam,local',
]);

$user = Auth::user();
$user->selected_avatar = $request->selected_avatar;
if (!$user->save()) {
Session::flash('alert-danger', 'Oops, Something went wrong while updating the user on the selected avatar change.');
return Redirect::back();
}

Session::flash('alert-success', 'Selected avatar successfully updated!');
return Redirect::back();
}


}
Loading

0 comments on commit ff9d285

Please sign in to comment.