Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

improved the permission system #308

Merged
merged 2 commits into from
Aug 28, 2023
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
12 changes: 10 additions & 2 deletions app/Http/Controllers/Admin/PermController.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function shotgun() {
}

public function doShotgun($id) {
$redirection = redirect(route('perm.shotgun'));
$redirection = redirect(route('dashboard.perm.shotgun'));
$user = Auth::user();
$perm = Perm::find($id);
if ($user->is_newcomer) {
Expand Down Expand Up @@ -385,7 +385,7 @@ public function doShotgun($id) {
}

public function doUnshotgun($id) {
$redirection = redirect(route('perm.shotgun'));
$redirection = redirect(route('dashboard.perm.shotgun'));
$user = Auth::user();
$perm = Perm::find($id);
$found = false;
Expand All @@ -411,4 +411,12 @@ public function doUnshotgun($id) {
$perm->permanenciers()->detach($user->id);
return $redirection->withSuccess('Tu as bien quitté la perm.');
}

public function shotgunedList() {
$user = Auth::user();
$perms = Perm::join('perm_users', 'perm_users.perm_id', '=', 'perms.id')
->where('user_id', '=', $user->id)
->where('respo', '=', 0)->get();
return view('dashboard.perms.shotguned', compact('perms'));
}
}
10 changes: 5 additions & 5 deletions resources/views/dashboard/perms/shotgun.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<th>Nom</th>
<th>Lieu</th>
<th>Jour</th>
<th>Heure</th>
<th>Durée</th>
<th>Début</th>
<th>Fin</th>
<th>Permanenciers</th>
<th>Description</th>
<th>Points</th>
Expand All @@ -31,14 +31,14 @@
<tr class="align-middle">
<td>
<form action="{{ url('dashboard/perm/'.($perm->isAlreadyIn ? 'unshotgun' : 'shotgun').'/'.$perm->id) }}" method="post">
<button class="btn btn-xl {{ $perm->isAlreadyIn ? 'btn-danger' : 'btn-success' }}" {{$perm->isOpen ? '' : 'disabled'}} type="submit">{{ $perm->isAlreadyIn ? 'Quitter' : "S'inscrire" }}</button>
<button class="btn btn-xl {{ $perm->isAlreadyIn ? 'btn-danger' : 'btn-success' }}" {{ $perm->isOpen ? '' : 'disabled' }} type="submit">{{ $perm->isAlreadyIn ? 'Quitter' : "S'inscrire" }}</button>
</form>
</td>
<td>{{ $perm->type->name }}</td>
<td>{{ $perm->place }}</td>
<td>{{ date('l', $perm->start) }}</td>
<td>{{ strftime('%A', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->start) }}</td>
<td>{{ gmdate('G\\Hi', $perm->end - $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->end) }}</td>
<td>{{ $perm->permanenciers->count().'/'.$perm->nbr_permanenciers }}</td>
<td>{{ $perm->description }}</td>
<td>{{ $perm->type->points }}</td>
Expand Down
51 changes: 51 additions & 0 deletions resources/views/dashboard/perms/shotguned.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@extends('layouts.dashboard')

@section('title')
Permanences que tu as prises
@endsection

@section('smalltitle')
Liste des permanences que tu as prises.
@endsection

@section('content')
<div class="callout callout-info">
<h4>Liste de tes permanences</h4>
</div>
<div class="box box-default">
<div class="box-body table-responsive no-padding">
<table class="table table-hover align-middle text-center">
<tbody>
<tr>
<th>Nom</th>
<th>Lieu</th>
<th>Date</th>
<th>Début</th>
<th>Fin</th>
<th>Permanenciers</th>
<th>Description</th>
<th>Points</th>
<th>Quitter</th>
</tr>
@foreach ($perms as $perm)
<tr class="align-middle">
<td>{{ $perm->type->name }}</td>
<td>{{ $perm->place }}</td>
<td>{{ date('j/n/y', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->end) }}</td>
<td>{{ $perm->permanenciers->count().'/'.$perm->nbr_permanenciers }}</td>
<td>{{ $perm->description }}</td>
<td>{{ $perm->type->points }}</td>
<td>
<form action="{{ url('dashboard/perm/unshotgun/'.$perm->id) }}" method="post">
<button class="btn btn-xl btn-danger" type="submit">Quitter</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
3 changes: 2 additions & 1 deletion resources/views/layouts/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
<li><a href="{{ url('dashboard/perm') }}">Liste des permanences</a></li>
<li><a href="{{ url('dashboard/permType') }}">Types de permanences</a></li>
@endif
<li><a href="{{ url('dashboard/perm/shotgun') }}">Shotgun des permanences</a></li>
<li><a href="{{ route('dashboard.perm.shotgun') }}">Shotgun des permanences</a></li>
<li><a href="{{ route('dashboard.perm.shotgun.list') }}">Liste de tes perms</a></li>
</ul>
</li>
@if (Auth::user()->isAdmin())
Expand Down
3 changes: 2 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@

// Perm model's route (for all users)
Route::group(['middleware' => 'authorize:volunteer'], function () {
Route::get('/perm/shotgun', ['as' => 'perm.shotgun', 'uses' => 'Admin\PermController@shotgun']);
Route::get('/perm/shotgun', ['as' => 'dashboard.perm.shotgun', 'uses' => 'Admin\PermController@shotgun']);
Route::get('/perm/shotgun/list', ['as' => 'dashboard.perm.shotgun.list', 'uses' => 'Admin\PermController@shotgunedList']);
Route::post('/perm/shotgun/{id}', ['uses' => 'Admin\PermController@doShotgun']);
Route::post('/perm/unshotgun/{id}', ['uses' => 'Admin\PermController@doUnshotgun']);
});
Expand Down