Skip to content

Commit

Permalink
Merge pull request #190 from HACManchester/rm-storage
Browse files Browse the repository at this point in the history
Hide online member storage claims
  • Loading branch information
rjackson authored Feb 4, 2025
2 parents dda6096 + c70ce4a commit 1c32ec1
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 62 deletions.
19 changes: 17 additions & 2 deletions app/Policies/StorageBoxPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ class StorageBoxPolicy
{
use HandlesAuthorization;

public function before($user, $ability)
{
if ($user->isAdmin() || $user->hasRole('storage')) {
return true;
}

// fall through to policy methods
return null;
}

/**
* Determine whether the user can view the StorageBox.
*
Expand Down Expand Up @@ -58,11 +68,16 @@ public function delete(User $user, StorageBox $StorageBox)
return Auth::user()->isAdmin();
}

public function canViewOld(User $user)
{
return false;
}

public function claim(User $user, StorageBox $StorageBox)
{
return Auth::user()->isActive() && Auth::user()->storageBoxes->isEmpty();
return false;
}

public function release(User $user, StorageBox $StorageBox)
{
return $user->id == $StorageBox->user_id || Auth::user()->isAdmin();
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,6 @@ parameters:
count: 3
path: app/Policies/KeyFobPolicy.php

-
message: "#^Access to an undefined property Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable\\:\\:\\$storageBoxes\\.$#"
count: 1
path: app/Policies/StorageBoxPolicy.php

-
message: "#^If condition is always true\\.$#"
count: 1
Expand Down
28 changes: 20 additions & 8 deletions resources/views/account/partials/signposts/item-storage.blade.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
<li class="signposts-grid-item">
<div class="panel panel-default">
<div class="panel {{ $user->storageBoxes()->count() ? 'panel-danger' : 'panel-warning' }}">
<div class="panel-heading">
<h3 class="panel-title">📦 Storage space</h3>
</div>
<div class="panel-body">
<p><strong>Your storage space is: {{ $user->storageBoxes()->count() ? $user->storageBoxes()->first()->location : '(none claimed)' }}</strong></p>
@if ($user->storageBoxes()->count() > 0)
<div class="alert alert-danger">
<strong>Storage is changing (action required)</strong>
<p>Please add a sticker to any items you've stored before 1st July 2025, or your items may be disposed of.</p>
<p>See signage in the Hackspace storage area for full details.</p>
</div>
<p><strong>Your storage space is: {{ $user->storageBoxes()->count() ? $user->storageBoxes()->first()->location : '(none claimed)' }}</strong></p>

<p>To claim a storage space, or return your space for somebody else to use, visit the Member&apos;s Storage page.</p>
<p>To relinquish your claimed storage location, visit the Member&apos;s Storage page.</p>

<div class="signpost-grid-item-buttons">
<a class="btn btn-primary btn-block" href="{{ route('storage_boxes.index') }}">
Manage Storage
</a>
</div>
<div class="signpost-grid-item-buttons">
<a class="btn btn-primary btn-block" href="{{ route('storage_boxes.index') }}">
Manage Storage
</a>
</div>
@else
<p>
As of January 2025, storage is managed physically with time-limited stickers.
See signage in the Hackspace storage area for full details.
</p>
@endif
</div>
</div>
</li>
117 changes: 70 additions & 47 deletions resources/views/storage_boxes/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
@stop

@section('content')

<div class="well">
<h1>Storage is changing: Add stickers to your items by 1st July 2025</h1>
<ul>
<li>Storage will no longer be managed online</li>
<li>Items being stored must have a storage sticker on them, allowing them to be stored for a period of time.</li>
<li>New stickers will be released every 3 months</li>
<li>Items left with old stickers on them may be disposed of, as per our storage guidelines.</li>
</ul>
<p>
The new storage system went into effect in January 2025, with a
grace period until 1st July 2025.
</p>
<strong>Items left without stickers after 1st July 2025 will be disposed of.</strong>
</div>

<div class="row">
<div class="col-md-6">
<div class="well">
Expand Down Expand Up @@ -44,54 +60,61 @@
</div>
</div>

<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Location</th>
<th>Member</th>
<th>Message</th>
@if (Auth::user()->hasRole('storage'))
<th>Admin</th>
@endif
</tr>
</thead>
@foreach ($storageBoxes as $box)
<tbody>
<tr
@if($box->user && !$box->user->active)class="warning"@elseif(!$box->user)class="success"@endif
>
<td><a href="{{ route('storage_boxes.show', $box) }}">{{ $box->id }}</a></td>
<td>{{ $box->location }}</td>
<td>
@if($box->isClaimed())
<a href="{{ route('members.show', $box->user) }}">
{{ $box->user->name }}
</a>
@else
Available
@endif
</td>
<td>
@if($box->isClaimed() && !$box->user->active)
⚠️ Member left
@elseif (!$box->isClaimed())
@if (Auth::user()->online_only)
⛔ Not available to be claimed
@can('canViewOld', BB\Entities\StorageBox::class)
<div class="well">
<h1>Previous storage claims</h1>
<p>These will no longer be in effect after the July 2025 grace period deadline.</p>
<p>This box and below is only visible to admins and storage managers.</p>
</div>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Location</th>
<th>Member</th>
<th>Message</th>
@if (Auth::user()->hasRole('storage'))
<th>Admin</th>
@endif
</tr>
</thead>
@foreach ($storageBoxes as $box)
<tbody>
<tr
@if($box->user && !$box->user->active)class="warning"@elseif(!$box->user)class="success"@endif
>
<td><a href="{{ route('storage_boxes.show', $box) }}">{{ $box->id }}</a></td>
<td>{{ $box->location }}</td>
<td>
@if($box->isClaimed())
<a href="{{ route('members.show', $box->user) }}">
{{ $box->user->name }}
</a>
@else
@can('claim', $box)
{!! Form::open(array('method'=>'POST', 'route' => ['storage_boxes_claim.update', $box->id], 'class'=>'navbar-left')) !!}
{!! Form::submit('Claim', array('class'=>'btn btn-default')) !!}
{!! Form::close() !!}
@endcan
Available
@endif
</td>
<td>
@if($box->isClaimed() && !$box->user->active)
⚠️ Member left
@elseif (!$box->isClaimed())
@if (Auth::user()->online_only)
⛔ Not available to be claimed
@else
@can('claim', $box)
{!! Form::open(array('method'=>'POST', 'route' => ['storage_boxes_claim.update', $box->id], 'class'=>'navbar-left')) !!}
{!! Form::submit('Claim', array('class'=>'btn btn-default')) !!}
{!! Form::close() !!}
@endcan
@endif
@endif
</td>
@if (Auth::user()->isAdmin() || Auth::user()->hasRole('storage'))
<td><a href="{{ route('storage_boxes.show', $box) }}">Admin</a></td>
@endif
</td>
@if (Auth::user()->isAdmin() || Auth::user()->hasRole('storage'))
<td><a href="{{ route('storage_boxes.show', $box) }}">Admin</a></td>
@endif
</tr>
</tbody>
@endforeach
</table>
</tr>
</tbody>
@endforeach
</table>
@endcan
@stop

0 comments on commit 1c32ec1

Please sign in to comment.